summaryrefslogtreecommitdiff
path: root/scene/resources/dynamic_font.cpp
diff options
context:
space:
mode:
authorRuslan Mustakov <r.mustakov@gmail.com>2018-03-19 20:48:43 +0700
committerRuslan Mustakov <r.mustakov@gmail.com>2018-05-08 19:01:15 +0700
commit863dd9aa46aff502f7425ea6045de93bf09b76a3 (patch)
tree2019d31d5035683896d7b0436e3dd6f51b095c8e /scene/resources/dynamic_font.cpp
parent5cd12f6649387f91d08fd17bf3c70e732798ab58 (diff)
Always emit dynamic font change in update_oversampling
Fixes #15787. The issue occurred when two (or more) separate DynamicFont instances used the same DynamicFontAtSize instance due to having equal properties. The first instance updated its data_at_size and emitted "changed" signal, but the second did not because it considered the data_at_size to be up to date, even though it has just been updated.
Diffstat (limited to 'scene/resources/dynamic_font.cpp')
-rw-r--r--scene/resources/dynamic_font.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 0f8db44596..f41a26a680 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -444,7 +444,7 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
ret.x = 0;
ret.y = 0;
- int texsize = MAX(id.size * 8, 256);
+ int texsize = MAX(id.size * oversampling * 8, 256);
if (mw > texsize)
texsize = mw; //special case, adapt to it?
if (mh > texsize)
@@ -644,11 +644,9 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
char_map[p_char] = character;
}
-bool DynamicFontAtSize::update_oversampling() {
- if (oversampling == font_oversampling)
- return false;
- if (!valid)
- return false;
+void DynamicFontAtSize::update_oversampling() {
+ if (oversampling == font_oversampling || !valid)
+ return;
FT_Done_FreeType(library);
textures.clear();
@@ -656,8 +654,6 @@ bool DynamicFontAtSize::update_oversampling() {
oversampling = font_oversampling;
valid = false;
_load();
-
- return true;
}
DynamicFontAtSize::DynamicFontAtSize() {
@@ -1082,7 +1078,8 @@ void DynamicFont::update_oversampling() {
SelfList<DynamicFont> *E = dynamic_fonts.first();
while (E) {
- if (E->self()->data_at_size.is_valid() && E->self()->data_at_size->update_oversampling()) {
+ if (E->self()->data_at_size.is_valid()) {
+ E->self()->data_at_size->update_oversampling();
changed.push_back(Ref<DynamicFont>(E->self()));
}
E = E->next();