diff options
| author | Menase Teshale <osome3717@gmail.com> | 2026-09-04 20:47:08 +0300 |
|---|---|---|
| committer | Menase Teshale <osome3717@gmail.com> | 2026-09-04 20:47:08 +0300 |
| commit | 7b407b8083268e982cbc80b6c1f969dcdc6dec8d (patch) | |
| tree | 85c67eb54bd4c48852bc9777e1596fd192c58f2c /src/font.c | |
| parent | cd4a22bbfbe032d92616313853026f17b89b362b (diff) | |
Scaling Added
Diffstat (limited to 'src/font.c')
| -rw-r--r-- | src/font.c | 32 |
1 files changed, 25 insertions, 7 deletions
@@ -326,12 +326,13 @@ bool load_sprite_font(SDL_Renderer* renderer, const char* filename, sprite_font* return true; } -void draw_text_with_spritefont +void draw_text_with_spritefont_extended ( SDL_Renderer* renderer, sprite_font* font, const unsigned char* text, - float x_position, float y_position + float x_position, float y_position, + float scale ) { while (*text) { const font_char* fc = &font->characters[*text-font->smallest_character]; @@ -349,12 +350,29 @@ void draw_text_with_spritefont .h = fc->height }, &(SDL_FRect){ - .x = x_position + fc->x_offset, - .y = y_position + fc->y_offset, - .w = fc->width, - .h = fc->height + .x = x_position + fc->x_offset*scale, + .y = (y_position + fc->y_offset) * scale, + .w = fc->width * scale, + .h = fc->height * scale }); - x_position += fc->x_advance; + x_position += fc->x_advance * scale; text++; } } + + +void draw_text_with_spritefont +( + SDL_Renderer* renderer, + sprite_font* font, + const unsigned char* text, + float x_position, float y_position +) { + draw_text_with_spritefont_extended(renderer, + font, + text, + x_position, + y_position, + 1.0 + ); +} |
