src/text.c

changeset 23
ab07757004b4
parent 19
d0e88022e209
child 24
7183b4ae9b20
     1.1 --- a/src/text.c	Mon Dec 18 19:05:30 2023 +0100
     1.2 +++ b/src/text.c	Thu Jan 18 21:53:16 2024 +0100
     1.3 @@ -42,9 +42,7 @@
     1.4      node->position = (asc_vec2i) {x, y};
     1.5      node->font = asc_context.active_font;
     1.6      node->color = asc_context.ink;
     1.7 -    cxBufferInit(&node->text, NULL, strlen(text)+8,
     1.8 -                 cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
     1.9 -    cxBufferPutString(&node->text, text);
    1.10 +    node->text = strdup(text);
    1.11  
    1.12      return node;
    1.13  }
    1.14 @@ -64,15 +62,10 @@
    1.15          asc_dprintf("Generated new texture for text node: %u", node->internal.tex_id);
    1.16      }
    1.17  
    1.18 -    // ensure the text is zero-terminated
    1.19 -    CxBuffer* text = &(node->text);
    1.20 -    cxBufferMinimumCapacity(text, text->size+1);
    1.21 -    text->space[text->size] = '\0';
    1.22 -
    1.23      // Render text onto a surface
    1.24      SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped(
    1.25              asc_font_cache_validate(node->font)->ptr,
    1.26 -            text->space,
    1.27 +            node->text,
    1.28              asc_col_sdl(node->color),
    1.29              node->max_width
    1.30      );
    1.31 @@ -136,6 +129,6 @@
    1.32  void asc_text_free(AscTextNode *node) {
    1.33      asc_dprintf("Release text node texture: %u", node->internal.tex_id);
    1.34      glDeleteTextures(1, &node->internal.tex_id);
    1.35 -    cxBufferDestroy(&node->text);
    1.36 +    free(node->text);
    1.37      free(node);
    1.38  }
    1.39 \ No newline at end of file

mercurial