From b3b791350b541b811760453d6a5667ee8c4d8814 Mon Sep 17 00:00:00 2001 From: Faolan <46481567+Faolan-Rad@users.noreply.github.com> Date: Thu, 15 Jun 2023 10:56:22 -0400 Subject: [PATCH] Move registration of `fallbacks` property in the base Font class --- doc/classes/Font.xml | 19 ++++++------------- doc/classes/FontFile.xml | 3 --- doc/classes/FontVariation.xml | 3 --- doc/classes/SystemFont.xml | 3 --- scene/resources/font.cpp | 11 ++++++++--- scene/resources/font.h | 1 + 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index 461e96def47..e87712825d2 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -149,12 +149,6 @@ Returns number of faces in the TrueType / OpenType collection. - - - - Returns array of fallback [Font]s. - - @@ -335,12 +329,11 @@ Sets LRU cache capacity for [code]draw_*[/code] methods. - - - - - Sets array of fallback [Font]s. - - + + + Array of fallback [Font]s to use as a substitute if a glyph is not found in this current [Font]. + If this array is empty in a [FontVariation], the [member FontVariation.base_font]'s fallbacks are used instead. + + diff --git a/doc/classes/FontFile.xml b/doc/classes/FontFile.xml index ba4761e900f..86d1cb552a7 100644 --- a/doc/classes/FontFile.xml +++ b/doc/classes/FontFile.xml @@ -568,9 +568,6 @@ Contents of the dynamic font source file. - - Array of fallback [Font]s. - Font size, used only for the bitmap fonts. diff --git a/doc/classes/FontVariation.xml b/doc/classes/FontVariation.xml index eb72b4020c3..f02fda31b96 100644 --- a/doc/classes/FontVariation.xml +++ b/doc/classes/FontVariation.xml @@ -46,9 +46,6 @@ Base font used to create a variation. If not set, default [Theme] font is used. - - Array of fallback [Font]s to use as a substitute if a glyph is not found in this [FontVariation]. If not set, [member base_font]'s fallbacks are used instead. - A set of OpenType feature tags. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. diff --git a/doc/classes/SystemFont.xml b/doc/classes/SystemFont.xml index ea3dd0acd22..239bcc257cc 100644 --- a/doc/classes/SystemFont.xml +++ b/doc/classes/SystemFont.xml @@ -19,9 +19,6 @@ Font anti-aliasing mode. - - Array of fallback [Font]s. - If set to [code]true[/code], italic or oblique font is preferred. diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 09a835db1bd..df0bd8bc2e8 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -97,6 +97,8 @@ void Font::_bind_methods() { ClassDB::bind_method(D_METHOD("get_supported_feature_list"), &Font::get_supported_feature_list); ClassDB::bind_method(D_METHOD("get_supported_variation_list"), &Font::get_supported_variation_list); ClassDB::bind_method(D_METHOD("get_face_count"), &Font::get_face_count); + + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font")), "set_fallbacks", "get_fallbacks"); } void Font::_update_rids_fb(const Ref &p_f, int p_depth) const { @@ -1006,7 +1008,12 @@ void FontFile::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_oversampling", "get_oversampling"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_fixed_size", "get_fixed_size"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "opentype_feature_overrides", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_opentype_feature_overrides", "get_opentype_feature_overrides"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font"), PROPERTY_USAGE_STORAGE), "set_fallbacks", "get_fallbacks"); +} + +void FontFile::_validate_property(PropertyInfo &p_property) const { + if (p_property.name == "fallbacks") { + p_property.usage &= ~PROPERTY_USAGE_EDITOR; + } } bool FontFile::_set(const StringName &p_name, const Variant &p_value) { @@ -2634,7 +2641,6 @@ void FontVariation::_bind_methods() { ClassDB::bind_method(D_METHOD("set_spacing", "spacing", "value"), &FontVariation::set_spacing); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_base_font", "get_base_font"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font")), "set_fallbacks", "get_fallbacks"); ADD_GROUP("Variation", "variation_"); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "variation_opentype"), "set_variation_opentype", "get_variation_opentype"); @@ -2924,7 +2930,6 @@ void SystemFont::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range"), "set_msdf_pixel_range", "get_msdf_pixel_range"); ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_size"), "set_msdf_size", "get_msdf_size"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), "set_oversampling", "get_oversampling"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "fallbacks", PROPERTY_HINT_ARRAY_TYPE, MAKE_RESOURCE_TYPE_HINT("Font")), "set_fallbacks", "get_fallbacks"); } void SystemFont::_update_rids() const { diff --git a/scene/resources/font.h b/scene/resources/font.h index 5d600451a17..d8374c4447c 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -210,6 +210,7 @@ class FontFile : public Font { protected: static void _bind_methods(); + void _validate_property(PropertyInfo &p_property) const; bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const;