diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/path_2d.cpp | 4 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 25 | ||||
-rw-r--r-- | scene/animation/tween.h | 5 | ||||
-rw-r--r-- | scene/gui/button.cpp | 8 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 6 | ||||
-rw-r--r-- | scene/gui/label.cpp | 6 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 6 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 2 | ||||
-rw-r--r-- | scene/gui/link_button.cpp | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 10 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 2 | ||||
-rw-r--r-- | scene/gui/texture_rect.cpp | 22 | ||||
-rw-r--r-- | scene/gui/texture_rect.h | 9 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 2 | ||||
-rw-r--r-- | scene/resources/font.cpp | 121 | ||||
-rw-r--r-- | scene/resources/font.h | 3 |
16 files changed, 92 insertions, 145 deletions
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 4f24b0e004..742756113f 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -93,6 +93,10 @@ void Path2D::_notification(int p_what) { return; } + if (curve->get_point_count() < 2) { + return; + } + #ifdef TOOLS_ENABLED const real_t line_width = 2 * EDSCALE; #else diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 2e6a123016..a37c6f5355 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -260,10 +260,8 @@ bool Tween::step(float p_delta) { } if (is_bound) { - Object *bound_instance = ObjectDB::get_instance(bound_node); - if (bound_instance) { - Node *bound_node = Object::cast_to<Node>(bound_instance); - // This can't by anything else than Node, so we can omit checking if casting succeeded. + Node *bound_node = get_bound_node(); + if (bound_node) { if (!bound_node->is_inside_tree()) { return true; } @@ -320,16 +318,23 @@ bool Tween::step(float p_delta) { return true; } -bool Tween::should_pause() { +bool Tween::can_process(bool p_tree_paused) const { if (is_bound && pause_mode == TWEEN_PAUSE_BOUND) { - Object *bound_instance = ObjectDB::get_instance(bound_node); - if (bound_instance) { - Node *bound_node = Object::cast_to<Node>(bound_instance); - return !bound_node->can_process(); + Node *bound_node = get_bound_node(); + if (bound_node) { + return bound_node->can_process(); } } - return pause_mode != TWEEN_PAUSE_PROCESS; + return !p_tree_paused || pause_mode == TWEEN_PAUSE_PROCESS; +} + +Node *Tween::get_bound_node() const { + if (is_bound) { + return Object::cast_to<Node>(ObjectDB::get_instance(bound_node)); + } else { + return nullptr; + } } real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t p_time, real_t p_initial, real_t p_delta, real_t p_duration) { diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 7ecdb64f0d..5b0745b2b3 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -97,7 +97,7 @@ public: private: TweenProcessMode process_mode = TweenProcessMode::TWEEN_PROCESS_IDLE; - TweenPauseMode pause_mode = TweenPauseMode::TWEEN_PAUSE_STOP; + TweenPauseMode pause_mode = TweenPauseMode::TWEEN_PAUSE_BOUND; TransitionType default_transition = TransitionType::TRANS_LINEAR; EaseType default_ease = EaseType::EASE_IN_OUT; ObjectID bound_node; @@ -164,7 +164,8 @@ public: Variant calculate_delta_value(Variant p_intial_val, Variant p_final_val); bool step(float p_delta); - bool should_pause(); + bool can_process(bool p_tree_paused) const; + Node *get_bound_node() const; Tween() {} }; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 25e931c287..046b9c18c7 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -302,6 +302,8 @@ void Button::_notification(int p_what) { Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0; + text_buf->set_alignment(align_rtl_checked); + text_buf->set_width(text_width); switch (align_rtl_checked) { case HORIZONTAL_ALIGNMENT_FILL: case HORIZONTAL_ALIGNMENT_LEFT: { @@ -497,7 +499,7 @@ bool Button::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -505,7 +507,7 @@ bool Button::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; _shape(); update(); @@ -537,7 +539,7 @@ bool Button::_get(const StringName &p_name, Variant &r_ret) const { void Button::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 1a270ff942..d6569e3de4 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -46,7 +46,7 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -54,7 +54,7 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; _shape(); update(); @@ -153,7 +153,7 @@ bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const { void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 54c4835ccf..edd206a1ca 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -811,7 +811,7 @@ bool Label::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -819,7 +819,7 @@ bool Label::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; dirty = true; update(); @@ -851,7 +851,7 @@ bool Label::_get(const StringName &p_name, Variant &r_ret) const { void Label::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f000f64caf..ec18101d2f 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -2164,7 +2164,7 @@ bool LineEdit::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -2172,7 +2172,7 @@ bool LineEdit::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; _shape(); update(); @@ -2204,7 +2204,7 @@ bool LineEdit::_get(const StringName &p_name, Variant &r_ret) const { void LineEdit::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 029ff07d13..0c313f71c2 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -97,7 +97,7 @@ private: PopupMenu *menu_dir = nullptr; PopupMenu *menu_ctl = nullptr; - bool caret_mid_grapheme_enabled = false; + bool caret_mid_grapheme_enabled = true; int caret_column = 0; int scroll_offset = 0; diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 1890e461e9..67ffa2c7ed 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -240,7 +240,7 @@ bool LinkButton::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -248,7 +248,7 @@ bool LinkButton::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; _shape(); update(); @@ -280,7 +280,7 @@ bool LinkButton::_get(const StringName &p_name, Variant &r_ret) const { void LinkButton::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 55f621fa96..8df77daafb 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1135,7 +1135,7 @@ void TextEdit::_notification(int p_what) { int first_visible_char = TS->shaped_text_get_range(rid).y; int last_visible_char = TS->shaped_text_get_range(rid).x; - int char_ofs = 0; + float char_ofs = 0; if (outline_size > 0 && outline_color.a > 0) { for (int j = 0; j < gl_size; j++) { for (int k = 0; k < glyphs[j].repeat; k++) { @@ -1170,7 +1170,7 @@ void TextEdit::_notification(int p_what) { } } - int char_pos = char_ofs + char_margin + ofs_x; + float char_pos = char_ofs + char_margin + ofs_x; if (char_pos >= xmargin_beg) { if (highlight_matching_braces_enabled) { if ((brace_open_match_line == line && brace_open_match_column == glyphs[j].start) || @@ -5228,7 +5228,7 @@ bool TextEdit::_set(const StringName &p_name, const Variant &p_value) { if (str.begins_with("opentype_features/")) { String name = str.get_slicec('/', 1); int32_t tag = TS->name_to_tag(name); - double value = p_value; + int value = p_value; if (value == -1) { if (opentype_features.has(tag)) { opentype_features.erase(tag); @@ -5237,7 +5237,7 @@ bool TextEdit::_set(const StringName &p_name, const Variant &p_value) { update(); } } else { - if ((double)opentype_features[tag] != value) { + if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) { opentype_features[tag] = value; text.set_font_features(opentype_features); text.invalidate_all(); @@ -5270,7 +5270,7 @@ bool TextEdit::_get(const StringName &p_name, Variant &r_ret) const { void TextEdit::_get_property_list(List<PropertyInfo> *p_list) const { for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) { String name = TS->tag_to_name(*ftr); - p_list->push_back(PropertyInfo(Variant::FLOAT, "opentype_features/" + name)); + p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name)); } p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index d51ac8dffc..57b48b5f52 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -374,7 +374,7 @@ private: bool move_caret_on_right_click = true; - bool caret_mid_grapheme_enabled = false; + bool caret_mid_grapheme_enabled = true; bool drag_action = false; bool drag_caret_force_displayed = false; diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index ebf5ce597e..a8cdeb44f5 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -44,9 +44,6 @@ void TextureRect::_notification(int p_what) { bool tile = false; switch (stretch_mode) { - case STRETCH_SCALE_ON_EXPAND: { - size = expand ? get_size() : texture->get_size(); - } break; case STRETCH_SCALE: { size = get_size(); } break; @@ -114,7 +111,7 @@ void TextureRect::_notification(int p_what) { } Size2 TextureRect::get_minimum_size() const { - if (!expand && !texture.is_null()) { + if (!ignore_texture_size && !texture.is_null()) { return texture->get_size(); } else { return Size2(); @@ -124,8 +121,8 @@ Size2 TextureRect::get_minimum_size() const { void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TextureRect::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &TextureRect::get_texture); - ClassDB::bind_method(D_METHOD("set_expand", "enable"), &TextureRect::set_expand); - ClassDB::bind_method(D_METHOD("has_expand"), &TextureRect::has_expand); + ClassDB::bind_method(D_METHOD("set_ignore_texture_size", "ignore"), &TextureRect::set_ignore_texture_size); + ClassDB::bind_method(D_METHOD("get_ignore_texture_size"), &TextureRect::get_ignore_texture_size); ClassDB::bind_method(D_METHOD("set_flip_h", "enable"), &TextureRect::set_flip_h); ClassDB::bind_method(D_METHOD("is_flipped_h"), &TextureRect::is_flipped_h); ClassDB::bind_method(D_METHOD("set_flip_v", "enable"), &TextureRect::set_flip_v); @@ -134,12 +131,11 @@ void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureRect::get_stretch_mode); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_texture_size"), "set_ignore_texture_size", "get_ignore_texture_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_v"), "set_flip_v", "is_flipped_v"); - BIND_ENUM_CONSTANT(STRETCH_SCALE_ON_EXPAND); BIND_ENUM_CONSTANT(STRETCH_SCALE); BIND_ENUM_CONSTANT(STRETCH_TILE); BIND_ENUM_CONSTANT(STRETCH_KEEP); @@ -179,14 +175,14 @@ Ref<Texture2D> TextureRect::get_texture() const { return texture; } -void TextureRect::set_expand(bool p_expand) { - expand = p_expand; +void TextureRect::set_ignore_texture_size(bool p_ignore) { + ignore_texture_size = p_ignore; update(); update_minimum_size(); } -bool TextureRect::has_expand() const { - return expand; +bool TextureRect::get_ignore_texture_size() const { + return ignore_texture_size; } void TextureRect::set_stretch_mode(StretchMode p_mode) { diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index ede5b7b480..7d667b25a8 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -38,7 +38,6 @@ class TextureRect : public Control { public: enum StretchMode { - STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility STRETCH_SCALE, STRETCH_TILE, STRETCH_KEEP, @@ -49,11 +48,11 @@ public: }; private: - bool expand = false; + bool ignore_texture_size = false; bool hflip = false; bool vflip = false; Ref<Texture2D> texture; - StretchMode stretch_mode = STRETCH_SCALE_ON_EXPAND; + StretchMode stretch_mode = STRETCH_SCALE; void _texture_changed(); @@ -66,8 +65,8 @@ public: void set_texture(const Ref<Texture2D> &p_tex); Ref<Texture2D> get_texture() const; - void set_expand(bool p_expand); - bool has_expand() const; + void set_ignore_texture_size(bool p_ignore); + bool get_ignore_texture_size() const; void set_stretch_mode(StretchMode p_mode); StretchMode get_stretch_mode() const; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 9e4908a23d..cafa4a43fd 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -535,7 +535,7 @@ void SceneTree::process_tweens(float p_delta, bool p_physics) { for (List<Ref<Tween>>::Element *E = tweens.front(); E;) { List<Ref<Tween>>::Element *N = E->next(); // Don't process if paused or process mode doesn't match. - if ((paused && E->get()->should_pause()) || (p_physics == (E->get()->get_process_mode() == Tween::TWEEN_PROCESS_IDLE))) { + if (!E->get()->can_process(paused) || (p_physics == (E->get()->get_process_mode() == Tween::TWEEN_PROCESS_IDLE))) { if (E == L) { break; } diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 9bd98237ff..d9e0c301de 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -184,6 +184,9 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_script_support_override", "script"), &FontData::remove_script_support_override); ClassDB::bind_method(D_METHOD("get_script_support_overrides"), &FontData::get_script_support_overrides); + ClassDB::bind_method(D_METHOD("set_opentype_feature_overrides", "overrides"), &FontData::set_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("get_opentype_feature_overrides"), &FontData::get_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("has_char", "char"), &FontData::has_char); ClassDB::bind_method(D_METHOD("get_supported_chars"), &FontData::get_supported_chars); @@ -191,49 +194,25 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_supported_feature_list"), &FontData::get_supported_feature_list); ClassDB::bind_method(D_METHOD("get_supported_variation_list"), &FontData::get_supported_variation_list); + + ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_data", "get_data"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_antialiased", "is_antialiased"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_name", "get_font_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style_name", "get_font_style_name"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style", "get_font_style"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_multichannel_signed_distance_field", "is_multichannel_signed_distance_field"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_msdf_pixel_range", "get_msdf_pixel_range"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_msdf_size", "get_msdf_size"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_autohinter", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_force_autohinter", "is_force_autohinter"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_STORAGE), "set_hinting", "get_hinting"); + 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"); } bool FontData::_set(const StringName &p_name, const Variant &p_value) { Vector<String> tokens = p_name.operator String().split("/"); - if (tokens.size() == 1) { - if (tokens[0] == "data") { - set_data(p_value); - return true; - } else if (tokens[0] == "antialiased") { - set_antialiased(p_value); - return true; - } else if (tokens[0] == "font_name") { - set_font_name(p_value); - return true; - } else if (tokens[0] == "style_name") { - set_font_style_name(p_value); - return true; - } else if (tokens[0] == "font_style") { - set_font_style(p_value); - return true; - } else if (tokens[0] == "multichannel_signed_distance_field") { - set_multichannel_signed_distance_field(p_value); - return true; - } else if (tokens[0] == "msdf_pixel_range") { - set_msdf_pixel_range(p_value); - return true; - } else if (tokens[0] == "msdf_size") { - set_msdf_size(p_value); - return true; - } else if (tokens[0] == "fixed_size") { - set_fixed_size(p_value); - return true; - } else if (tokens[0] == "hinting") { - set_hinting((TextServer::Hinting)p_value.operator int()); - return true; - } else if (tokens[0] == "force_autohinter") { - set_force_autohinter(p_value); - return true; - } else if (tokens[0] == "oversampling") { - set_oversampling(p_value); - return true; - } - } else if (tokens.size() == 2 && tokens[0] == "language_support_override") { + if (tokens.size() == 2 && tokens[0] == "language_support_override") { String lang = tokens[1]; set_language_support_override(lang, p_value); return true; @@ -309,45 +288,7 @@ bool FontData::_set(const StringName &p_name, const Variant &p_value) { bool FontData::_get(const StringName &p_name, Variant &r_ret) const { Vector<String> tokens = p_name.operator String().split("/"); - if (tokens.size() == 1) { - if (tokens[0] == "data") { - r_ret = get_data(); - return true; - } else if (tokens[0] == "antialiased") { - r_ret = is_antialiased(); - return true; - } else if (tokens[0] == "font_name") { - r_ret = get_font_name(); - return true; - } else if (tokens[0] == "style_name") { - r_ret = get_font_style_name(); - return true; - } else if (tokens[0] == "font_style") { - r_ret = get_font_style(); - return true; - } else if (tokens[0] == "multichannel_signed_distance_field") { - r_ret = is_multichannel_signed_distance_field(); - return true; - } else if (tokens[0] == "msdf_pixel_range") { - r_ret = get_msdf_pixel_range(); - return true; - } else if (tokens[0] == "msdf_size") { - r_ret = get_msdf_size(); - return true; - } else if (tokens[0] == "fixed_size") { - r_ret = get_fixed_size(); - return true; - } else if (tokens[0] == "hinting") { - r_ret = get_hinting(); - return true; - } else if (tokens[0] == "force_autohinter") { - r_ret = is_force_autohinter(); - return true; - } else if (tokens[0] == "oversampling") { - r_ret = get_oversampling(); - return true; - } - } else if (tokens.size() == 2 && tokens[0] == "language_support_override") { + if (tokens.size() == 2 && tokens[0] == "language_support_override") { String lang = tokens[1]; r_ret = get_language_support_override(lang); return true; @@ -422,20 +363,6 @@ bool FontData::_get(const StringName &p_name, Variant &r_ret) const { } void FontData::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - - p_list->push_back(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::INT, "fixed_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::BOOL, "force_autohinter", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - p_list->push_back(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); - Vector<String> lang_over = get_language_support_overrides(); for (int i = 0; i < lang_over.size(); i++) { p_list->push_back(PropertyInfo(Variant::BOOL, "language_support_override/" + lang_over[i], PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); @@ -1077,6 +1004,16 @@ Vector<String> FontData::get_script_support_overrides() const { return TS->font_get_script_support_overrides(cache[0]); } +void FontData::set_opentype_feature_overrides(const Dictionary &p_overrides) { + _ensure_rid(0); + TS->font_set_opentype_feature_overrides(cache[0], p_overrides); +} + +Dictionary FontData::get_opentype_feature_overrides() const { + _ensure_rid(0); + return TS->font_get_opentype_feature_overrides(cache[0]); +} + bool FontData::has_char(char32_t p_char) const { _ensure_rid(0); return TS->font_has_char(cache[0], p_char); diff --git a/scene/resources/font.h b/scene/resources/font.h index 9c3672bd69..1b4ecc73ce 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -198,6 +198,9 @@ public: virtual void remove_script_support_override(const String &p_script); virtual Vector<String> get_script_support_overrides() const; + virtual void set_opentype_feature_overrides(const Dictionary &p_overrides); + virtual Dictionary get_opentype_feature_overrides() const; + // Base font properties. virtual bool has_char(char32_t p_char) const; virtual String get_supported_chars() const; |