|
@@ -149,6 +149,25 @@ bool Font::_is_cyclic(const Ref<Font> &p_f, int p_depth) const {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+bool Font::_is_base_cyclic(const Ref<Font> &p_f, int p_depth) const {
|
|
|
+ ERR_FAIL_COND_V(p_depth > MAX_FALLBACK_DEPTH, true);
|
|
|
+ if (p_f.is_null()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (p_f == this) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ Ref<FontVariation> fv = p_f;
|
|
|
+ if (fv.is_valid()) {
|
|
|
+ return _is_base_cyclic(fv->get_base_font(), p_depth + 1);
|
|
|
+ }
|
|
|
+ Ref<SystemFont> fs = p_f;
|
|
|
+ if (fs.is_valid()) {
|
|
|
+ return _is_base_cyclic(fs->get_base_font(), p_depth + 1);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
void Font::reset_state() {
|
|
|
_invalidate_rids();
|
|
|
}
|
|
@@ -2910,7 +2929,7 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
|
|
|
}
|
|
|
|
|
|
Ref<Font> f = theme->get_font(theme_name, E);
|
|
|
- if (f == this) {
|
|
|
+ if (_is_base_cyclic(f, 0)) {
|
|
|
continue;
|
|
|
}
|
|
|
if (f.is_valid()) {
|
|
@@ -2922,7 +2941,7 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
|
|
|
}
|
|
|
|
|
|
Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName());
|
|
|
- if (f != this) {
|
|
|
+ if (!_is_base_cyclic(f, 0)) {
|
|
|
if (f.is_valid()) {
|
|
|
theme_font = f;
|
|
|
theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
|
|
@@ -3273,7 +3292,7 @@ Ref<Font> SystemFont::_get_base_font_or_default() const {
|
|
|
}
|
|
|
|
|
|
Ref<Font> f = theme->get_font(theme_name, E);
|
|
|
- if (f == this) {
|
|
|
+ if (_is_base_cyclic(f, 0)) {
|
|
|
continue;
|
|
|
}
|
|
|
if (f.is_valid()) {
|
|
@@ -3285,7 +3304,7 @@ Ref<Font> SystemFont::_get_base_font_or_default() const {
|
|
|
}
|
|
|
|
|
|
Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName());
|
|
|
- if (f != this) {
|
|
|
+ if (!_is_base_cyclic(f, 0)) {
|
|
|
if (f.is_valid()) {
|
|
|
theme_font = f;
|
|
|
theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED);
|