From 3f69f6c63c49ba74b8fcd8357b9b7d0498486f95 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 12 Nov 2024 20:28:12 +0100 Subject: Fix multiline text height --- src/graphics/text.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/graphics/text.c') diff --git a/src/graphics/text.c b/src/graphics/text.c index e84e4b1..e872360 100644 --- a/src/graphics/text.c +++ b/src/graphics/text.c @@ -67,8 +67,7 @@ static void mgl_text_for_each_codepoint(const mgl_text *self, codepoint_loop_cal if(((glyph_offset.x + kerning + glyph_width > self->max_width) && self->max_width > 0.001f) || codepoint == '\n') { glyph_offset.x = 0.0f; - if(codepoint != '\n') - glyph_offset.y += self->font->character_size; + glyph_offset.y += self->font->character_size; prev_codepoint = 0; if(rows == self->max_rows) @@ -82,8 +81,8 @@ static void mgl_text_for_each_codepoint(const mgl_text *self, codepoint_loop_cal return; glyph_offset.x += glyph_width; - if(codepoint == '\n') - glyph_offset.y += self->font->character_size; + //if(codepoint == '\n') + // glyph_offset.y += self->font->character_size; prev_codepoint = codepoint; @@ -100,7 +99,7 @@ typedef struct { static bool calculate_bounds_callback(codepoint_loop_callback_data callback_data, void *userdata) { CalculateBoundsUserdata *calculate_bounds_userdata = userdata; calculate_bounds_userdata->bounds.x = max_float(calculate_bounds_userdata->bounds.x, callback_data.glyph_offset.x + callback_data.glyph_width); - calculate_bounds_userdata->bounds.y = max_float(calculate_bounds_userdata->bounds.y, callback_data.glyph_offset.y); + calculate_bounds_userdata->bounds.y = max_float(calculate_bounds_userdata->bounds.y, callback_data.glyph_offset.y + callback_data.glyph->size.y); return true; } -- cgit v1.2.3