From 7b407b8083268e982cbc80b6c1f969dcdc6dec8d Mon Sep 17 00:00:00 2001 From: Menase Teshale Date: Fri, 4 Sep 2026 20:47:08 +0300 Subject: Scaling Added --- src/font.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/font.c') diff --git a/src/font.c b/src/font.c index 17c62ad..b04c0df 100644 --- a/src/font.c +++ b/src/font.c @@ -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 + ); +} -- cgit v1.2.3