temp font fix

This commit is contained in:
herbglitch 2024-12-13 03:30:43 -07:00
parent c9e5cb2d11
commit 75cf426d1a

View file

@ -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;
}
}