aboutsummaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRuslan Mustakov2018-03-19 20:48:43 +0700
committerRuslan Mustakov2018-05-08 19:01:15 +0700
commit863dd9aa46aff502f7425ea6045de93bf09b76a3 (patch)
tree2019d31d5035683896d7b0436e3dd6f51b095c8e /scene/resources
parent5cd12f6649387f91d08fd17bf3c70e732798ab58 (diff)
downloadgodot-863dd9aa46aff502f7425ea6045de93bf09b76a3.tar.gz
godot-863dd9aa46aff502f7425ea6045de93bf09b76a3.tar.zst
godot-863dd9aa46aff502f7425ea6045de93bf09b76a3.zip
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')
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
-rw-r--r--scene/resources/dynamic_font.cpp15
-rw-r--r--scene/resources/dynamic_font.h2
3 files changed, 8 insertions, 11 deletions
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 5b9ebbd4e..5ac9344f3 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -415,7 +415,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_color", "Label", Color(1, 1, 1));
theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
- theme->set_color("font_outline_modulator", "Label", Color(1, 1, 1));
+ theme->set_color("font_outline_modulate", "Label", Color(1, 1, 1));
theme->set_constant("shadow_offset_x", "Label", 1 * scale);
theme->set_constant("shadow_offset_y", "Label", 1 * scale);
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 0f8db4459..f41a26a68 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();
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index f024465cc..f460bca2d 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -192,7 +192,7 @@ public:
float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only = false) const;
void set_texture_flags(uint32_t p_flags);
- bool update_oversampling();
+ void update_oversampling();
DynamicFontAtSize();
~DynamicFontAtSize();