You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 19:31:35 +00:00
Merge pull request #105259 from bruvzg/rtl_track_custom_font_changes
[RTL] Track external changes in the custom fonts set by BBCode / `push_*`.
This commit is contained in:
@@ -4253,6 +4253,8 @@ void RichTextLabel::push_dropcap(const String &p_string, const Ref<Font> &p_font
|
||||
item->ol_size = p_ol_size;
|
||||
item->ol_color = p_ol_color;
|
||||
item->dropcap_margins = p_dropcap_margins;
|
||||
p_font->connect_changed(callable_mp(this, &RichTextLabel::_invalidate_fonts), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
_add_item(item, false);
|
||||
}
|
||||
|
||||
@@ -4269,6 +4271,8 @@ void RichTextLabel::_push_def_font_var(DefaultFont p_def_font, const Ref<Font> &
|
||||
item->font = p_font;
|
||||
item->font_size = p_size;
|
||||
item->def_size = (p_size <= 0);
|
||||
p_font->connect_changed(callable_mp(this, &RichTextLabel::_invalidate_fonts), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
_add_item(item, true);
|
||||
}
|
||||
|
||||
@@ -4296,9 +4300,19 @@ void RichTextLabel::push_font(const Ref<Font> &p_font, int p_size) {
|
||||
item->rid = items.make_rid(item);
|
||||
item->font = p_font;
|
||||
item->font_size = p_size;
|
||||
p_font->connect_changed(callable_mp(this, &RichTextLabel::_invalidate_fonts), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
_add_item(item, true);
|
||||
}
|
||||
|
||||
void RichTextLabel::_invalidate_fonts() {
|
||||
_stop_thread();
|
||||
main->first_invalid_font_line.store(0); // Invalidate all lines.
|
||||
_invalidate_accessibility();
|
||||
queue_accessibility_update();
|
||||
queue_redraw();
|
||||
}
|
||||
|
||||
void RichTextLabel::push_normal() {
|
||||
ERR_FAIL_COND(theme_cache.normal_font.is_null());
|
||||
|
||||
|
||||
@@ -252,6 +252,14 @@ private:
|
||||
Color ol_color;
|
||||
Rect2 dropcap_margins;
|
||||
ItemDropcap() { type = ITEM_DROPCAP; }
|
||||
~ItemDropcap() {
|
||||
if (font.is_valid()) {
|
||||
RichTextLabel *owner_rtl = ObjectDB::get_instance<RichTextLabel>(owner);
|
||||
if (owner_rtl) {
|
||||
font->disconnect_changed(callable_mp(owner_rtl, &RichTextLabel::_invalidate_fonts));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ItemImage : public Item {
|
||||
@@ -284,6 +292,14 @@ private:
|
||||
bool def_size = false;
|
||||
int font_size = 0;
|
||||
ItemFont() { type = ITEM_FONT; }
|
||||
~ItemFont() {
|
||||
if (font.is_valid()) {
|
||||
RichTextLabel *owner_rtl = ObjectDB::get_instance<RichTextLabel>(owner);
|
||||
if (owner_rtl) {
|
||||
font->disconnect_changed(callable_mp(owner_rtl, &RichTextLabel::_invalidate_fonts));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ItemFontSize : public Item {
|
||||
@@ -658,6 +674,8 @@ private:
|
||||
Ref<RichTextEffect> _get_custom_effect_by_code(String p_bbcode_identifier);
|
||||
virtual Dictionary parse_expressions_for_values(Vector<String> p_expressions);
|
||||
|
||||
void _invalidate_fonts();
|
||||
|
||||
Size2 _get_image_size(const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Rect2 &p_region = Rect2());
|
||||
|
||||
String _get_prefix(Item *p_item, const Vector<int> &p_list_index, const Vector<ItemList *> &p_list_items);
|
||||
|
||||
Reference in New Issue
Block a user