This commit is contained in:
2025-02-06 14:33:23 +01:00
parent 2a2313dff7
commit aaf3dfb40c
5 changed files with 203 additions and 29 deletions

View File

@@ -6,21 +6,14 @@
BitmapFont
prepText(SDL_Renderer *renderer, unsigned char pxSize, const char *file, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
const unsigned char ptSize = floor(pxSize * 0.75);
TTF_Font *gFont = TTF_OpenFont(file, ptSize);
TTF_Font *gFont = TTF_OpenFont(file, pxSize);
BitmapFont out;
out.size = pxSize;
out.color = (SDL_Color) {r, g, b, a};
unsigned char i = 0;
do {
char tmpOut[2] = {i, 0};
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
SDL_Rect dstRect;
dstRect.x = 0;
dstRect.y = 0;
dstRect.w = pxSize;
dstRect.h = pxSize;
out.texture[i] = SDL_CreateTextureFromSurface(renderer, out.surface[i]);
i++;
} while (i < 255);