diff options
Diffstat (limited to 'src/vk')
-rw-r--r-- | src/vk/texture.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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<VK::Character> 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; |