summaryrefslogtreecommitdiff
path: root/src/vk
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2024-01-09 12:20:52 -0300
committerFrederico Linhares <fred@linhares.blue>2024-01-09 12:20:52 -0300
commite2581a8209c549fd3f88be671c9bcd6447ec1dac (patch)
tree69fa9b5054b85eebc238634204a47c3b1280c7bd /src/vk
parent66afe52032c85763ac3cc0ab03166879a2adb3ea (diff)
fixt Remove another bug when computing text size
Diffstat (limited to 'src/vk')
-rw-r--r--src/vk/texture.cpp11
1 files changed, 8 insertions, 3 deletions
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<VK::Character> 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;