[RTL] Track external changes in the custom fonts set by BBCode / push_*.

This commit is contained in:
Pāvels Nadtočajevs 2025-04-10 20:30:48 +03:00
parent 06c71fbf40
commit 1ddd503213
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
2 changed files with 32 additions and 0 deletions

View file

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