From e2581a8209c549fd3f88be671c9bcd6447ec1dac Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Tue, 9 Jan 2024 12:20:52 -0300 Subject: fixt Remove another bug when computing text size --- src/vk/texture.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/vk') diff --git a/src/vk/texture.cpp b/src/vk/texture.cpp index 50cfac5..a4cac40 100644 --- a/src/vk/texture.cpp +++ b/src/vk/texture.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Frederico de Oliveira Linhares + * Copyright 2022-2024 Frederico de Oliveira Linhares * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -275,6 +275,8 @@ load_text_proportions(void *obj) self->max_bearing_y = 0; self->chars_to_draw.reserve(unicode_text.size()); + // FIXME: I need to test several different fonts to find all bugs in this + // code. std::shared_ptr char_image{}; { // Calculate image size int max_height; @@ -295,8 +297,11 @@ 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); + { // Restore image width if last character have a negative bearing. + int bearing_x_pluss_width = char_image->bearing_x + char_image->width; + if(bearing_x_pluss_width > char_image->advance) + texture_width += bearing_x_pluss_width - char_image->advance; + } self->texture->width = texture_width; self->texture->height = self->max_bearing_y + texture_descender; -- cgit v1.2.3