diff --git a/packages/graphics/sdl/text.c b/packages/graphics/sdl/text.c index f2a8bba..6cdf23d 100644 --- a/packages/graphics/sdl/text.c +++ b/packages/graphics/sdl/text.c @@ -15,6 +15,11 @@ void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color (*text)->color = color; (*text)->texture = NULL; (*text)->bounds = (ARC_Rect){ 0, 0, 0, 0 }; + + if(TTF_Init()==-1) { + printf("TTF_Init: %s\n", TTF_GetError()); + exit(2); + } } void ARC_Text_Destroy(ARC_Text *font){ @@ -28,6 +33,7 @@ void ARC_Text_Destroy(ARC_Text *font){ void ARC_Text_SetString(ARC_Text *text, ARC_Renderer *renderer, ARC_String *string){ TTF_Font *ttfont = TTF_OpenFont(text->name->data, text->size); SDL_Color textColor = (SDL_Color){ text->color.r, text->color.g, text->color.b, text->color.a }; + SDL_Surface *surface = TTF_RenderText_Blended_Wrapped(ttfont, string->data, textColor, 0); text->bounds.w = surface->w; @@ -54,4 +60,4 @@ void ARC_Text_Render(ARC_Text *text, ARC_Renderer *renderer){ void ARC_Text_SetPos(ARC_Text *text, ARC_Point pos){ text->bounds.x = pos.x; text->bounds.y = pos.y; -} \ No newline at end of file +}