Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move registration of fallbacks property in the base Font class #78266

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions doc/classes/Font.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@
Returns number of faces in the TrueType / OpenType collection.
</description>
</method>
<method name="get_fallbacks" qualifiers="const">
<return type="Font[]" />
<description>
Returns array of fallback [Font]s.
</description>
</method>
<method name="get_font_name" qualifiers="const">
<return type="String" />
<description>
Expand Down Expand Up @@ -335,12 +329,11 @@
Sets LRU cache capacity for [code]draw_*[/code] methods.
</description>
</method>
<method name="set_fallbacks">
<return type="void" />
<param index="0" name="fallbacks" type="Font[]" />
<description>
Sets array of fallback [Font]s.
</description>
</method>
</methods>
<members>
<member name="fallbacks" type="Font[]" setter="set_fallbacks" getter="get_fallbacks" default="[]">
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.
</member>
</members>
</class>
3 changes: 0 additions & 3 deletions doc/classes/FontFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,6 @@
<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contents of the dynamic font source file.
</member>
<member name="fallbacks" type="Font[]" setter="set_fallbacks" getter="get_fallbacks" default="[]">
Array of fallback [Font]s.
</member>
<member name="fixed_size" type="int" setter="set_fixed_size" getter="get_fixed_size" default="0">
Font size, used only for the bitmap fonts.
</member>
Expand Down
3 changes: 0 additions & 3 deletions doc/classes/FontVariation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<member name="base_font" type="Font" setter="set_base_font" getter="get_base_font">
Base font used to create a variation. If not set, default [Theme] font is used.
</member>
<member name="fallbacks" type="Font[]" setter="set_fallbacks" getter="get_fallbacks" default="[]">
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.
akien-mga marked this conversation as resolved.
Show resolved Hide resolved
</member>
<member name="opentype_features" type="Dictionary" setter="set_opentype_features" getter="get_opentype_features" default="{}">
A set of OpenType feature tags. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
</member>
Expand Down
3 changes: 0 additions & 3 deletions doc/classes/SystemFont.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<member name="antialiasing" type="int" setter="set_antialiasing" getter="get_antialiasing" enum="TextServer.FontAntialiasing" default="1">
Font anti-aliasing mode.
</member>
<member name="fallbacks" type="Font[]" setter="set_fallbacks" getter="get_fallbacks" default="[]">
Array of fallback [Font]s.
</member>
<member name="font_italic" type="bool" setter="set_font_italic" getter="get_font_italic" default="false">
If set to [code]true[/code], italic or oblique font is preferred.
</member>
Expand Down
11 changes: 8 additions & 3 deletions scene/resources/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Font> &p_f, int p_depth) const {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions scene/resources/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading