From de49e676fae6060ac85864bdd8471b525305c9fb Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Fri, 22 Dec 2023 11:33:14 -0300 Subject: fixt Remove bug when computing text size * src/texture.cpp: Fix number of arguments. * src/vk/texture.cpp: Fix image size when last character have a negative bearing. --- src/vk/texture.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/vk') diff --git a/src/vk/texture.cpp b/src/vk/texture.cpp index 063eb86..50cfac5 100644 --- a/src/vk/texture.cpp +++ b/src/vk/texture.cpp @@ -274,11 +274,13 @@ load_text_proportions(void *obj) self->max_bearing_y = 0; self->chars_to_draw.reserve(unicode_text.size()); + + std::shared_ptr char_image{}; { // Calculate image size int max_height; for(auto char_code : unicode_text) { - auto char_image{self->font->character(char_code)}; + char_image = self->font->character(char_code); uint32_t descender{char_image->height - char_image->bearing_y}; uint32_t pos_x{texture_width + char_image->bearing_x}; @@ -293,6 +295,9 @@ load_text_proportions(void *obj) } } + // Restore image width if last character have a negative bearing. + if(char_image->bearing_x < 0) texture_width += -(char_image->bearing_x); + self->texture->width = texture_width; self->texture->height = self->max_bearing_y + texture_descender; self->texture->mip_levels = 1; -- cgit v1.2.3