text stuff, I forgot

This commit is contained in:
herbglitch 2023-06-20 00:27:54 -06:00
parent 7018500555
commit 8a29955b1f
3 changed files with 9 additions and 8 deletions

View file

@ -7,10 +7,6 @@
#include <SDL2/SDL_ttf.h>
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);