diff --git a/include/arc/graphics/text.h b/include/arc/graphics/text.h index a73ab11..3838fd7 100644 --- a/include/arc/graphics/text.h +++ b/include/arc/graphics/text.h @@ -11,8 +11,6 @@ extern "C" { #include "arc/math/point.h" #include "arc/std/string.h" -void ARC_TTF_Init(); - typedef struct ARC_Text ARC_Text; void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color color); diff --git a/src/engine/engine.c b/src/engine/engine.c index 228ba5e..3b0fa67 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -16,6 +16,7 @@ #include "arc/input/sdl/keyboard.h" #include #include +#include #elif ARC_OPENGL #include "arc/graphics/opengl/window.h" #include "arc/graphics/opengl/renderer.h" @@ -39,6 +40,10 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf ARC_KeyboardInfo keyboardInfo; (*data)->windowSize = windowSize; +//TEMP +#ifdef ARC_SDL + TTF_Init(); +#endif #ifdef ARC_SDL windowInfo = (ARC_WindowInfo){ "title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (*data)->windowSize.x, (*data)->windowSize.y, 0 }; diff --git a/src/graphics/sdl/text.c b/src/graphics/sdl/text.c index 1868b8a..0cd81d2 100644 --- a/src/graphics/sdl/text.c +++ b/src/graphics/sdl/text.c @@ -7,10 +7,6 @@ #include -void ARC_TTF_Init(){ - TTF_Init(); -} - void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color color){ *text = (ARC_Text *)malloc(sizeof(ARC_Text)); ARC_String_Copy(&(*text)->name, path); @@ -31,9 +27,11 @@ 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(ttfont, string->data, textColor); + SDL_Surface *surface = TTF_RenderText_Blended_Wrapped(ttfont, string->data, textColor, 0); + + text->bounds.w = surface->w; + text->bounds.h = surface->h; - TTF_SizeText(ttfont, string->data, &(text->bounds.w), &(text->bounds.h)); text->texture = SDL_CreateTextureFromSurface((SDL_Renderer *)renderer, surface); SDL_FreeSurface(surface);