Some changes

This commit is contained in:
2025-02-16 17:28:10 +01:00
parent 0fc4040ad7
commit 4d3755e2ce
18 changed files with 562 additions and 80 deletions

View File

@@ -13,10 +13,10 @@ prepText(SDL_Renderer *renderer, unsigned char pxSize, const char *file, uint8_t
unsigned int i = 1;
do {
if (i == 173) { //specifically this char is 0 width (IDK why)
out.surface[i] = SDL_CreateRGBSurface(0,pxSize,pxSize,32,0,0,0,0);
out.surface[i] = SDL_CreateRGBSurface(0, pxSize, pxSize, 32, 0, 0, 0, 0);
} else {
char tmpOut[2] = {i, 0};
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
char tmpOut[2] = {i, 0};
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
}
out.texture[i] = SDL_CreateTextureFromSurface(renderer, out.surface[i]);
i++;
@@ -51,7 +51,11 @@ void renderText(SDL_Renderer *renderer, BitmapFont font, char *string, uint16_t
void destroyFont(BitmapFont *font) {
for (uint16_t i = 1; i < 256; i++) {
SDL_DestroyTexture(font->texture[i]);
SDL_FreeSurface(font->surface[i]);
if (font->texture[i]) {
SDL_DestroyTexture(font->texture[i]);
}
if (font->surface[i]) {
SDL_FreeSurface(font->surface[i]);
}
}
}