summaryrefslogtreecommitdiff
path: root/src/vk
diff options
context:
space:
mode:
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;