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.
This commit is contained in:
Ruslan Mustakov 2018-03-19 20:48:43 +07:00
parent 5cd12f6649
commit 863dd9aa46
4 changed files with 10 additions and 13 deletions

View File

@ -93,7 +93,7 @@ void Label::_notification(int p_what) {
bool use_outline = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
int line_spacing = get_constant("line_spacing");
Color font_outline_modulator = get_color("font_outline_modulator");
Color font_outline_modulate = get_color("font_outline_modulate");
style->draw(ci, Rect2(Point2(0, 0), get_size()));
@ -151,7 +151,7 @@ void Label::_notification(int p_what) {
int line = 0;
int line_to = lines_skipped + (lines_visible > 0 ? lines_visible : 1);
FontDrawer drawer(font, font_outline_modulator);
FontDrawer drawer(font, font_outline_modulate);
while (wc) {
/* handle lines not meant to be drawn quickly */
if (line >= line_to)

View File

@ -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);

View File

@ -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();

View File

@ -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();