diff options
57 files changed, 622 insertions, 380 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index c5540f926d..507a686cab 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -892,7 +892,8 @@ void Input::set_event_dispatch_function(EventDispatchFunc p_function) { void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) { _THREAD_SAFE_METHOD_; Joypad &joy = joy_names[p_device]; - //printf("got button %i, mapping is %i\n", p_button, joy.mapping); + ERR_FAIL_INDEX((int)p_button, (int)JoyButton::MAX); + if (joy.last_buttons[(size_t)p_button] == p_pressed) { return; } diff --git a/core/input/input_enums.h b/core/input/input_enums.h index aa55316ec8..0282de2176 100644 --- a/core/input/input_enums.h +++ b/core/input/input_enums.h @@ -83,7 +83,7 @@ enum class JoyButton { PADDLE4 = 19, TOUCHPAD = 20, SDL_MAX = 21, - MAX = 36, // Android supports up to 36 buttons. + MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons. }; enum class MIDIMessage { diff --git a/core/templates/set.h b/core/templates/set.h index 9107459884..cdc6e8447d 100644 --- a/core/templates/set.h +++ b/core/templates/set.h @@ -582,6 +582,9 @@ public: } Element *lower_bound(const T &p_value) const { + if (!_data._root) { + return nullptr; + } return _lower_bound(p_value); } diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 20a371c3d0..be7ac1164e 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2134,8 +2134,11 @@ <constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButton"> The number of SDL game controller buttons. </constant> - <constant name="JOY_BUTTON_MAX" value="36" enum="JoyButton"> - The maximum number of game controller buttons: Android supports up to 36 buttons. + <constant name="JOY_BUTTON_MAX" value="128" enum="JoyButton"> + The maximum number of game controller buttons supported by the engine. The actual limit may be lower on specific platforms: + - Android: Up to 36 buttons. + - Linux: Up to 80 buttons. + - Windows and macOS: Up to 128 buttons. </constant> <constant name="JOY_AXIS_INVALID" value="-1" enum="JoyAxis"> An invalid game controller axis. diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 7a2120379f..6f660c9a88 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -158,7 +158,7 @@ </member> <member name="detail_normal" type="Texture2D" setter="set_texture" getter="get_texture"> Texture that specifies the per-pixel normal of the detail overlay. - [b]Note:[/b] Godot expects the normal map to use X+, Y-, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. </member> <member name="detail_uv_layer" type="int" setter="set_detail_uv" getter="get_detail_uv" enum="BaseMaterial3D.DetailUV" default="0"> Specifies whether to use [code]UV[/code] or [code]UV2[/code] for the detail layer. See [enum DetailUV] for options. @@ -255,7 +255,7 @@ <member name="normal_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture used to specify the normal at a given pixel. The [code]normal_texture[/code] only uses the red and green channels; the blue and alpha channels are ignored. The normal read from [code]normal_texture[/code] is oriented around the surface normal provided by the [Mesh]. [b]Note:[/b] The mesh must have both normals and tangents defined in its vertex data. Otherwise, the normal map won't render correctly and will only appear to darken the whole surface. If creating geometry with [SurfaceTool], you can use [method SurfaceTool.generate_normals] and [method SurfaceTool.generate_tangents] to automatically generate normals and tangents respectively. - [b]Note:[/b] Godot expects the normal map to use X+, Y-, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. </member> <member name="orm_texture" type="Texture2D" setter="set_texture" getter="get_texture"> </member> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index a7b2434def..44845947b1 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -115,7 +115,7 @@ <argument index="4" name="outline" type="float" default="0.0" /> <argument index="5" name="pixel_range" type="float" default="4.0" /> <description> - Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [method FontData.set_multichannel_signed_distance_field] for more information and caveats about MSDF font rendering. + Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member FontData.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering. If [code]outline[/code] is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the [code]outline[/code] radius. Value of the [code]pixel_range[/code] should the same that was used during distance field texture generation. </description> diff --git a/doc/classes/FontData.xml b/doc/classes/FontData.xml index 0c8386784e..36976f7083 100644 --- a/doc/classes/FontData.xml +++ b/doc/classes/FontData.xml @@ -79,12 +79,6 @@ Returns text server font cache entry resource id. </description> </method> - <method name="get_data" qualifiers="const"> - <return type="PackedByteArray" /> - <description> - Returns contents of the dynamic font source file. - </description> - </method> <method name="get_descent" qualifiers="const"> <return type="float" /> <argument index="0" name="cache_index" type="int" /> @@ -93,30 +87,6 @@ Returns font descent (number of pixels below the baseline). </description> </method> - <method name="get_fixed_size" qualifiers="const"> - <return type="int" /> - <description> - Returns font fixed size. - </description> - </method> - <method name="get_font_name" qualifiers="const"> - <return type="String" /> - <description> - Returns font family name. - </description> - </method> - <method name="get_font_style" qualifiers="const"> - <return type="int" /> - <description> - Returns font style flags, see [enum TextServer.FontStyle]. - </description> - </method> - <method name="get_font_style_name" qualifiers="const"> - <return type="String" /> - <description> - Returns font style name. - </description> - </method> <method name="get_glyph_advance" qualifiers="const"> <return type="Vector2" /> <argument index="0" name="cache_index" type="int" /> @@ -180,12 +150,6 @@ Returns rectangle in the cache texture containing the glyph. </description> </method> - <method name="get_hinting" qualifiers="const"> - <return type="int" enum="TextServer.Hinting" /> - <description> - Returns the font hinting mode. Used by dynamic fonts only. - </description> - </method> <method name="get_kerning" qualifiers="const"> <return type="Vector2" /> <argument index="0" name="cache_index" type="int" /> @@ -216,24 +180,6 @@ Returns list of language support overrides. </description> </method> - <method name="get_msdf_pixel_range" qualifiers="const"> - <return type="int" /> - <description> - Returns the width of the range around the shape between the minimum and maximum representable signed distance. - </description> - </method> - <method name="get_msdf_size" qualifiers="const"> - <return type="int" /> - <description> - Returns source font size used to generate MSDF textures. - </description> - </method> - <method name="get_oversampling" qualifiers="const"> - <return type="float" /> - <description> - Returns font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only. - </description> - </method> <method name="get_scale" qualifiers="const"> <return type="float" /> <argument index="0" name="cache_index" type="int" /> @@ -346,18 +292,6 @@ Returns [code]true[/code] if a Unicode [code]char[/code] is available in the font. </description> </method> - <method name="is_antialiased" qualifiers="const"> - <return type="bool" /> - <description> - Returns [code]true[/code] if font 8-bit anitialiased glyph rendering is supported and enabled. - </description> - </method> - <method name="is_force_autohinter" qualifiers="const"> - <return type="bool" /> - <description> - Returns [code]true[/code] if auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only. - </description> - </method> <method name="is_language_supported" qualifiers="const"> <return type="bool" /> <argument index="0" name="language" type="String" /> @@ -365,12 +299,6 @@ Returns [code]true[/code], if font supports given language ([url=https://en.wikipedia.org/wiki/ISO_639-1]ISO 639[/url] code). </description> </method> - <method name="is_multichannel_signed_distance_field" qualifiers="const"> - <return type="bool" /> - <description> - Returns [code]true[/code] if glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. - </description> - </method> <method name="is_script_supported" qualifiers="const"> <return type="bool" /> <argument index="0" name="script" type="String" /> @@ -455,13 +383,6 @@ Renders the range of characters to the font cache texture. </description> </method> - <method name="set_antialiased"> - <return type="void" /> - <argument index="0" name="antialiased" type="bool" /> - <description> - If set to [code]true[/code], 8-bit antialiased glyph rendering is used, otherwise 1-bit rendering is used. Used by dynamic fonts only. - </description> - </method> <method name="set_ascent"> <return type="void" /> <argument index="0" name="cache_index" type="int" /> @@ -471,13 +392,6 @@ Sets the font ascent (number of pixels above the baseline). </description> </method> - <method name="set_data"> - <return type="void" /> - <argument index="0" name="data" type="PackedByteArray" /> - <description> - Sets font source data, e.g contents of the dynamic font source file. - </description> - </method> <method name="set_descent"> <return type="void" /> <argument index="0" name="cache_index" type="int" /> @@ -487,41 +401,6 @@ Sets the font descent (number of pixels below the baseline). </description> </method> - <method name="set_fixed_size"> - <return type="void" /> - <argument index="0" name="fixed_size" type="int" /> - <description> - Sets the fixed size for the font. - </description> - </method> - <method name="set_font_name"> - <return type="void" /> - <argument index="0" name="name" type="String" /> - <description> - Sets the font family name. - </description> - </method> - <method name="set_font_style"> - <return type="void" /> - <argument index="0" name="style" type="int" /> - <description> - Sets the font style flags, see [enum TextServer.FontStyle]. - </description> - </method> - <method name="set_font_style_name"> - <return type="void" /> - <argument index="0" name="name" type="String" /> - <description> - Sets the font style name. - </description> - </method> - <method name="set_force_autohinter"> - <return type="void" /> - <argument index="0" name="force_autohinter" type="bool" /> - <description> - If set to [code]true[/code] auto-hinting is preferred over font built-in hinting. - </description> - </method> <method name="set_glyph_advance"> <return type="void" /> <argument index="0" name="cache_index" type="int" /> @@ -573,13 +452,6 @@ Sets rectangle in the cache texture containing the glyph. </description> </method> - <method name="set_hinting"> - <return type="void" /> - <argument index="0" name="hinting" type="int" enum="TextServer.Hinting" /> - <description> - Sets font hinting mode. Used by dynamic fonts only. - </description> - </method> <method name="set_kerning"> <return type="void" /> <argument index="0" name="cache_index" type="int" /> @@ -598,35 +470,6 @@ Adds override for [method is_language_supported]. </description> </method> - <method name="set_msdf_pixel_range"> - <return type="void" /> - <argument index="0" name="msdf_pixel_range" type="int" /> - <description> - Sets the width of the range around the shape between the minimum and maximum representable signed distance. - </description> - </method> - <method name="set_msdf_size"> - <return type="void" /> - <argument index="0" name="msdf_size" type="int" /> - <description> - Sets source font size used to generate MSDF textures. - </description> - </method> - <method name="set_multichannel_signed_distance_field"> - <return type="void" /> - <argument index="0" name="msdf" type="bool" /> - <description> - If set to [code]true[/code], glyphs of all sizes are rendered using single multichannel signed distance field (MSDF) generated from the dynamic font vector data. MSDF rendering allows displaying the font at any scaling factor without blurriness, and without incurring a CPU cost when the font size changes (since the font no longer needs to be rasterized on the CPU). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes. - [b]Note:[/b] MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts. - </description> - </method> - <method name="set_oversampling"> - <return type="void" /> - <argument index="0" name="oversampling" type="float" /> - <description> - Sets font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only. - </description> - </method> <method name="set_scale"> <return type="void" /> <argument index="0" name="cache_index" type="int" /> @@ -701,4 +544,45 @@ </description> </method> </methods> + <members> + <member name="antialiased" type="bool" setter="set_antialiased" getter="is_antialiased" default="true"> + If set to [code]true[/code], font 8-bit anitialiased glyph rendering is supported and enabled. + </member> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()"> + Contents of the dynamic font source file. + </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> + <member name="font_name" type="String" setter="set_font_name" getter="get_font_name" default=""""> + Font family name. + </member> + <member name="font_style" type="int" setter="set_font_style" getter="get_font_style" default="0"> + Font style flags, see [enum TextServer.FontStyle]. + </member> + <member name="force_autohinter" type="bool" setter="set_force_autohinter" getter="is_force_autohinter" default="false"> + If set to [code]true[/code], auto-hinting is supported and preffered over font built-in hinting. Used by dynamic fonts only. + </member> + <member name="hinting" type="int" setter="set_hinting" getter="get_hinting" enum="TextServer.Hinting" default="1"> + Font hinting mode. Used by dynamic fonts only. + </member> + <member name="msdf_pixel_range" type="int" setter="set_msdf_pixel_range" getter="get_msdf_pixel_range" default="16"> + The width of the range around the shape between the minimum and maximum representable signed distance. + </member> + <member name="msdf_size" type="int" setter="set_msdf_size" getter="get_msdf_size" default="48"> + Source font size used to generate MSDF textures. + </member> + <member name="multichannel_signed_distance_field" type="bool" setter="set_multichannel_signed_distance_field" getter="is_multichannel_signed_distance_field" default="false"> + If set to [code]true[/code], glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. + </member> + <member name="opentype_feature_overrides" type="Dictionary" setter="set_opentype_feature_overrides" getter="get_opentype_feature_overrides" default="{}"> + Font OpenType feature set override. + </member> + <member name="oversampling" type="float" setter="set_oversampling" getter="get_oversampling" default="0.0"> + Font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only. + </member> + <member name="style_name" type="String" setter="set_font_style_name" getter="get_font_style_name" default=""""> + Font style name. + </member> + </members> </class> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index c3e3088d69..b376ab5cb0 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -174,7 +174,7 @@ <member name="caret_force_displayed" type="bool" setter="set_caret_force_displayed" getter="is_caret_force_displayed" default="false"> If [code]true[/code], the [LineEdit] will always show the caret, even if focus is lost. </member> - <member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="false"> + <member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="true"> Allow moving caret, selecting and removing the individual composite character components. [b]Note:[/b] [kbd]Backspace[/kbd] is always removing individual composite character components. </member> diff --git a/doc/classes/MeshInstance2D.xml b/doc/classes/MeshInstance2D.xml index 6873edb3ae..5d5471c570 100644 --- a/doc/classes/MeshInstance2D.xml +++ b/doc/classes/MeshInstance2D.xml @@ -15,7 +15,7 @@ </member> <member name="normal_map" type="Texture2D" setter="set_normal_map" getter="get_normal_map"> The normal map that will be used if using the default [CanvasItemMaterial]. - [b]Note:[/b] Godot expects the normal map to use X+, Y-, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> The [Texture2D] that will be used if using the default [CanvasItemMaterial]. Can be accessed as [code]TEXTURE[/code] in CanvasItem shader. diff --git a/doc/classes/MultiMeshInstance2D.xml b/doc/classes/MultiMeshInstance2D.xml index 328ddff0eb..be01d96b5d 100644 --- a/doc/classes/MultiMeshInstance2D.xml +++ b/doc/classes/MultiMeshInstance2D.xml @@ -15,7 +15,7 @@ </member> <member name="normal_map" type="Texture2D" setter="set_normal_map" getter="get_normal_map"> The normal map that will be used if using the default [CanvasItemMaterial]. - [b]Note:[/b] Godot expects the normal map to use X+, Y-, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> The [Texture2D] that will be used if using the default [CanvasItemMaterial]. Can be accessed as [code]TEXTURE[/code] in CanvasItem shader. diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 753492ad34..d714fbc0d5 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -15,6 +15,7 @@ Finally, when a node is freed with [method Object.free] or [method queue_free], it will also free all its children. [b]Groups:[/b] Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See [method add_to_group], [method is_in_group] and [method remove_from_group]. You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on [SceneTree]. [b]Networking with nodes:[/b] After connecting to a server (or making one, see [ENetMultiplayerPeer]), it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling [method rpc] with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call, Godot will use its [NodePath] (make sure node names are the same on all peers). Also, take a look at the high-level networking tutorial and corresponding demos. + [b]Note:[/b] The [code]script[/code] property is part of the [Object] class, not [Node]. It isn't exposed like most properties but does have a setter and getter ([code]set_script()[/code] and [code]get_script()[/code]). </description> <tutorials> <link title="Nodes and scenes">$DOCS_URL/getting_started/step_by_step/nodes_and_scenes.html</link> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index e796cb2298..f5f6ba8b6d 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -27,6 +27,7 @@ The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code]. Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification]. [b]Note:[/b] Unlike references to a [RefCounted], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [RefCounted] for data classes instead of [Object]. + [b]Note:[/b] The [code]script[/code] property is not exposed like most properties, but it does have a setter and getter ([code]set_script()[/code] and [code]get_script()[/code]). </description> <tutorials> <link title="When and how to avoid using nodes for everything">$DOCS_URL/tutorials/best_practices/node_alternatives.html</link> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 26ad20e85b..e120f79236 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -942,7 +942,7 @@ <member name="caret_blink_speed" type="float" setter="set_caret_blink_speed" getter="get_caret_blink_speed" default="0.65"> Duration (in seconds) of a caret's blinking cycle. </member> - <member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="false"> + <member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="true"> Allow moving caret, selecting and removing the individual composite character components. [b]Note:[/b] [kbd]Backspace[/kbd] is always removing individual composite character components. </member> diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 443716435a..64989eb98b 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -261,6 +261,13 @@ Returns font family name. </description> </method> + <method name="font_get_opentype_feature_overrides" qualifiers="const"> + <return type="Dictionary" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font OpenType feature set override. + </description> + </method> <method name="font_get_oversampling" qualifiers="const"> <return type="float" /> <argument index="0" name="font_rid" type="RID" /> @@ -663,6 +670,14 @@ Sets the font family name. </description> </method> + <method name="font_set_opentype_feature_overrides"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="overrides" type="Dictionary" /> + <description> + Sets font OpenType feature set override. + </description> + </method> <method name="font_set_oversampling"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml index fb4ac630ba..aa6c93456b 100644 --- a/doc/classes/TextServerExtension.xml +++ b/doc/classes/TextServerExtension.xml @@ -261,6 +261,13 @@ Returns font family name. </description> </method> + <method name="_font_get_opentype_feature_overrides" qualifiers="virtual const"> + <return type="Dictionary" /> + <argument index="0" name="font_rid" type="RID" /> + <description> + Returns font OpenType feature set override. + </description> + </method> <method name="_font_get_oversampling" qualifiers="virtual const"> <return type="float" /> <argument index="0" name="font_rid" type="RID" /> @@ -550,6 +557,7 @@ <argument index="0" name="font_rid" type="RID" /> <argument index="1" name="force_autohinter" type="bool" /> <description> + If set to [code]true[/code] auto-hinting is preffered over font built-in hinting. </description> </method> <method name="_font_set_global_oversampling" qualifiers="virtual"> @@ -670,6 +678,14 @@ Sets the font family name. </description> </method> + <method name="_font_set_opentype_feature_overrides" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="font_rid" type="RID" /> + <argument index="1" name="overrides" type="Dictionary" /> + <description> + Sets font OpenType feature set override. + </description> + </method> <method name="_font_set_oversampling" qualifiers="virtual"> <return type="void" /> <argument index="0" name="font_rid" type="RID" /> diff --git a/doc/classes/TextureRect.xml b/doc/classes/TextureRect.xml index a160eceb35..f0cbe09fb9 100644 --- a/doc/classes/TextureRect.xml +++ b/doc/classes/TextureRect.xml @@ -10,15 +10,15 @@ <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link> </tutorials> <members> - <member name="expand" type="bool" setter="set_expand" getter="has_expand" default="false"> - If [code]true[/code], the texture scales to fit its bounding rectangle. - </member> <member name="flip_h" type="bool" setter="set_flip_h" getter="is_flipped_h" default="false"> If [code]true[/code], texture is flipped horizontally. </member> <member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" default="false"> If [code]true[/code], texture is flipped vertically. </member> + <member name="ignore_texture_size" type="bool" setter="set_ignore_texture_size" getter="get_ignore_texture_size" default="false"> + If [code]true[/code], the size of the texture won't be considered for minimum size calculation, so the [TextureRect] can be shrunk down past the texture size. Useful for preventing [TextureRect]s from breaking GUI layout regardless of their texture size. + </member> <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="1" /> <member name="stretch_mode" type="int" setter="set_stretch_mode" getter="get_stretch_mode" enum="TextureRect.StretchMode" default="0"> Controls the texture's behavior when resizing the node's bounding rectangle. See [enum StretchMode]. @@ -28,28 +28,25 @@ </member> </members> <constants> - <constant name="STRETCH_SCALE_ON_EXPAND" value="0" enum="StretchMode"> - Scale to fit the node's bounding rectangle, only if [code]expand[/code] is [code]true[/code]. Default [code]stretch_mode[/code], for backwards compatibility. Until you set [code]expand[/code] to [code]true[/code], the texture will behave like [constant STRETCH_KEEP]. - </constant> - <constant name="STRETCH_SCALE" value="1" enum="StretchMode"> + <constant name="STRETCH_SCALE" value="0" enum="StretchMode"> Scale to fit the node's bounding rectangle. </constant> - <constant name="STRETCH_TILE" value="2" enum="StretchMode"> + <constant name="STRETCH_TILE" value="1" enum="StretchMode"> Tile inside the node's bounding rectangle. </constant> - <constant name="STRETCH_KEEP" value="3" enum="StretchMode"> + <constant name="STRETCH_KEEP" value="2" enum="StretchMode"> The texture keeps its original size and stays in the bounding rectangle's top-left corner. </constant> - <constant name="STRETCH_KEEP_CENTERED" value="4" enum="StretchMode"> + <constant name="STRETCH_KEEP_CENTERED" value="3" enum="StretchMode"> The texture keeps its original size and stays centered in the node's bounding rectangle. </constant> - <constant name="STRETCH_KEEP_ASPECT" value="5" enum="StretchMode"> + <constant name="STRETCH_KEEP_ASPECT" value="4" enum="StretchMode"> Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio. </constant> - <constant name="STRETCH_KEEP_ASPECT_CENTERED" value="6" enum="StretchMode"> + <constant name="STRETCH_KEEP_ASPECT_CENTERED" value="5" enum="StretchMode"> Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio. </constant> - <constant name="STRETCH_KEEP_ASPECT_COVERED" value="7" enum="StretchMode"> + <constant name="STRETCH_KEEP_ASPECT_COVERED" value="6" enum="StretchMode"> Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits. </constant> </constants> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 05c83f0423..1cba995366 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -303,46 +303,64 @@ </signals> <constants> <constant name="TWEEN_PROCESS_PHYSICS" value="0" enum="TweenProcessMode"> - The [Tween] updates during physics frame. + The [Tween] updates during the physics frame. </constant> <constant name="TWEEN_PROCESS_IDLE" value="1" enum="TweenProcessMode"> - The [Tween] updates during idle + The [Tween] updates during the idle frame. </constant> <constant name="TWEEN_PAUSE_BOUND" value="0" enum="TweenPauseMode"> + If the [Tween] has a bound node, it will process when that node can process (see [member Node.process_mode]). Otherwise it's the same as [constant TWEEN_PAUSE_STOP]. </constant> <constant name="TWEEN_PAUSE_STOP" value="1" enum="TweenPauseMode"> + If [SceneTree] is paused, the [Tween] will also pause. </constant> <constant name="TWEEN_PAUSE_PROCESS" value="2" enum="TweenPauseMode"> + The [Tween] will process regardless of whether [SceneTree] is paused. </constant> <constant name="TRANS_LINEAR" value="0" enum="TransitionType"> + The animation is interpolated linearly. </constant> <constant name="TRANS_SINE" value="1" enum="TransitionType"> + The animation is interpolated using a sine function. </constant> <constant name="TRANS_QUINT" value="2" enum="TransitionType"> + The animation is interpolated with a quintic (to the power of 5) function. </constant> <constant name="TRANS_QUART" value="3" enum="TransitionType"> + The animation is interpolated with a quartic (to the power of 4) function. </constant> <constant name="TRANS_QUAD" value="4" enum="TransitionType"> + The animation is interpolated with a quadratic (to the power of 2) function. </constant> <constant name="TRANS_EXPO" value="5" enum="TransitionType"> + The animation is interpolated with an exponential (to the power of x) function. </constant> <constant name="TRANS_ELASTIC" value="6" enum="TransitionType"> + The animation is interpolated with elasticity, wiggling around the edges. </constant> <constant name="TRANS_CUBIC" value="7" enum="TransitionType"> + The animation is interpolated with a cubic (to the power of 3) function. </constant> <constant name="TRANS_CIRC" value="8" enum="TransitionType"> + The animation is interpolated with a function using square roots. </constant> <constant name="TRANS_BOUNCE" value="9" enum="TransitionType"> + The animation is interpolated by bouncing at the end. </constant> <constant name="TRANS_BACK" value="10" enum="TransitionType"> + The animation is interpolated backing out at ends. </constant> <constant name="EASE_IN" value="0" enum="EaseType"> + The interpolation starts slowly and speeds up towards the end. </constant> <constant name="EASE_OUT" value="1" enum="EaseType"> + The interpolation starts quickly and slows down towards the end. </constant> <constant name="EASE_IN_OUT" value="2" enum="EaseType"> + A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is slowest at both ends. </constant> <constant name="EASE_OUT_IN" value="3" enum="EaseType"> + A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is fastest at both ends. </constant> </constants> </class> diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 8e9b2a9368..d5e825a26c 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -645,7 +645,7 @@ EditorProfiler::EditorProfiler() { variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited)); graph = memnew(TextureRect); - graph->set_expand(true); + graph->set_ignore_texture_size(true); graph->set_mouse_filter(MOUSE_FILTER_STOP); graph->connect("draw", callable_mp(this, &EditorProfiler::_graph_tex_draw)); graph->connect("gui_input", callable_mp(this, &EditorProfiler::_graph_tex_input)); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 42b52a3b38..3cb5d3513d 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -786,7 +786,7 @@ EditorVisualProfiler::EditorVisualProfiler() { variables->connect("cell_selected", callable_mp(this, &EditorVisualProfiler::_item_selected)); graph = memnew(TextureRect); - graph->set_expand(true); + graph->set_ignore_texture_size(true); graph->set_mouse_filter(MOUSE_FILTER_STOP); //graph->set_ignore_mouse(false); graph->connect("draw", callable_mp(this, &EditorVisualProfiler::_graph_tex_draw)); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index c649162d7e..6002bcfadc 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -874,7 +874,7 @@ EditorResourcePicker::EditorResourcePicker() { assign_button->connect("gui_input", callable_mp(this, &EditorResourcePicker::_button_input)); preview_rect = memnew(TextureRect); - preview_rect->set_expand(true); + preview_rect->set_ignore_texture_size(true); preview_rect->set_anchors_and_offsets_preset(PRESET_WIDE); preview_rect->set_offset(SIDE_TOP, 1); preview_rect->set_offset(SIDE_BOTTOM, -1); diff --git a/editor/import/dynamicfont_import_settings.cpp b/editor/import/dynamicfont_import_settings.cpp index c8d8cd8ee1..3151496bec 100644 --- a/editor/import/dynamicfont_import_settings.cpp +++ b/editor/import/dynamicfont_import_settings.cpp @@ -1185,6 +1185,38 @@ void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p memdelete(lang_item); } +void DynamicFontImportSettings::_ot_add() { + menu_ot->set_position(ot_list->get_screen_transform().xform(ot_list->get_local_mouse_position())); + menu_ot->set_size(Vector2(1, 1)); + menu_ot->popup(); +} + +void DynamicFontImportSettings::_ot_add_item(int p_option) { + String name = TS->tag_to_name(p_option); + for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { + if (ot_item->get_text(0) == name) { + return; + } + } + TreeItem *ot_item = ot_list->create_item(ot_list_root); + ERR_FAIL_NULL(ot_item); + + ot_item->set_text(0, name); + ot_item->set_editable(0, false); + ot_item->set_text(1, "1"); + ot_item->set_editable(1, true); + ot_item->add_button(2, ot_list->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_VAR, false, TTR("Remove")); + ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); +} + +void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id) { + TreeItem *ot_item = (TreeItem *)p_item; + ERR_FAIL_NULL(ot_item); + + ot_list_root->remove_child(ot_item); + memdelete(ot_item); +} + void DynamicFontImportSettings::_script_add() { menu_scripts->set_position(script_list->get_screen_position() + script_list->get_local_mouse_position()); menu_scripts->reset_size(); @@ -1230,6 +1262,7 @@ void DynamicFontImportSettings::_notification(int p_what) { add_lang->set_icon(add_var->get_theme_icon("Add", "EditorIcons")); add_script->set_icon(add_var->get_theme_icon("Add", "EditorIcons")); add_var->set_icon(add_var->get_theme_icon("Add", "EditorIcons")); + add_ot->set_icon(add_var->get_theme_icon("Add", "EditorIcons")); } } @@ -1317,6 +1350,14 @@ void DynamicFontImportSettings::_re_import() { main_settings["preload/glyph_ranges"] = ranges; } + Dictionary ot_ov; + for (TreeItem *ot_item = ot_list_root->get_first_child(); ot_item; ot_item = ot_item->get_next()) { + String tag = ot_item->get_text(0); + int32_t value = ot_item->get_text(1).to_int(); + ot_ov[tag] = value; + } + main_settings["opentype_feature_overrides"] = ot_ov; + if (OS::get_singleton()->is_stdout_verbose()) { print_line("Import settings:"); for (Map<StringName, Variant>::Element *E = main_settings.front(); E; E = E->next()) { @@ -1373,6 +1414,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { vars_list->clear(); lang_list->clear(); script_list->clear(); + ot_list->clear(); selected_chars.clear(); selected_glyphs.clear(); @@ -1381,6 +1423,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { vars_list_root = vars_list->create_item(); lang_list_root = lang_list->create_item(); script_list_root = script_list->create_item(); + ot_list_root = ot_list->create_item(); options_variations.clear(); Dictionary var_list = dfont_main->get_supported_variation_list(); @@ -1546,6 +1589,23 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { script_item->set_editable(1, true); script_item->add_button(2, lang_list->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_VAR, false, TTR("Remove")); } + } else if (key == "opentype_feature_overrides") { + Dictionary features = config->get_value("params", key); + for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { + TreeItem *ot_item = ot_list->create_item(ot_list_root); + ERR_FAIL_NULL(ot_item); + int32_t value = features[*ftr]; + if (ftr->get_type() == Variant::STRING) { + ot_item->set_text(0, *ftr); + } else { + ot_item->set_text(0, TS->tag_to_name(*ftr)); + } + ot_item->set_editable(0, false); + ot_item->set_text(1, itos(value)); + ot_item->set_editable(1, true); + ot_item->add_button(2, ot_list->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_VAR, false, TTR("Remove")); + ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); + } } else { Variant value = config->get_value("params", key); import_settings_data->defaults[key] = value; @@ -1570,6 +1630,39 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { font_preview_label->add_theme_font_override("font", font_preview); font_preview_label->update(); + menu_ot->clear(); + menu_ot_ss->clear(); + menu_ot_cv->clear(); + menu_ot_cu->clear(); + bool have_ss = false; + bool have_cv = false; + bool have_cu = false; + Dictionary features = font_preview->get_feature_list(); + for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { + String ftr_name = TS->tag_to_name(*ftr); + if (ftr_name.begins_with("stylistic_set_")) { + menu_ot_ss->add_item(ftr_name.capitalize(), (int32_t)*ftr); + have_ss = true; + } else if (ftr_name.begins_with("character_variant_")) { + menu_ot_cv->add_item(ftr_name.capitalize(), (int32_t)*ftr); + have_cv = true; + } else if (ftr_name.begins_with("custom_")) { + menu_ot_cu->add_item(ftr_name.replace("custom_", ""), (int32_t)*ftr); + have_cu = true; + } else { + menu_ot->add_item(ftr_name.capitalize(), (int32_t)*ftr); + } + } + if (have_ss) { + menu_ot->add_submenu_item(RTR("Stylistic Sets"), "SSMenu"); + } + if (have_cv) { + menu_ot->add_submenu_item(RTR("Character Variants"), "CVMenu"); + } + if (have_cu) { + menu_ot->add_submenu_item(RTR("Custom"), "CUMenu"); + } + _variations_validate(); popup_centered_ratio(); @@ -1619,6 +1712,25 @@ DynamicFontImportSettings::DynamicFontImportSettings() { add_child(menu_scripts); menu_scripts->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_script_add_item)); + menu_ot = memnew(PopupMenu); + add_child(menu_ot); + menu_ot->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_cv = memnew(PopupMenu); + menu_ot_cv->set_name("CVMenu"); + menu_ot->add_child(menu_ot_cv); + menu_ot_cv->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_ss = memnew(PopupMenu); + menu_ot_ss->set_name("SSMenu"); + menu_ot->add_child(menu_ot_ss); + menu_ot_ss->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + + menu_ot_cu = memnew(PopupMenu); + menu_ot_cu->set_name("CUMenu"); + menu_ot->add_child(menu_ot_cu); + menu_ot_cu->connect("id_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add_item)); + Color warn_color = (EditorNode::get_singleton()) ? EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor") : Color(1, 1, 0); // Root layout @@ -1897,6 +2009,34 @@ DynamicFontImportSettings::DynamicFontImportSettings() { script_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_script_remove)); script_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + HBoxContainer *hb_ot = memnew(HBoxContainer); + page5_vb->add_child(hb_ot); + + label_ot = memnew(Label); + label_ot->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); + label_ot->set_h_size_flags(Control::SIZE_EXPAND_FILL); + label_ot->set_text(TTR("OpenType feature overrides")); + hb_ot->add_child(label_ot); + + add_ot = memnew(Button); + hb_ot->add_child(add_ot); + add_ot->set_tooltip(TTR("Add feature override")); + add_ot->set_icon(add_var->get_theme_icon("Add", "EditorIcons")); + add_ot->connect("pressed", callable_mp(this, &DynamicFontImportSettings::_ot_add)); + + ot_list = memnew(Tree); + page5_vb->add_child(ot_list); + ot_list->set_hide_root(true); + ot_list->set_columns(3); + ot_list->set_column_expand(0, true); + ot_list->set_column_custom_minimum_width(0, 80 * EDSCALE); + ot_list->set_column_expand(1, true); + ot_list->set_column_custom_minimum_width(1, 80 * EDSCALE); + ot_list->set_column_expand(2, false); + ot_list->set_column_custom_minimum_width(2, 50 * EDSCALE); + ot_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_remove)); + ot_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + // Common import_settings_data.instantiate(); diff --git a/editor/import/dynamicfont_import_settings.h b/editor/import/dynamicfont_import_settings.h index be8cf7ad3d..89665ae476 100644 --- a/editor/import/dynamicfont_import_settings.h +++ b/editor/import/dynamicfont_import_settings.h @@ -120,18 +120,27 @@ class DynamicFontImportSettings : public ConfirmationDialog { Label *page5_description = nullptr; Button *add_lang = nullptr; Button *add_script = nullptr; + Button *add_ot = nullptr; PopupMenu *menu_langs = nullptr; PopupMenu *menu_scripts = nullptr; + PopupMenu *menu_ot = nullptr; + PopupMenu *menu_ot_ss = nullptr; + PopupMenu *menu_ot_cv = nullptr; + PopupMenu *menu_ot_cu = nullptr; Tree *lang_list = nullptr; TreeItem *lang_list_root = nullptr; + Label *label_langs = nullptr; Tree *script_list = nullptr; TreeItem *script_list_root = nullptr; - Label *label_langs = nullptr; Label *label_script = nullptr; + Tree *ot_list = nullptr; + TreeItem *ot_list_root = nullptr; + Label *label_ot = nullptr; + void _lang_add(); void _lang_add_item(int p_option); void _lang_remove(Object *p_item, int p_column, int p_id); @@ -140,6 +149,10 @@ class DynamicFontImportSettings : public ConfirmationDialog { void _script_add_item(int p_option); void _script_remove(Object *p_item, int p_column, int p_id); + void _ot_add(); + void _ot_add_item(int p_option); + void _ot_remove(Object *p_item, int p_column, int p_id); + // Common void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name); diff --git a/editor/import/resource_importer_dynamicfont.cpp b/editor/import/resource_importer_dynamicfont.cpp index 54e95f905e..11f563a982 100644 --- a/editor/import/resource_importer_dynamicfont.cpp +++ b/editor/import/resource_importer_dynamicfont.cpp @@ -107,6 +107,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List< r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "opentype_feature_overrides"), Dictionary())); r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/char_ranges"), Vector<String>())); r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "preload/glyph_ranges"), Vector<String>())); @@ -174,6 +175,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str bool msdf = p_options["multichannel_signed_distance_field"]; int px_range = p_options["msdf_pixel_range"]; int px_size = p_options["msdf_size"]; + Dictionary ot_ov = p_options["opentype_feature_overrides"]; bool autohinter = p_options["force_autohinter"]; int hinting = p_options["hinting"]; @@ -190,6 +192,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str font->set_multichannel_signed_distance_field(msdf); font->set_msdf_pixel_range(px_range); font->set_msdf_size(px_size); + font->set_opentype_feature_overrides(ot_ov); font->set_fixed_size(0); font->set_force_autohinter(autohinter); font->set_hinting((TextServer::Hinting)hinting); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 4b7ad7e325..49bef4acd5 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -288,7 +288,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { preview = memnew(TextureRect); previews_vbox->add_child(preview); - preview->set_expand(true); + preview->set_ignore_texture_size(true); preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); preview->set_custom_minimum_size(Size2(640 * EDSCALE, 345 * EDSCALE)); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 460eb994e5..2da4f80751 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1232,7 +1232,7 @@ SpriteFramesEditor::SpriteFramesEditor() { split_sheet_vb->add_child(split_sheet_panel); split_sheet_preview = memnew(TextureRect); - split_sheet_preview->set_expand(true); + split_sheet_preview->set_ignore_texture_size(true); split_sheet_preview->set_mouse_filter(MOUSE_FILTER_PASS); split_sheet_preview->connect("draw", callable_mp(this, &SpriteFramesEditor::_sheet_preview_draw)); split_sheet_preview->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_sheet_preview_input)); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index a07cc299f2..84b33f0986 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -84,7 +84,7 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { texture_display->set_texture(p_texture); texture_display->set_anchors_preset(TextureRect::PRESET_WIDE); texture_display->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); - texture_display->set_expand(true); + texture_display->set_ignore_texture_size(true); add_child(texture_display); if (p_show_metadata) { diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index bf30b595fe..fc4764f61e 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -301,7 +301,7 @@ AtlasMergingDialog::AtlasMergingDialog() { preview = memnew(TextureRect); preview->set_h_size_flags(Control::SIZE_EXPAND_FILL); preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); - preview->set_expand(true); + preview->set_ignore_texture_size(true); preview->hide(); preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); atlas_merging_right_panel->add_child(preview); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 2d6775d02e..9bd8c1e227 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -265,10 +265,25 @@ void ProjectExportDialog::_edit_preset(int p_index) { export_templates_error->hide(); } + export_warning->hide(); export_button->set_disabled(true); get_ok_button()->set_disabled(true); - } else { + if (error != String()) { + Vector<String> items = error.split("\n", false); + error = ""; + for (int i = 0; i < items.size(); i++) { + if (i > 0) { + error += "\n"; + } + error += " - " + items[i]; + } + export_warning->set_text(error); + export_warning->show(); + } else { + export_warning->hide(); + } + export_error->hide(); export_templates_error->hide(); export_button->set_disabled(false); @@ -1247,6 +1262,11 @@ ProjectExportDialog::ProjectExportDialog() { export_error->hide(); export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + export_warning = memnew(Label); + main_vb->add_child(export_warning); + export_warning->hide(); + export_warning->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + export_templates_error = memnew(HBoxContainer); main_vb->add_child(export_templates_error); export_templates_error->hide(); diff --git a/editor/project_export.h b/editor/project_export.h index 5dcda0a9b9..af7ec083c4 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -99,6 +99,7 @@ private: Label *script_key_error; Label *export_error; + Label *export_warning; HBoxContainer *export_templates_error; String default_filename; diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 71891c8704..f6e09067d2 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -343,6 +343,16 @@ void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); + Array csg_meshes = cs->get_meshes(); + if (csg_meshes.size() != 2) { + return; + } + + Ref<Mesh> csg_mesh = csg_meshes[1]; + if (csg_mesh.is_valid()) { + p_gizmo->add_collision_triangles(csg_mesh->generate_triangle_mesh()); + } + if (p_gizmo->is_selected()) { // Draw a translucent representation of the CSG node Ref<ArrayMesh> mesh = memnew(ArrayMesh); diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 2b29f4d97e..643a74f83e 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -1092,7 +1092,7 @@ HashMap<int, R> FBXMeshData::extract_per_vertex_data( const int vertex_index = get_vertex_from_polygon_vertex(p_mesh_indices, polygon_vertex_index); ERR_FAIL_COND_V_MSG(vertex_index < 0, (HashMap<int, R>()), "FBX file corrupted: #ERR05"); ERR_FAIL_COND_V_MSG(vertex_index >= p_vertex_count, (HashMap<int, R>()), "FBX file corrupted: #ERR06"); - const int index_to_direct = p_mapping_data.index[polygon_vertex_index]; + const int index_to_direct = get_vertex_from_polygon_vertex(p_mapping_data.index, polygon_vertex_index); T value = p_mapping_data.data[index_to_direct]; aggregate_vertex_data[vertex_index].push_back({ polygon_id, value }); } @@ -1297,7 +1297,7 @@ HashMap<int, T> FBXMeshData::extract_per_polygon( } else { ERR_FAIL_INDEX_V_MSG(polygon_index, (int)p_fbx_data.index.size(), (HashMap<int, T>()), "FBX file is corrupted: #ERR62"); - const int index_to_direct = p_fbx_data.index[polygon_index]; + const int index_to_direct = get_vertex_from_polygon_vertex(p_fbx_data.index, polygon_index); T value = p_fbx_data.data[index_to_direct]; aggregate_polygon_data[polygon_index].push_back(value); } diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index f1945f62cb..f9997a437f 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -2573,7 +2573,7 @@ int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, cha return FT_Get_Char_Index(fd->cache[size]->face, p_char); } } else { - return 0; + return (int32_t)p_char; } #else return (int32_t)p_char; @@ -2841,6 +2841,24 @@ Vector<String> TextServerAdvanced::font_get_script_support_overrides(RID p_font_ return out; } +void TextServerAdvanced::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->feature_overrides = p_overrides; +} + +Dictionary TextServerAdvanced::font_get_opentype_feature_overrides(RID p_font_rid) const { + FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, Dictionary()); + + MutexLock lock(fd->mutex); + return fd->feature_overrides; +} + Dictionary TextServerAdvanced::font_supported_feature_list(RID p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -3668,6 +3686,12 @@ float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat3 const_cast<TextServerAdvanced *>(this)->shaped_text_update_breaks(p_shaped); } + for (int i = 0; i < p_tab_stops.size(); i++) { + if (p_tab_stops[i] <= 0) { + return 0.f; + } + } + int tab_index = 0; float off = 0.f; @@ -4231,6 +4255,24 @@ Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char return gl; } +_FORCE_INLINE_ void TextServerAdvanced::_add_featuers(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs) { + for (const Variant *ftr = p_source.next(nullptr); ftr != nullptr; ftr = p_source.next(ftr)) { + int32_t values = p_source[*ftr]; + if (values >= 0) { + hb_feature_t feature; + if (ftr->get_type() == Variant::STRING) { + feature.tag = name_to_tag(*ftr); + } else { + feature.tag = *ftr; + } + feature.value = values; + feature.start = 0; + feature.end = -1; + r_ftrs.push_back(feature); + } + } +} + void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_start, int32_t p_end, hb_script_t p_script, hb_direction_t p_direction, Vector<RID> p_fonts, int p_span, int p_fb_index) { int fs = p_sd->spans[p_span].font_size; if (p_fb_index >= p_fonts.size()) { @@ -4287,17 +4329,9 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star hb_buffer_add_utf32(p_sd->hb_buffer, (const uint32_t *)p_sd->text.ptr(), p_sd->text.length(), p_start, p_end - p_start); Vector<hb_feature_t> ftrs; - for (const Variant *ftr = p_sd->spans[p_span].features.next(nullptr); ftr != nullptr; ftr = p_sd->spans[p_span].features.next(ftr)) { - double values = p_sd->spans[p_span].features[*ftr]; - if (values >= 0) { - hb_feature_t feature; - feature.tag = *ftr; - feature.value = values; - feature.start = 0; - feature.end = -1; - ftrs.push_back(feature); - } - } + _add_featuers(font_get_opentype_feature_overrides(f), ftrs); + _add_featuers(p_sd->spans[p_span].features, ftrs); + hb_shape(hb_font, p_sd->hb_buffer, ftrs.is_empty() ? nullptr : &ftrs[0], ftrs.size()); unsigned int glyph_count = 0; diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index fb9446da9f..6ff9817dcf 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -187,6 +187,7 @@ class TextServerAdvanced : public TextServer { Set<uint32_t> supported_scripts; Dictionary supported_features; Dictionary supported_varaitions; + Dictionary feature_overrides; // Language/script support override. Map<String, bool> language_support_overrides; @@ -272,6 +273,7 @@ class TextServerAdvanced : public TextServer { bool _shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int p_start, int p_length) const; void _shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_start, int32_t p_end, hb_script_t p_script, hb_direction_t p_direction, Vector<RID> p_fonts, int p_span, int p_fb_index); Glyph _shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, RID p_font, int p_font_size); + _FORCE_INLINE_ void _add_featuers(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs); // HarfBuzz bitmap font interface. @@ -447,6 +449,9 @@ public: virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) override; + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const override; + virtual Dictionary font_supported_feature_list(RID p_font_rid) const override; virtual Dictionary font_supported_variation_list(RID p_font_rid) const override; diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 1f7c5427be..f28d174c5c 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -1995,6 +1995,24 @@ Vector<String> TextServerFallback::font_get_script_support_overrides(RID p_font_ return out; } +void TextServerFallback::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND(!fd); + + MutexLock lock(fd->mutex); + Vector2i size = _get_size(fd, 16); + ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); + fd->feature_overrides = p_overrides; +} + +Dictionary TextServerFallback::font_get_opentype_feature_overrides(RID p_font_rid) const { + FontDataFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_COND_V(!fd, Dictionary()); + + MutexLock lock(fd->mutex); + return fd->feature_overrides; +} + Dictionary TextServerFallback::font_supported_feature_list(RID p_font_rid) const { return Dictionary(); } @@ -2665,6 +2683,12 @@ float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat3 const_cast<TextServerFallback *>(this)->shaped_text_update_breaks(p_shaped); } + for (int i = 0; i < p_tab_stops.size(); i++) { + if (p_tab_stops[i] <= 0) { + return 0.f; + } + } + int tab_index = 0; float off = 0.f; diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index d47fa44f8f..9d1be50b04 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -150,6 +150,7 @@ class TextServerFallback : public TextServer { bool face_init = false; Dictionary supported_varaitions; + Dictionary feature_overrides; // Language/script support override. Map<String, bool> language_support_overrides; @@ -357,6 +358,9 @@ public: virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) override; + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const override; + virtual Dictionary font_supported_feature_list(RID p_font_rid) const override; virtual Dictionary font_supported_variation_list(RID p_font_rid) const override; diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp index ab50144303..3a731f2172 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/osx/export/export_plugin.cpp @@ -381,12 +381,22 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese #ifdef OSX_ENABLED List<String> args; + bool ad_hoc = (p_preset->get("codesign/identity") == "" || p_preset->get("codesign/identity") == "-"); + if (p_preset->get("codesign/timestamp")) { - args.push_back("--timestamp"); + if (ad_hoc) { + WARN_PRINT("Timestamping is not compatible with ad-hoc signature, and was disabled!"); + } else { + args.push_back("--timestamp"); + } } if (p_preset->get("codesign/hardened_runtime")) { - args.push_back("--options"); - args.push_back("runtime"); + if (ad_hoc) { + WARN_PRINT("Hardened Runtime is not compatible with ad-hoc signature, and was disabled!"); + } else { + args.push_back("--options"); + args.push_back("runtime"); + } } if (p_path.get_extension() != "dmg") { @@ -403,7 +413,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese } args.push_back("-s"); - if (p_preset->get("codesign/identity") == "") { + if (ad_hoc) { args.push_back("-"); } else { args.push_back(p_preset->get("codesign/identity")); @@ -1166,10 +1176,9 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset String err; bool valid = false; - // Look for export templates (first official, and if defined custom templates). - - bool dvalid = exists_export_template("osx.zip", &err); - bool rvalid = dvalid; // Both in the same ZIP. + // Look for export templates (custom templates). + bool dvalid = false; + bool rvalid = false; if (p_preset->get("custom_template/debug") != "") { dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); @@ -1184,6 +1193,12 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset } } + // Look for export templates (official templates, check only is custom templates are not set). + if (!dvalid || !rvalid) { + dvalid = exists_export_template("osx.zip", &err); + rvalid = dvalid; // Both in the same ZIP. + } + valid = dvalid || rvalid; r_missing_templates = !valid; @@ -1194,16 +1209,26 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset valid = false; } +#ifdef OSX_ENABLED bool sign_enabled = p_preset->get("codesign/enable"); bool noto_enabled = p_preset->get("notarization/enable"); + bool ad_hoc = ((p_preset->get("codesign/identity") == "") || (p_preset->get("codesign/identity") == "-")); + if (noto_enabled) { + if (ad_hoc) { + err += TTR("Notarization: Notarization with the ad-hoc signature is not supported.") + "\n"; + valid = false; + } if (!sign_enabled) { - err += TTR("Notarization: code signing required.") + "\n"; + err += TTR("Notarization: Code signing is required for notarization.") + "\n"; + valid = false; + } + if (!(bool)p_preset->get("codesign/hardened_runtime")) { + err += TTR("Notarization: Hardened runtime is required for notarization.") + "\n"; valid = false; } - bool hr_enabled = p_preset->get("codesign/hardened_runtime"); - if (!hr_enabled) { - err += TTR("Notarization: hardened runtime required.") + "\n"; + if (!(bool)p_preset->get("codesign/timestamp")) { + err += TTR("Notarization: Timestamping is required for notarization.") + "\n"; valid = false; } if (p_preset->get("notarization/apple_id_name") == "") { @@ -1214,7 +1239,22 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset err += TTR("Notarization: Apple ID password not specified.") + "\n"; valid = false; } + } else { + err += TTR("Notarization is disabled. Exported project will be blocked by Gatekeeper, if it's downloaded from an unknown source.") + "\n"; + if (!sign_enabled) { + err += TTR("Code signing is disabled. Exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n"; + } else { + if ((bool)p_preset->get("codesign/hardened_runtime") && ad_hoc) { + err += TTR("Hardened Runtime is not compatible with ad-hoc signature, and will be disabled!") + "\n"; + } + if ((bool)p_preset->get("codesign/timestamp") && ad_hoc) { + err += TTR("Timestamping is not compatible with ad-hoc signature, and will be disabled!") + "\n"; + } + } } +#else + err += TTR("macOS code signing and Notarization is not supported on the host OS. Exported project will not run on Macs with enabled Gatekeeper and Apple Silicon powered Macs.") + "\n"; +#endif if (!err.is_empty()) { r_error = err; 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 817a4453a8..2d4ee01c84 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; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 5d420ba48d..adbcdedacc 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7596,8 +7596,16 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct #ifdef DEBUG_ENABLED int uniform_buffer_size = 0; int max_uniform_buffer_size = 0; - if (RenderingDevice::get_singleton()) { - max_uniform_buffer_size = RenderingDevice::get_singleton()->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE); + int uniform_buffer_exceeded_line = -1; + + bool check_device_limit_warnings = false; + { + RenderingDevice *device = RenderingDevice::get_singleton(); + if (device != nullptr) { + check_device_limit_warnings = check_warnings && HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED_FLAG); + + max_uniform_buffer_size = device->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE); + } } #endif // DEBUG_ENABLED ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL; @@ -8001,15 +8009,21 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) { uniform2.order = uniforms++; #ifdef DEBUG_ENABLED - if (uniform2.array_size > 0) { - int size = get_datatype_size(uniform2.type) * uniform2.array_size; - int m = (16 * uniform2.array_size); - if ((size % m) != 0U) { - size += m - (size % m); + if (check_device_limit_warnings) { + if (uniform2.array_size > 0) { + int size = get_datatype_size(uniform2.type) * uniform2.array_size; + int m = (16 * uniform2.array_size); + if ((size % m) != 0U) { + size += m - (size % m); + } + uniform_buffer_size += size; + } else { + uniform_buffer_size += get_datatype_size(uniform2.type); + } + + if (uniform_buffer_exceeded_line == -1 && uniform_buffer_size > max_uniform_buffer_size) { + uniform_buffer_exceeded_line = tk_line; } - uniform_buffer_size += size; - } else { - uniform_buffer_size += get_datatype_size(uniform2.type); } #endif // DEBUG_ENABLED } @@ -9022,11 +9036,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } #ifdef DEBUG_ENABLED - if (HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED) && (uniform_buffer_size > max_uniform_buffer_size)) { - Vector<Variant> args; - args.push_back(uniform_buffer_size); - args.push_back(max_uniform_buffer_size); - _add_global_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, "uniform buffer", args); + if (check_device_limit_warnings && uniform_buffer_exceeded_line != -1) { + _add_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, uniform_buffer_exceeded_line, "uniform buffer", { uniform_buffer_size, max_uniform_buffer_size }); } #endif // DEBUG_ENABLED return OK; diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index 2b0510680e..a51b62e730 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -174,6 +174,9 @@ void TextServerExtension::_bind_methods() { GDVIRTUAL_BIND(_font_remove_script_support_override, "font_rid", "script"); GDVIRTUAL_BIND(_font_get_script_support_overrides, "font_rid"); + GDVIRTUAL_BIND(_font_set_opentype_feature_overrides, "font_rid", "overrides"); + GDVIRTUAL_BIND(_font_get_opentype_feature_overrides, "font_rid"); + GDVIRTUAL_BIND(_font_supported_feature_list, "font_rid"); GDVIRTUAL_BIND(_font_supported_variation_list, "font_rid"); @@ -869,6 +872,18 @@ Vector<String> TextServerExtension::font_get_script_support_overrides(RID p_font return Vector<String>(); } +void TextServerExtension::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { + GDVIRTUAL_CALL(_font_set_opentype_feature_overrides, p_font_rid, p_overrides); +} + +Dictionary TextServerExtension::font_get_opentype_feature_overrides(RID p_font_rid) const { + Dictionary ret; + if (GDVIRTUAL_CALL(_font_get_opentype_feature_overrides, p_font_rid, ret)) { + return ret; + } + return Dictionary(); +} + Dictionary TextServerExtension::font_supported_feature_list(RID p_font_rid) const { Dictionary ret; if (GDVIRTUAL_CALL(_font_supported_feature_list, p_font_rid, ret)) { diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 5c97401118..9b456c2dd7 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -285,6 +285,11 @@ public: GDVIRTUAL2(_font_remove_script_support_override, RID, const String &); GDVIRTUAL1R(Vector<String>, _font_get_script_support_overrides, RID); + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const override; + GDVIRTUAL2(_font_set_opentype_feature_overrides, RID, const Dictionary &); + GDVIRTUAL1RC(Dictionary, _font_get_opentype_feature_overrides, RID); + virtual Dictionary font_supported_feature_list(RID p_font_rid) const override; virtual Dictionary font_supported_variation_list(RID p_font_rid) const override; GDVIRTUAL1RC(Dictionary, _font_supported_feature_list, RID); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index d547bcc75e..143cda985d 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -327,6 +327,9 @@ void TextServer::_bind_methods() { ClassDB::bind_method(D_METHOD("font_remove_script_support_override", "font_rid", "script"), &TextServer::font_remove_script_support_override); ClassDB::bind_method(D_METHOD("font_get_script_support_overrides", "font_rid"), &TextServer::font_get_script_support_overrides); + ClassDB::bind_method(D_METHOD("font_set_opentype_feature_overrides", "font_rid", "overrides"), &TextServer::font_set_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("font_get_opentype_feature_overrides", "font_rid"), &TextServer::font_get_opentype_feature_overrides); + ClassDB::bind_method(D_METHOD("font_supported_feature_list", "font_rid"), &TextServer::font_supported_feature_list); ClassDB::bind_method(D_METHOD("font_supported_variation_list", "font_rid"), &TextServer::font_supported_variation_list); @@ -989,9 +992,9 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start, } real_t char_adv = advance / (real_t)(glyphs[i].end - glyphs[i].start); if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { - ranges.push_back(Vector2(off, off + char_adv * (start - glyphs[i].start))); + ranges.push_back(Vector2(off, off + char_adv * (glyphs[i].end - start))); } else { - ranges.push_back(Vector2(off + char_adv * (glyphs[i].end - start), off + advance)); + ranges.push_back(Vector2(off + char_adv * (start - glyphs[i].start), off + advance)); } } // Selection range is within grapheme. @@ -1099,6 +1102,31 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons return glyphs[i].start; } } + // Ligature, handle mid-grapheme hit. + if (p_coords >= off && p_coords < off + advance && glyphs[i].end > glyphs[i].start + 1) { + int cnt = glyphs[i].end - glyphs[i].start; + real_t char_adv = advance / (real_t)(cnt); + real_t sub_off = off; + for (int j = 0; j < cnt; j++) { + // Place caret to the left of clicked sub-grapheme. + if (p_coords >= sub_off && p_coords < sub_off + char_adv / 2) { + if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { + return glyphs[i].end - j; + } else { + return glyphs[i].start + j; + } + } + // Place caret to the right of clicked sub-grapheme. + if (p_coords >= sub_off + char_adv / 2 && p_coords < sub_off + char_adv) { + if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { + return glyphs[i].start + (cnt - 1) - j; + } else { + return glyphs[i].end - (cnt - 1) + j; + } + } + sub_off += char_adv; + } + } // Place caret to the left of clicked grapheme. if (p_coords >= off && p_coords < off + advance / 2) { if ((glyphs[i].flags & GRAPHEME_IS_RTL) == GRAPHEME_IS_RTL) { diff --git a/servers/text_server.h b/servers/text_server.h index e9c5248866..d5dccc0edb 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -350,6 +350,9 @@ public: virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) = 0; virtual Vector<String> font_get_script_support_overrides(RID p_font_rid) = 0; + virtual void font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) = 0; + virtual Dictionary font_get_opentype_feature_overrides(RID p_font_rid) const = 0; + virtual Dictionary font_supported_feature_list(RID p_font_rid) const = 0; virtual Dictionary font_supported_variation_list(RID p_font_rid) const = 0; |