From f19cd44346a68a649cabfe85cc3ba7a44ceb0ca4 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sun, 13 Feb 2022 14:41:29 +0200 Subject: [PATCH] Unify TextServer built-in module and GDExtension code. --- SConstruct | 2 +- core/io/image.cpp | 4 +- core/io/image.h | 16 +- core/string/ustring.cpp | 6 + core/string/ustring.h | 1 + core/variant/variant_call.cpp | 2 + core/variant/variant_op.cpp | 1 + doc/classes/Font.xml | 6 + doc/classes/String.xml | 24 + doc/classes/TextServer.xml | 53 +- doc/classes/TextServerDummy.xml | 9 + doc/classes/TextServerExtension.xml | 450 +++--- editor/debugger/script_editor_debugger.cpp | 2 +- editor/editor_spin_slider.cpp | 2 +- .../import/dynamic_font_import_settings.cpp | 2 +- main/main.cpp | 37 +- modules/text_server_adv/.gitignore | 2 + modules/text_server_adv/SCsub | 1 + .../doc_classes/TextServerAdvanced.xml | 2 +- .../gdextension_build/SConstruct | 638 ++++++++ .../gdextension_build/methods.py | 130 ++ .../text_server_adv.gdextension | 12 + modules/text_server_adv/register_types.cpp | 28 +- modules/text_server_adv/script_iterator.h | 17 +- modules/text_server_adv/text_server_adv.cpp | 1297 +++++++++-------- modules/text_server_adv/text_server_adv.h | 468 +++--- modules/text_server_fb/.gitignore | 2 + .../doc_classes/TextServerFallback.xml | 2 +- .../gdextension_build/SConstruct | 205 +++ .../gdextension_build/methods.py | 130 ++ .../text_server_fb.gdextension | 12 + modules/text_server_fb/register_types.cpp | 28 +- modules/text_server_fb/text_server_fb.cpp | 763 +++++----- modules/text_server_fb/text_server_fb.h | 429 +++--- scene/gui/label.cpp | 6 +- scene/gui/line_edit.cpp | 2 +- scene/resources/font.cpp | 14 +- scene/resources/font.h | 2 +- scene/resources/text_line.cpp | 2 +- scene/resources/text_paragraph.cpp | 12 +- servers/register_server_types.cpp | 2 + servers/text/text_server_dummy.h | 48 + servers/text/text_server_extension.cpp | 1156 +++++++-------- servers/text/text_server_extension.h | 671 ++++----- servers/text_server.cpp | 52 +- servers/text_server.h | 442 +++--- tests/core/object/test_class_db.h | 4 - tests/scene/test_code_edit.h | 522 +++---- tests/servers/test_text_server.h | 66 +- 49 files changed, 4658 insertions(+), 3126 deletions(-) create mode 100644 doc/classes/TextServerDummy.xml create mode 100644 modules/text_server_adv/.gitignore create mode 100644 modules/text_server_adv/gdextension_build/SConstruct create mode 100644 modules/text_server_adv/gdextension_build/methods.py create mode 100644 modules/text_server_adv/gdextension_build/text_server_adv.gdextension create mode 100644 modules/text_server_fb/.gitignore create mode 100644 modules/text_server_fb/gdextension_build/SConstruct create mode 100644 modules/text_server_fb/gdextension_build/methods.py create mode 100644 modules/text_server_fb/gdextension_build/text_server_fb.gdextension create mode 100644 servers/text/text_server_dummy.h diff --git a/SConstruct b/SConstruct index aa31c39d32e..a8475358125 100644 --- a/SConstruct +++ b/SConstruct @@ -741,7 +741,7 @@ if selected_platform in platform_list: if env["minizip"]: env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) - editor_module_list = ["freetype"] + editor_module_list = [] if env["tools"] and not env.module_check_dependencies("tools", editor_module_list): print( "Build option 'module_" diff --git a/core/io/image.cpp b/core/io/image.cpp index 766c84bdbe4..5376b78a894 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -3112,8 +3112,8 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_mipmaps", "renormalize"), &Image::generate_mipmaps, DEFVAL(false)); ClassDB::bind_method(D_METHOD("clear_mipmaps"), &Image::clear_mipmaps); - ClassDB::bind_method(D_METHOD("create", "width", "height", "use_mipmaps", "format"), &Image::_create_empty); - ClassDB::bind_method(D_METHOD("create_from_data", "width", "height", "use_mipmaps", "format", "data"), &Image::_create_from_data); + ClassDB::bind_method(D_METHOD("create", "width", "height", "use_mipmaps", "format"), &Image::create_empty); + ClassDB::bind_method(D_METHOD("create_from_data", "width", "height", "use_mipmaps", "format", "data"), &Image::create_from_data); ClassDB::bind_method(D_METHOD("is_empty"), &Image::is_empty); diff --git a/core/io/image.h b/core/io/image.h index 53bfa0881f7..39c700565b6 100644 --- a/core/io/image.h +++ b/core/io/image.h @@ -155,14 +155,6 @@ protected: static void _bind_methods(); private: - void _create_empty(int p_width, int p_height, bool p_use_mipmaps, Format p_format) { - create(p_width, p_height, p_use_mipmaps, p_format); - } - - void _create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector &p_data) { - create(p_width, p_height, p_use_mipmaps, p_format, p_data); - } - Format format = FORMAT_L8; Vector data; int width = 0; @@ -289,6 +281,14 @@ public: Vector save_png_to_buffer() const; Error save_exr(const String &p_path, bool p_grayscale) const; + void create_empty(int p_width, int p_height, bool p_use_mipmaps, Format p_format) { + create(p_width, p_height, p_use_mipmaps, p_format); + } + + void create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector &p_data) { + create(p_width, p_height, p_use_mipmaps, p_format, p_data); + } + /** * create an empty image */ diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 759c121f295..7cfd34b53ed 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -463,6 +463,12 @@ String String::operator+(const String &p_str) const { return res; } +String String::operator+(char32_t p_char) const { + String res = *this; + res += p_char; + return res; +} + String operator+(const char *p_chr, const String &p_str) { String tmp = p_chr; tmp += p_str; diff --git a/core/string/ustring.h b/core/string/ustring.h index 1d302b65a72..5e7904d8270 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -225,6 +225,7 @@ public: bool operator==(const String &p_str) const; bool operator!=(const String &p_str) const; String operator+(const String &p_str) const; + String operator+(char32_t p_char) const; String &operator+=(const String &); String &operator+=(char32_t p_char); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index bc29be77fc3..bcae5aad320 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1467,6 +1467,8 @@ static void _register_variant_builtin_methods() { bind_static_method(String, num_scientific, sarray("number"), varray()); bind_static_method(String, num, sarray("number", "decimals"), varray(-1)); + bind_static_method(String, num_int64, sarray("number", "base", "capitalize_hex"), varray(10, false)); + bind_static_method(String, num_uint64, sarray("number", "base", "capitalize_hex"), varray(10, false)); bind_static_method(String, chr, sarray("char"), varray()); bind_static_method(String, humanize_size, sarray("size"), varray()); diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index cd1ae9f41ff..35e0319aa3a 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -177,6 +177,7 @@ void Variant::_register_variant_operators() { register_op>(Variant::OP_ADD, Variant::FLOAT, Variant::FLOAT); register_op>(Variant::OP_ADD, Variant::STRING, Variant::STRING); register_op>(Variant::OP_ADD, Variant::INT, Variant::STRING); + register_op>(Variant::OP_ADD, Variant::STRING, Variant::INT); register_op>(Variant::OP_ADD, Variant::VECTOR2, Variant::VECTOR2); register_op>(Variant::OP_ADD, Variant::VECTOR2I, Variant::VECTOR2I); register_op>(Variant::OP_ADD, Variant::VECTOR3, Variant::VECTOR3); diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index 4ba15d7afcc..f357cb05b55 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -191,6 +191,12 @@ See also [method draw_multiline_string]. + + + + Returns [Array] of valid [FontData] [RID]s, which can be passsed to the [TextServer] methods. + + diff --git a/doc/classes/String.xml b/doc/classes/String.xml index ea0bd2adb1e..9a6155c8a81 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -514,12 +514,30 @@ [/codeblock] + + + + + + + Converts a signed [int] to a string representation of a number. + + + + + + + + + Converts a unsigned [int] to a string representation of a number. + + @@ -887,6 +905,12 @@ + + + + + + diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 020c30b9cdf..b4339bef11f 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -57,7 +57,7 @@ - Removes all font sizes from the cache entry + Removes all font sizes from the cache entry. @@ -509,7 +509,7 @@ - Renders specified glyph the the font cache texture. + Renders specified glyph to the font cache texture. @@ -1112,7 +1112,7 @@ - Returns text glyphs in the visual order. + Returns an array of glyphs in the visual order. @@ -1177,7 +1177,7 @@ - Sets text orientation. + Returns the parent buffer from which the substring originates. @@ -1222,7 +1222,7 @@ - Returns position of the trim. + Returns the position of the overrun trim. @@ -1420,6 +1420,7 @@ Strips diacritics from the string. + [b]Note:[/b] The result may be longer or shorter than the original. @@ -1544,8 +1545,8 @@ Glyph horizontal position is rounded based on font size. - - To one quarter of the pixel size if font size is smaller or equal to [code]16[/code]. - - To one half of the pixel size if font size is smaller or equal to [code]20[/code]. + - To one quarter of the pixel size if font size is smaller or equal to [constant SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE]. + - To one half of the pixel size if font size is smaller or equal to [constant SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE]. - To the whole pixel size for larger fonts. @@ -1554,31 +1555,49 @@ Glyph horizontal position is rounded to one quarter of the pixel size, each glyph is rasterized up to four times. - - TextServer supports bidirectional layouts. + + Maximum font size which will use one half of the pixel subpixel positioning in [constants SUBPIXEL_POSITIONING_AUTO] mode. - + + Maximum font size which will use one quarter of the pixel subpixel positioning in [constants SUBPIXEL_POSITIONING_AUTO] mode. + + + TextServer supports simple text layouts. + + + TextServer supports bidirectional text layouts. + + TextServer supports vertical layouts. - + TextServer supports complex text shaping. - + TextServer supports justification using kashidas. - + TextServer supports complex line/word breaking rules (e.g. dictionary based). - + + TextServer supports loading bitmap fonts. + + + TextServer supports loading dynamic (TrueType, OpeType, etc.) fonts. + + + TextServer supports multichannel signed distance field dynamic font rendering. + + TextServer supports loading system fonts. - + TextServer supports variable fonts. - + TextServer supports locale dependent and context sensitive case conversion. - + TextServer require external data file for some features. diff --git a/doc/classes/TextServerDummy.xml b/doc/classes/TextServerDummy.xml new file mode 100644 index 00000000000..b872e93fd61 --- /dev/null +++ b/doc/classes/TextServerDummy.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/doc/classes/TextServerExtension.xml b/doc/classes/TextServerExtension.xml index 5ffd80bf630..25647e2668e 100644 --- a/doc/classes/TextServerExtension.xml +++ b/doc/classes/TextServerExtension.xml @@ -9,23 +9,21 @@ - + - Creates new, empty font cache entry resource. To free the resulting resourec, use [method _free] method. + Creates new, empty font cache entry resource. To free the resulting resourec, use [method free_rid] method. - + - Creates new buffer for complex text layout, with the given [code]direction[/code] and [code]orientation[/code]. To free the resulting buffer, use [method _free] method. - [b]Note:[/b] Direction is ignored if server does not support [code]FEATURE_BIDI_LAYOUT[/code] feature. - [b]Note:[/b] Orientation is ignored if server does not support [code]FEATURE_VERTICAL_LAYOUT[/code] feature. + Creates new buffer for complex text layout, with the given [code]direction[/code] and [code]orientation[/code]. To free the resulting buffer, use [method free_rid] method. - + @@ -34,18 +32,18 @@ Draws box displaying character hexadecimal code. Used for replacing missing characters. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Removes all rendered glyphs information from the cache entry. - [b]Note:[/b] This function will not remove textures associated with the glyphs, use [method _font_remove_texture] to remove them manually. - + @@ -53,23 +51,22 @@ Removes all kerning overrides. - + - Removes all font sizes from the cache entry + Removes all font sizes from the cache entry. - + Removes all textures from font cache entry. - [b]Note:[/b] This function will not remove glyphs associated with the texture, use [method _font_remove_glyph] to remove them manually. - + @@ -79,10 +76,9 @@ Draws single glyph into a canvas item at the position, using [code]font_rid[/code] at the size [code]size[/code]. - [b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method _shaped_text_get_glyphs] or [method _font_get_glyph_index]. - + @@ -93,10 +89,9 @@ Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font_rid[/code] at the size [code]size[/code]. - [b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method _shaped_text_get_glyphs] or [method _font_get_glyph_index]. - + @@ -104,7 +99,7 @@ Returns the font ascent (number of pixels above the baseline). - + @@ -112,37 +107,36 @@ Returns the font descent (number of pixels below the baseline). - + Returns font embolden strength. - + Returns bitmap font fixed size. - + Returns the font oversampling factor, shared by all fonts in the TextServer. - + Returns glyph advance (offset of the next glyph). - [b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved. - + @@ -154,7 +148,7 @@ [code]orientation[/code] - [bool], contour orientation. If [code]true[/code], clockwise contours must be filled. - + @@ -164,7 +158,7 @@ Returns the glyph index of a [code]char[/code], optionally modified by the [code]variation_selector[/code]. - + @@ -172,7 +166,7 @@ Returns list of rendered glyphs in the cache entry. - + @@ -181,7 +175,7 @@ Returns glyph offset from the baseline. - + @@ -190,7 +184,7 @@ Returns size of the glyph. - + @@ -199,7 +193,7 @@ Returns index of the cache texture containing the glyph. - + @@ -208,14 +202,14 @@ Returns rectangle in the cache texture containing the glyph. - + Returns the font hinting mode. Used by dynamic fonts only. - + @@ -224,7 +218,7 @@ Returns kerning for the pair of glyphs. - + @@ -232,7 +226,7 @@ Returns list of the kerning overrides. - + @@ -240,49 +234,49 @@ Returns [code]true[/code] if support override is enabled for the [code]language[/code]. - + Returns list of language support overrides. - + - Return the width of the range around the shape between the minimum and maximum representable signed distance. + Returns the width of the range around the shape between the minimum and maximum representable signed distance. - + Returns source font size used to generate MSDF textures. - + Returns font family name. - + Returns font OpenType feature set override. - + Returns font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only. - + @@ -290,7 +284,7 @@ Returns scaling factor of the color bitmap font. - + @@ -298,21 +292,21 @@ Returns [code]true[/code] if support override is enabled for the [code]script[/code]. - + Returns list of script support overrides. - + - Return list of the font sizes in the cache. Each size is [code]Vector2i[/code] with font size and outline size. + Returns list of the font sizes in the cache. Each size is [code]Vector2i[/code] with font size and outline size. - + @@ -321,35 +315,35 @@ Returns extra spacing added between glyphs in pixels. - + Returns font style flags, see [enum TextServer.FontStyle]. - + Returns font style name. - + Returns font sub-pixel glyph positioning mode. - + Returns a string containing all the characters available in the font. - + @@ -357,7 +351,7 @@ Returns number of textures used by font cache entry. - + @@ -366,7 +360,7 @@ Returns font cache texture image data. - + @@ -375,14 +369,14 @@ Returns array containing the first free pixel in the each column of texture. Should be the same size as texture width or empty. - + Retruns 2D transform applied to the font outlines. - + @@ -390,7 +384,7 @@ Returns pixel offset of the underline below the baseline. - + @@ -398,36 +392,36 @@ Returns thickness of the underline in pixels. - + - Returns variation coordinates for the specified font cache entry. See [method _font_supported_variation_list] for more info. + Returns variation coordinates for the specified font cache entry. See [method font_supported_variation_list] for more info. - + - Return [code]true[/code] if a Unicode [code]char[/code] is available in the font. + Returns [code]true[/code] if a Unicode [code]char[/code] is available in the font. - + Returns [code]true[/code] if font 8-bit anitialiased glyph rendering is supported and enabled. - + Returns [code]true[/code] if auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only. - + @@ -435,14 +429,14 @@ Returns [code]true[/code], if font supports given language ([url=https://en.wikipedia.org/wiki/ISO_639-1]ISO 639[/url] code). - + Returns [code]true[/code] if glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. - + @@ -450,17 +444,16 @@ Returns [code]true[/code], if font supports given script (ISO 15924 code). - + Removes specified rendered glyph information from the cache entry. - [b]Note:[/b] This function will not remove textures associated with the glyphs, use [method _font_remove_texture] to remove them manually. - + @@ -469,7 +462,7 @@ Removes kerning override for the pair of glyphs. - + @@ -477,7 +470,7 @@ Remove language support override. - + @@ -485,7 +478,7 @@ Removes script support override. - + @@ -493,26 +486,25 @@ Removes specified font size from the cache entry. - + Removes specified texture from font cache entry. - [b]Note:[/b] This function will not remove glyphs associated with the texture, remove them manually, using [method _font_remove_glyph]. - + - Renders specified glyph the the font cache texture. + Renders specified glyph to the font cache texture. - + @@ -522,7 +514,7 @@ Renders the range of characters to the font cache texture. - + @@ -530,7 +522,7 @@ If set to [code]true[/code], 8-bit antialiased glyph rendering is used, otherwise 1-bit rendering is used. Used by dynamic fonts only. - + @@ -539,7 +531,7 @@ Sets the font ascent (number of pixels above the baseline). - + @@ -547,25 +539,25 @@ Sets font source data, e.g contents of the dynamic font source file. - + - Sets the font descent (number of pixels below the baseline). + Sets font source data, e.g contents of the dynamic font source file. [code]data_ptr[/code] memory buffer must remain accessible during font lifetime. - + - Sets bitmap font fixed size. If set to value greater than zero, same cache entry will be used for all font sizes. + Sets the font descent (number of pixels below the baseline). - + @@ -573,15 +565,15 @@ Sets font embolden strength. If [code]strength[/code] is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness. - + - If set to [code]true[/code] auto-hinting is preferred over font built-in hinting. + Sets bitmap font fixed size. If set to value greater than zero, same cache entry will be used for all font sizes. - + @@ -589,7 +581,7 @@ If set to [code]true[/code] auto-hinting is preferred over font built-in hinting. - + @@ -597,7 +589,7 @@ [b]Note:[/b] This value can be automatically changed by display server. - + @@ -605,10 +597,9 @@ Sets glyph advance (offset of the next glyph). - [b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved. - + @@ -618,7 +609,7 @@ Sets glyph offset from the baseline. - + @@ -628,7 +619,7 @@ Sets size of the glyph. - + @@ -638,7 +629,7 @@ Sets index of the cache texture containing the glyph. - + @@ -648,7 +639,7 @@ Sets rectangle in the cache texture containing the glyph. - + @@ -656,7 +647,7 @@ Sets font hinting mode. Used by dynamic fonts only. - + @@ -666,16 +657,16 @@ Sets kerning for the pair of glyphs. - + - Adds override for [method _font_is_language_supported]. + Adds override for [method font_is_language_supported]. - + @@ -683,7 +674,7 @@ Sets the width of the range around the shape between the minimum and maximum representable signed distance. - + @@ -691,15 +682,16 @@ Sets source font size used to generate MSDF textures. - + - 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. + 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. 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. - + @@ -707,7 +699,7 @@ Sets the font family name. - + @@ -715,7 +707,7 @@ Sets font OpenType feature set override. - + @@ -723,7 +715,7 @@ Sets font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only. - + @@ -732,16 +724,16 @@ Sets scaling factor of the color bitmap font. - + - Adds override for [method _font_is_script_supported]. + Adds override for [method font_is_script_supported]. - + @@ -751,7 +743,7 @@ Sets extra spacing added between glyphs in pixels. - + @@ -759,7 +751,7 @@ Sets the font style flags, see [enum TextServer.FontStyle]. - + @@ -767,7 +759,7 @@ Sets the font style name. - + @@ -775,7 +767,7 @@ Sets font sub-pixel glyph positioning mode. - + @@ -785,7 +777,7 @@ Sets font cache texture image data. - + @@ -795,7 +787,7 @@ Sets array containing the first free pixel in the each column of texture. Should be the same size as texture width or empty. - + @@ -804,7 +796,7 @@ For example, to simulate italic typeface by slanting, apply the following transform [code]Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)[/code]. - + @@ -813,7 +805,7 @@ Sets pixel offset of the underline below the baseline. - + @@ -822,29 +814,29 @@ Sets thickness of the underline in pixels. - + - Sets variation coordinates for the specified font cache entry. See [method _font_supported_variation_list] for more info. + Sets variation coordinates for the specified font cache entry. See [method font_supported_variation_list] for more info. - + Returns the dictionary of the supported OpenType features. - + Returns the dictionary of the supported OpenType variation coordinates. - + @@ -852,82 +844,82 @@ Converts a number from the Western Arabic (0..9) to the numeral systems used in [code]language[/code]. - + Frees an object created by this [TextServer]. - + Returns text server features, see [enum TextServer.Feature]. - + Returns size of the replacement character (box with character hexadecimal code that is drawn in place of invalid characters). + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns the name of the server interface. - + Returns default TextServer database (e.g. ICU break iterators and dictionaries) filename. - + Returns TextServer database (e.g. ICU break iterators and dictionaries) description. - + Returns [code]true[/code] if [code]rid[/code] is valid resource owned by this text server. - + Returns [code]true[/code] if the server supports a feature. - + Returns [code]true[/code] if locale is right-to-left. - + Loads optional TextServer database (e.g. ICU break iterators and dictionaries). - [b]Note:[/b] This function should be called before any other TextServer functions used, otherwise it won't have any effect. - + Converts readable feature, variation, script or language name to OpenType tag. - + @@ -935,14 +927,14 @@ Converts a number from the numeral systems used in [code]language[/code] to Western Arabic (0..9). - + Returns percent sign used in the [code]language[/code]. - + @@ -950,14 +942,14 @@ [b]Note:[/b] This function is used by during project export, to include TextServer database. - + - Returns number of text spans added using [method _shaped_text_add_string] or [method _shaped_text_add_object]. + Returns number of text spans added using [method shaped_text_add_string] or [method shaped_text_add_object]. - + @@ -965,7 +957,7 @@ Returns text span metadata. - + @@ -976,7 +968,7 @@ Changes text span font, font size and OpenType features, without changing the text. - + @@ -987,7 +979,7 @@ Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] object replacement characters. - + @@ -1000,14 +992,14 @@ Adds text span and font to draw it to the text buffer. - + Clears text buffer (removes text and inline objects). - + @@ -1017,9 +1009,10 @@ Draw shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + @@ -1030,116 +1023,118 @@ Draw the outline of the shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + - Adjusts text with to fit to specified width, returns new text width + Adjusts text with to fit to specified width, returns new text width. - + Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical). - [b]Note:[/b] Overall ascent can be higher than font ascent, if some glyphs are displaced from the baseline. - + Returns shapes of the carets corresponding to the character offset [code]position[/code] in the text. Returned caret shape is 1 pixel wide rectangle. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. - + Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical). - [b]Note:[/b] Overall descent can be higher than font descent, if some glyphs are displaced from the baseline. - + Returns direction of the text. - + Returns dominant direction of in the range of text. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns number of glyphs in the ellipsis. - - + + Returns array of the glyphs in the ellipsis. - + Returns position of the ellipsis. - + - Returns text glyphs count. + Returns number of glyphs in the buffer. - - + + - Copies text glyphs in the visual order, into preallocated array of the size returned by [method _shaped_text_get_glyph_count]. + Returns an array of glyphs in the visual order. - + Returns composite character's bounds as offsets from the start of the line. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns direction of the text, inferred by the BiDi algorithm. - + @@ -1147,9 +1142,10 @@ Breaks text to the lines and returns character ranges for each line. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + @@ -1158,9 +1154,10 @@ Breaks text to the lines and columns. Returns character ranges for each segment. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + @@ -1168,35 +1165,35 @@ Returns bounding rectangle of the inline object. - + Returns array of inline objects. - + - Returns text orientation. + eturns text orientation. - + - Sets text orientation. + Returns the parent buffer from which the substring originates. - + Returns [code]true[/code] if text buffer is configured to display control characters. - + @@ -1204,97 +1201,102 @@ [b]Note:[/b] If set to [code]false[/code], nothing is displayed in place of invalid characters. - + Returns substring buffer character range in the parent buffer. - + Returns selection rectangles for the specified character range. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns size of the text. - + - Returns ellipsis and trim positions. + Returns the position of the overrun trim. - + Returns pixel offset of the underline below the baseline. - + Returns thickness of the underline. - + Returns width (for horizontal layout) or height (for vertical) of the text. - + Breaks text into words and returns array of character ranges. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns grapheme index at the specified pixel offset at the baseline, or [code]-1[/code] if none is found. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + Returns [code]true[/code] if buffer is successfully shaped. - + Returns composite character end position closest to the [code]pos[/code]. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + @@ -1303,15 +1305,16 @@ Trims text if it exceeds the given width. - + Returns composite character start position closest to the [code]pos[/code]. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. - + @@ -1321,7 +1324,7 @@ Sets new size and alignment of embedded object. - + @@ -1330,7 +1333,7 @@ Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. - + @@ -1338,25 +1341,23 @@ Sets custom punctuation character list, used for word breaking. If set to empty string, server defaults are used. - + Sets desired text direction. If set to [code]TEXT_DIRECTION_AUTO[/code], direction will be detected based on the buffer contents and current locale. - [b]Note:[/b] Direction is ignored if server does not support [code]FEATURE_BIDI_LAYOUT[/code] feature. - + Sets desired text orientation. - [b]Note:[/b] Orientation is ignored if server does not support [code]FEATURE_VERTICAL_LAYOUT[/code] feature. - + @@ -1364,7 +1365,7 @@ If set to [code]true[/code] text buffer will display control characters. - + @@ -1372,22 +1373,21 @@ If set to [code]true[/code] text buffer will display invalid characters as hexadecimal codes, otherwise nothing is displayed. - + Shapes buffer if it's not shaped. Returns [code]true[/code] if the string is shaped successfully. - [b]Note:[/b] It is not necessary to call this function manually, buffer will be shaped automatically as soon as any of its output data is requested. - - + + - Copies text glyphs in the logical order, into preallocated array of the size returned by [method _shaped_text_get_glyph_count]. + Returns text glyphs in the logical order. - + @@ -1396,7 +1396,7 @@ Returns text buffer for the substring of the text in the [code]shaped[/code] text buffer (including inline objects). - + @@ -1404,37 +1404,47 @@ Aligns shaped text to the given tab-stops. - + - Updates line and word breaks. + Updates line breaking positions in the text buffer. + [b]Note:[/b] This method is used by default line/word breaking methods, and its implementation might be omitted if custom line breaking in implemented. - + - Updates justification opportunities (spaces, kashidas, etc.). + Updates line justification positions (word breaks and elongations) in the text buffer. + [b]Note:[/b] This method is used by default line/word breaking methods, and its implementation might be omitted if custom line breaking in implemented. - + - Returns the string converted to lowercase. Casing is locale dependent and context sensitive. The result may be longer or shorter than the original. + Returns the string converted to lowercase. - + - Returns the string converted to uppercase. Casing is locale dependent and context sensitive. The result may be longer or shorter than the original. + Returns the string converted to uppercase. - + + + + + Strips diacritics from the string. + [b]Note:[/b] If this method is not implemented in the plugin, the default implementation will be used. + + + diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index f6fdd5fc57e..f715d53fcc8 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -392,7 +392,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da stack_dump_info.push_back(d); s->set_metadata(0, d); - String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"]; + String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + String(d["function"]); s->set_text(0, line); if (i == 0) { diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 2fd4f3d6e6b..9bf3c4c5905 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -346,7 +346,7 @@ void EditorSpinSlider::_draw_spin_slider() { text_ofs.x += glyphs[i].advance; } } - TS->free(num_rid); + TS->free_rid(num_rid); if (get_step() == 1) { Ref updown2 = get_theme_icon(is_read_only() ? SNAME("updown_disabled") : SNAME("updown"), SNAME("SpinBox")); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 2ecc4839383..52833f4585a 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -645,7 +645,7 @@ void DynamicFontImportSettings::_glyph_text_selected() { selected_glyphs.insert(gl[i].index); } } - TS->free(text_rid); + TS->free_rid(text_rid); label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); } _range_selected(); diff --git a/main/main.cpp b/main/main.cpp index f0e74c3bb78..9727f179cd4 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -70,6 +70,7 @@ #include "servers/physics_server_3d.h" #include "servers/register_server_types.h" #include "servers/rendering/rendering_server_default.h" +#include "servers/text/text_server_dummy.h" #include "servers/text_server.h" #include "servers/xr_server.h" @@ -399,6 +400,12 @@ Error Main::test_setup() { translation_server = memnew(TranslationServer); tsman = memnew(TextServerManager); + if (tsman) { + Ref ts; + ts.instantiate(); + tsman->add_interface(ts); + } + register_core_extensions(); // From `Main::setup2()`. @@ -435,7 +442,26 @@ Error Main::test_setup() { initialize_theme(); ERR_FAIL_COND_V(TextServerManager::get_singleton()->get_interface_count() == 0, ERR_CANT_CREATE); - TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(0)); + + /* Use one with the most features available. */ + int max_features = 0; + for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) { + uint32_t features = TextServerManager::get_singleton()->get_interface(i)->get_features(); + int feature_number = 0; + while (features) { + feature_number += features & 1; + features >>= 1; + } + if (feature_number >= max_features) { + max_features = feature_number; + text_driver_idx = i; + } + } + if (text_driver_idx >= 0) { + TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx)); + } else { + ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface."); + } ClassDB::set_current_api(ClassDB::API_NONE); @@ -1532,6 +1558,12 @@ error: Error Main::setup2(Thread::ID p_main_tid_override) { tsman = memnew(TextServerManager); + if (tsman) { + Ref ts; + ts.instantiate(); + tsman->add_interface(ts); + } + preregister_module_types(); preregister_server_types(); @@ -1867,8 +1899,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (text_driver_idx >= 0) { TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx)); } else { - ERR_PRINT("TextServer: Unable to create TextServer interface."); - return ERR_CANT_CREATE; + ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface."); } MAIN_PRINT("Main: Load Scene Types"); diff --git a/modules/text_server_adv/.gitignore b/modules/text_server_adv/.gitignore new file mode 100644 index 00000000000..15cc38b59c6 --- /dev/null +++ b/modules/text_server_adv/.gitignore @@ -0,0 +1,2 @@ +# Godot-cpp headers +gdextension_build/godot-cpp diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index 5e5c284b575..50f7bd81a65 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -455,6 +455,7 @@ if env["builtin_icu"]: if env_icu["tools"]: env_icu.Depends("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/" + icu_data_name) env_icu.Command("#thirdparty/icu4c/icudata.gen.h", "#thirdparty/icu4c/" + icu_data_name, make_icu_data) + env_text_server_adv.Append(CPPPATH=["#thirdparty/icu4c/"]) else: thirdparty_sources += ["icu_data/icudata_stub.cpp"] diff --git a/modules/text_server_adv/doc_classes/TextServerAdvanced.xml b/modules/text_server_adv/doc_classes/TextServerAdvanced.xml index bf86eb6406c..91dde65cb83 100644 --- a/modules/text_server_adv/doc_classes/TextServerAdvanced.xml +++ b/modules/text_server_adv/doc_classes/TextServerAdvanced.xml @@ -1,5 +1,5 @@ - + Text Server using HarfBuzz, ICU and SIL Graphite to support BiDi, complex text layouts and contextual OpenType features. diff --git a/modules/text_server_adv/gdextension_build/SConstruct b/modules/text_server_adv/gdextension_build/SConstruct new file mode 100644 index 00000000000..b294fab5617 --- /dev/null +++ b/modules/text_server_adv/gdextension_build/SConstruct @@ -0,0 +1,638 @@ +#!/usr/bin/env python +import atexit +import os +import sys +import methods +import time + +# For the reference: +# - CCFLAGS are compilation flags shared between C and C++ +# - CFLAGS are for C-specific compilation flags +# - CXXFLAGS are for C++-specific compilation flags +# - CPPFLAGS are for pre-processor flags +# - CPPDEFINES are for pre-processor defines +# - LINKFLAGS are for linking flags + +time_at_start = time.time() + +env = SConscript("./godot-cpp/SConstruct") +env.__class__.disable_warnings = methods.disable_warnings + +opts = Variables([], ARGUMENTS) +opts.Add(BoolVariable("freetype_enabled", "Use FreeType library", True)) +opts.Add(BoolVariable("msdfgen_enabled", "Use MSDFgen library (require FreeType)", True)) +opts.Add(BoolVariable("graphite_enabled", "Use Graphite library (require FreeType)", True)) +opts.Add(BoolVariable("static_icu_data", "Use built-in ICU data", True)) +opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) + +opts.Update(env) + +if not env["verbose"]: + methods.no_verbose(sys, env) + +if env["platform"] == "windows" and not env["use_mingw"]: + env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding. + +# MSDFGEN +if env["msdfgen_enabled"] and env["freetype_enabled"]: + env_msdfgen = env.Clone() + env_msdfgen.disable_warnings() + + thirdparty_msdfgen_dir = "../../../thirdparty/msdfgen/" + thirdparty_msdfgen_sources = [ + "core/Contour.cpp", + "core/EdgeHolder.cpp", + "core/MSDFErrorCorrection.cpp", + "core/Projection.cpp", + "core/Scanline.cpp", + "core/Shape.cpp", + "core/SignedDistance.cpp", + "core/Vector2.cpp", + "core/contour-combiners.cpp", + "core/edge-coloring.cpp", + "core/edge-segments.cpp", + "core/edge-selectors.cpp", + "core/equation-solver.cpp", + "core/msdf-error-correction.cpp", + "core/msdfgen.cpp", + "core/rasterization.cpp", + "core/render-sdf.cpp", + "core/sdf-error-estimation.cpp", + "core/shape-description.cpp", + ] + thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources] + + env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"]) + env.Append(CPPPATH=["../../../thirdparty/msdfgen"]) + env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"]) + + lib = env_msdfgen.Library( + f'msdfgen_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_msdfgen_sources, + ) + env.Append(LIBS=[lib]) + +# FreeType +if env["freetype_enabled"]: + env_freetype = env.Clone() + env_freetype.disable_warnings() + + thirdparty_freetype_dir = "../../../thirdparty/freetype/" + thirdparty_freetype_sources = [ + "src/autofit/autofit.c", + "src/base/ftbase.c", + "src/base/ftbbox.c", + "src/base/ftbdf.c", + "src/base/ftbitmap.c", + "src/base/ftcid.c", + "src/base/ftdebug.c", + "src/base/ftfstype.c", + "src/base/ftgasp.c", + "src/base/ftglyph.c", + "src/base/ftgxval.c", + "src/base/ftinit.c", + "src/base/ftmm.c", + "src/base/ftotval.c", + "src/base/ftpatent.c", + "src/base/ftpfr.c", + "src/base/ftstroke.c", + "src/base/ftsynth.c", + "src/base/ftsystem.c", + "src/base/fttype1.c", + "src/base/ftwinfnt.c", + "src/bdf/bdf.c", + "src/bzip2/ftbzip2.c", + "src/cache/ftcache.c", + "src/cff/cff.c", + "src/cid/type1cid.c", + "src/gxvalid/gxvalid.c", + "src/gzip/ftgzip.c", + "src/lzw/ftlzw.c", + "src/otvalid/otvalid.c", + "src/pcf/pcf.c", + "src/pfr/pfr.c", + "src/psaux/psaux.c", + "src/pshinter/pshinter.c", + "src/psnames/psnames.c", + "src/raster/raster.c", + "src/sdf/sdf.c", + "src/smooth/smooth.c", + "src/truetype/truetype.c", + "src/type1/type1.c", + "src/type42/type42.c", + "src/winfonts/winfnt.c", + "src/sfnt/sfnt.c", + ] + thirdparty_freetype_sources = [thirdparty_freetype_dir + file for file in thirdparty_freetype_sources] + + thirdparty_png_dir = "../../../thirdparty/libpng/" + thirdparty_png_sources = [ + "png.c", + "pngerror.c", + "pngget.c", + "pngmem.c", + "pngpread.c", + "pngread.c", + "pngrio.c", + "pngrtran.c", + "pngrutil.c", + "pngset.c", + "pngtrans.c", + "pngwio.c", + "pngwrite.c", + "pngwtran.c", + "pngwutil.c", + ] + thirdparty_freetype_sources += [thirdparty_png_dir + file for file in thirdparty_png_sources] + + thirdparty_zlib_dir = "../../../thirdparty/zlib/" + thirdparty_zlib_sources = [ + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", + ] + thirdparty_freetype_sources += [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources] + + env_freetype.Append(CPPPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir]) + env.Append(CPPPATH=[thirdparty_freetype_dir + "/include"]) + + env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG", ("PNG_ARM_NEON_OPT", 0)]) + if env["target"] == "debug": + env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"]) + + env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"]) + + lib = env_freetype.Library( + f'freetype_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_freetype_sources, + ) + env.Append(LIBS=[lib]) + +# HarfBuzz +env_harfbuzz = env.Clone() +env_harfbuzz.disable_warnings() + +thirdparty_harfbuzz_dir = "../../../thirdparty/harfbuzz/" +thirdparty_harfbuzz_sources = [ + "src/hb-aat-layout.cc", + "src/hb-aat-map.cc", + "src/hb-blob.cc", + "src/hb-buffer-serialize.cc", + "src/hb-buffer-verify.cc", + "src/hb-buffer.cc", + "src/hb-common.cc", + #'src/hb-coretext.cc', + #'src/hb-directwrite.cc', + "src/hb-draw.cc", + "src/hb-face.cc", + "src/hb-fallback-shape.cc", + "src/hb-font.cc", + #'src/hb-gdi.cc', + #'src/hb-glib.cc', + #'src/hb-gobject-structs.cc', + "src/hb-icu.cc", + "src/hb-map.cc", + "src/hb-number.cc", + "src/hb-ot-cff1-table.cc", + "src/hb-ot-cff2-table.cc", + "src/hb-ot-color.cc", + "src/hb-ot-face.cc", + "src/hb-ot-font.cc", + "src/hb-ot-layout.cc", + "src/hb-ot-map.cc", + "src/hb-ot-math.cc", + "src/hb-ot-meta.cc", + "src/hb-ot-metrics.cc", + "src/hb-ot-name.cc", + "src/hb-ot-shape-complex-arabic.cc", + "src/hb-ot-shape-complex-default.cc", + "src/hb-ot-shape-complex-hangul.cc", + "src/hb-ot-shape-complex-hebrew.cc", + "src/hb-ot-shape-complex-indic-table.cc", + "src/hb-ot-shape-complex-indic.cc", + "src/hb-ot-shape-complex-khmer.cc", + "src/hb-ot-shape-complex-myanmar.cc", + "src/hb-ot-shape-complex-syllabic.cc", + "src/hb-ot-shape-complex-thai.cc", + "src/hb-ot-shape-complex-use.cc", + "src/hb-ot-shape-complex-vowel-constraints.cc", + "src/hb-ot-shape-fallback.cc", + "src/hb-ot-shape-normalize.cc", + "src/hb-ot-shape.cc", + "src/hb-ot-tag.cc", + "src/hb-ot-var.cc", + "src/hb-set.cc", + "src/hb-shape-plan.cc", + "src/hb-shape.cc", + "src/hb-shaper.cc", + "src/hb-static.cc", + "src/hb-style.cc", + "src/hb-subset-cff-common.cc", + "src/hb-subset-cff1.cc", + "src/hb-subset-cff2.cc", + "src/hb-subset-input.cc", + "src/hb-subset-plan.cc", + "src/hb-subset.cc", + "src/hb-ucd.cc", + "src/hb-unicode.cc", + #'src/hb-uniscribe.cc' +] + +if env["freetype_enabled"]: + thirdparty_harfbuzz_sources += [ + "src/hb-ft.cc", + "src/hb-graphite2.cc", + ] +thirdparty_harfbuzz_sources = [thirdparty_harfbuzz_dir + file for file in thirdparty_harfbuzz_sources] + +env_harfbuzz.Append( + CPPPATH=[ + "../../../thirdparty/harfbuzz/src", + "../../../thirdparty/icu4c/common/", + ] +) + +if env["freetype_enabled"]: + env_harfbuzz.Append( + CPPPATH=[ + "../../../thirdparty/freetype/include", + "../../../thirdparty/graphite/include", + ] + ) + +if env["platform"] == "android" or env["platform"] == "linuxbsd": + env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) + +env_harfbuzz.Append( + CCFLAGS=[ + "-DHAVE_ICU_BUILTIN", + "-DHAVE_ICU", + ] +) + +if env["freetype_enabled"]: + env_harfbuzz.Append( + CCFLAGS=[ + "-DHAVE_FREETYPE", + "-DHAVE_GRAPHITE2", + "-DGRAPHITE2_STATIC", + ] + ) + +env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"]) + +lib = env_harfbuzz.Library( + f'harfbuzz_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_harfbuzz_sources, +) +env.Prepend(LIBS=[lib]) + +# Graphite +if env["graphite_enabled"] and env["freetype_enabled"]: + env_graphite = env.Clone() + env_graphite.disable_warnings() + + thirdparty_graphite_dir = "../../../thirdparty/graphite/" + thirdparty_graphite_sources = [ + "src/gr_char_info.cpp", + "src/gr_face.cpp", + "src/gr_features.cpp", + "src/gr_font.cpp", + "src/gr_logging.cpp", + "src/gr_segment.cpp", + "src/gr_slot.cpp", + "src/CmapCache.cpp", + "src/Code.cpp", + "src/Collider.cpp", + "src/Decompressor.cpp", + "src/Face.cpp", + #'src/FileFace.cpp', + "src/FeatureMap.cpp", + "src/Font.cpp", + "src/GlyphCache.cpp", + "src/GlyphFace.cpp", + "src/Intervals.cpp", + "src/Justifier.cpp", + "src/NameTable.cpp", + "src/Pass.cpp", + "src/Position.cpp", + "src/Segment.cpp", + "src/Silf.cpp", + "src/Slot.cpp", + "src/Sparse.cpp", + "src/TtfUtil.cpp", + "src/UtfCodec.cpp", + "src/FileFace.cpp", + "src/json.cpp", + ] + if env["platform"] != "windows" or env["use_mingw"]: + thirdparty_graphite_sources += ["src/direct_machine.cpp"] + else: + thirdparty_graphite_sources += ["src/call_machine.cpp"] + + thirdparty_graphite_sources = [thirdparty_graphite_dir + file for file in thirdparty_graphite_sources] + + env_graphite.Append(CPPPATH=["../../../thirdparty/graphite/src", "../../../thirdparty/graphite/include"]) + env_graphite.Append( + CCFLAGS=[ + "-DGRAPHITE2_STATIC", + "-DGRAPHITE2_NTRACING", + "-DGRAPHITE2_NFILEFACE", + ] + ) + + lib = env_graphite.Library( + f'graphite_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_graphite_sources, + ) + env.Append(LIBS=[lib]) + +# ICU +env_icu = env.Clone() +env_icu.disable_warnings() + +thirdparty_icu_dir = "../../../thirdparty/icu4c/" +thirdparty_icu_sources = [ + "common/appendable.cpp", + "common/bmpset.cpp", + "common/brkeng.cpp", + "common/brkiter.cpp", + "common/bytesinkutil.cpp", + "common/bytestream.cpp", + "common/bytestrie.cpp", + "common/bytestriebuilder.cpp", + "common/bytestrieiterator.cpp", + "common/caniter.cpp", + "common/characterproperties.cpp", + "common/chariter.cpp", + "common/charstr.cpp", + "common/cmemory.cpp", + "common/cstr.cpp", + "common/cstring.cpp", + "common/cwchar.cpp", + "common/dictbe.cpp", + "common/dictionarydata.cpp", + "common/dtintrv.cpp", + "common/edits.cpp", + "common/emojiprops.cpp", + "common/errorcode.cpp", + "common/filteredbrk.cpp", + "common/filterednormalizer2.cpp", + "common/icudataver.cpp", + "common/icuplug.cpp", + "common/loadednormalizer2impl.cpp", + "common/localebuilder.cpp", + "common/localematcher.cpp", + "common/localeprioritylist.cpp", + "common/locavailable.cpp", + "common/locbased.cpp", + "common/locdispnames.cpp", + "common/locdistance.cpp", + "common/locdspnm.cpp", + "common/locid.cpp", + "common/loclikely.cpp", + "common/loclikelysubtags.cpp", + "common/locmap.cpp", + "common/locresdata.cpp", + "common/locutil.cpp", + "common/lsr.cpp", + "common/lstmbe.cpp", + "common/messagepattern.cpp", + "common/normalizer2.cpp", + "common/normalizer2impl.cpp", + "common/normlzr.cpp", + "common/parsepos.cpp", + "common/patternprops.cpp", + "common/pluralmap.cpp", + "common/propname.cpp", + "common/propsvec.cpp", + "common/punycode.cpp", + "common/putil.cpp", + "common/rbbi.cpp", + "common/rbbi_cache.cpp", + "common/rbbidata.cpp", + "common/rbbinode.cpp", + "common/rbbirb.cpp", + "common/rbbiscan.cpp", + "common/rbbisetb.cpp", + "common/rbbistbl.cpp", + "common/rbbitblb.cpp", + "common/resbund.cpp", + "common/resbund_cnv.cpp", + "common/resource.cpp", + "common/restrace.cpp", + "common/ruleiter.cpp", + "common/schriter.cpp", + "common/serv.cpp", + "common/servlk.cpp", + "common/servlkf.cpp", + "common/servls.cpp", + "common/servnotf.cpp", + "common/servrbf.cpp", + "common/servslkf.cpp", + "common/sharedobject.cpp", + "common/simpleformatter.cpp", + "common/static_unicode_sets.cpp", + "common/stringpiece.cpp", + "common/stringtriebuilder.cpp", + "common/uarrsort.cpp", + "common/ubidi.cpp", + "common/ubidi_props.cpp", + "common/ubidiln.cpp", + "common/ubiditransform.cpp", + "common/ubidiwrt.cpp", + "common/ubrk.cpp", + "common/ucase.cpp", + "common/ucasemap.cpp", + "common/ucasemap_titlecase_brkiter.cpp", + "common/ucat.cpp", + "common/uchar.cpp", + "common/ucharstrie.cpp", + "common/ucharstriebuilder.cpp", + "common/ucharstrieiterator.cpp", + "common/uchriter.cpp", + "common/ucln_cmn.cpp", + "common/ucmndata.cpp", + "common/ucnv.cpp", + "common/ucnv2022.cpp", + "common/ucnv_bld.cpp", + "common/ucnv_cb.cpp", + "common/ucnv_cnv.cpp", + "common/ucnv_ct.cpp", + "common/ucnv_err.cpp", + "common/ucnv_ext.cpp", + "common/ucnv_io.cpp", + "common/ucnv_lmb.cpp", + "common/ucnv_set.cpp", + "common/ucnv_u16.cpp", + "common/ucnv_u32.cpp", + "common/ucnv_u7.cpp", + "common/ucnv_u8.cpp", + "common/ucnvbocu.cpp", + "common/ucnvdisp.cpp", + "common/ucnvhz.cpp", + "common/ucnvisci.cpp", + "common/ucnvlat1.cpp", + "common/ucnvmbcs.cpp", + "common/ucnvscsu.cpp", + "common/ucnvsel.cpp", + "common/ucol_swp.cpp", + "common/ucptrie.cpp", + "common/ucurr.cpp", + "common/udata.cpp", + "common/udatamem.cpp", + "common/udataswp.cpp", + "common/uenum.cpp", + "common/uhash.cpp", + "common/uhash_us.cpp", + "common/uidna.cpp", + "common/uinit.cpp", + "common/uinvchar.cpp", + "common/uiter.cpp", + "common/ulist.cpp", + "common/uloc.cpp", + "common/uloc_keytype.cpp", + "common/uloc_tag.cpp", + "common/umapfile.cpp", + "common/umath.cpp", + "common/umutablecptrie.cpp", + "common/umutex.cpp", + "common/unames.cpp", + "common/unifiedcache.cpp", + "common/unifilt.cpp", + "common/unifunct.cpp", + "common/uniset.cpp", + "common/uniset_closure.cpp", + "common/uniset_props.cpp", + "common/unisetspan.cpp", + "common/unistr.cpp", + "common/unistr_case.cpp", + "common/unistr_case_locale.cpp", + "common/unistr_cnv.cpp", + "common/unistr_props.cpp", + "common/unistr_titlecase_brkiter.cpp", + "common/unorm.cpp", + "common/unormcmp.cpp", + "common/uobject.cpp", + "common/uprops.cpp", + "common/ures_cnv.cpp", + "common/uresbund.cpp", + "common/uresdata.cpp", + "common/usc_impl.cpp", + "common/uscript.cpp", + "common/uscript_props.cpp", + "common/uset.cpp", + "common/uset_props.cpp", + "common/usetiter.cpp", + # "common/ushape.cpp", + "common/usprep.cpp", + "common/ustack.cpp", + "common/ustr_cnv.cpp", + "common/ustr_titlecase_brkiter.cpp", + "common/ustr_wcs.cpp", + "common/ustrcase.cpp", + "common/ustrcase_locale.cpp", + "common/ustrenum.cpp", + "common/ustrfmt.cpp", + "common/ustring.cpp", + "common/ustrtrns.cpp", + "common/utext.cpp", + "common/utf_impl.cpp", + "common/util.cpp", + "common/util_props.cpp", + "common/utrace.cpp", + "common/utrie.cpp", + "common/utrie2.cpp", + "common/utrie2_builder.cpp", + "common/utrie_swap.cpp", + "common/uts46.cpp", + "common/utypes.cpp", + "common/uvector.cpp", + "common/uvectr32.cpp", + "common/uvectr64.cpp", + "common/wintz.cpp", +] +thirdparty_icu_sources = [thirdparty_icu_dir + file for file in thirdparty_icu_sources] + +icu_data_name = "icudt70l.dat" + +if env["static_icu_data"]: + env_icu.Depends("../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name) + env_icu.Command( + "../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/" + icu_data_name, methods.make_icu_data + ) + env.Append(CXXFLAGS=["-DICU_STATIC_DATA"]) + env.Append(CPPPATH=["../../../thirdparty/icu4c/"]) +else: + thirdparty_sources += ["../icu_data/icudata_stub.cpp"] + +env_icu.Append(CPPPATH=["../../../thirdparty/icu4c/common/"]) +env_icu.Append( + CXXFLAGS=[ + "-DU_STATIC_IMPLEMENTATION", + "-DU_COMMON_IMPLEMENTATION", + "-DUCONFIG_NO_COLLATION", + "-DUCONFIG_NO_CONVERSION", + "-DUCONFIG_NO_FORMATTING", + "-DUCONFIG_NO_SERVICE", + "-DUCONFIG_NO_IDNA", + "-DUCONFIG_NO_FILE_IO", + "-DUCONFIG_NO_TRANSLITERATION", + "-DPKGDATA_MODE=static", + "-DICU_DATA_NAME=" + icu_data_name, + ] +) +env.Append( + CXXFLAGS=[ + "-DICU_DATA_NAME=" + icu_data_name, + ] +) +env.Append(CPPPATH=["../../../thirdparty/icu4c/common/"]) + +if env["platform"] == "windows": + env.Append(LIBS=["advapi32"]) + +lib = env_icu.Library( + f'icu_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', thirdparty_icu_sources +) +env.Append(LIBS=[lib]) + +env.Append(CPPDEFINES=["GDEXTENSION"]) +env.Append(CPPPATH=["../"]) +sources = Glob("../*.cpp") + +if env["platform"] == "osx": + methods.write_osx_plist( + f'./bin/libtextserver_advanced.osx.{env["target"]}.framework', + f'libtextserver_advanced.osx.{env["target"]}', + "org.godotengine.textserver_advanced", + "ICU / HarfBuzz / Graphite Text Server", + ) + library = env.SharedLibrary( + f'./bin/libtextserver_advanced.osx.{env["target"]}.framework/libtextserver_advanced.osx.{env["target"]}', + source=sources, + ) +else: + library = env.SharedLibrary( + f'./bin/libtextserver_advanced.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["SHLIBSUFFIX"]}', + source=sources, + ) + +Default(library) + + +def print_elapsed_time(): + elapsed_time_sec = round(time.time() - time_at_start, 3) + time_ms = round((elapsed_time_sec % 1) * 1000) + print("[Time elapsed: {}.{:03}]".format(time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)), time_ms)) + + +atexit.register(print_elapsed_time) diff --git a/modules/text_server_adv/gdextension_build/methods.py b/modules/text_server_adv/gdextension_build/methods.py new file mode 100644 index 00000000000..d404f2851e9 --- /dev/null +++ b/modules/text_server_adv/gdextension_build/methods.py @@ -0,0 +1,130 @@ +import os +import sys + + +def no_verbose(sys, env): + colors = {} + + # Colors are disabled in non-TTY environments such as pipes. This means + # that if output is redirected to a file, it will not contain color codes + if sys.stdout.isatty(): + colors["blue"] = "\033[0;94m" + colors["bold_blue"] = "\033[1;94m" + colors["reset"] = "\033[0m" + else: + colors["blue"] = "" + colors["bold_blue"] = "" + colors["reset"] = "" + + # There is a space before "..." to ensure that source file names can be + # Ctrl + clicked in the VS Code terminal. + compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_program_message = "{}Linking Program {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + + env.Append(CXXCOMSTR=[compile_source_message]) + env.Append(CCCOMSTR=[compile_source_message]) + env.Append(SHCCCOMSTR=[compile_shared_source_message]) + env.Append(SHCXXCOMSTR=[compile_shared_source_message]) + env.Append(ARCOMSTR=[link_library_message]) + env.Append(RANLIBCOMSTR=[ranlib_library_message]) + env.Append(SHLINKCOMSTR=[link_shared_library_message]) + env.Append(LINKCOMSTR=[link_program_message]) + env.Append(JARCOMSTR=[java_library_message]) + env.Append(JAVACCOMSTR=[java_compile_source_message]) + + +def disable_warnings(self): + # 'self' is the environment + if self["platform"] == "windows" and not self["use_mingw"]: + # We have to remove existing warning level defines before appending /w, + # otherwise we get: "warning D9025 : overriding '/W3' with '/w'" + warn_flags = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/WX"] + self.Append(CCFLAGS=["/w"]) + self.Append(CFLAGS=["/w"]) + self.Append(CXXFLAGS=["/w"]) + self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x in warn_flags] + self["CFLAGS"] = [x for x in self["CFLAGS"] if not x in warn_flags] + self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x in warn_flags] + else: + self.Append(CCFLAGS=["-w"]) + self.Append(CFLAGS=["-w"]) + self.Append(CXXFLAGS=["-w"]) + + +def make_icu_data(target, source, env): + dst = target[0].srcnode().abspath + g = open(dst, "w", encoding="utf-8") + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n") + g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n") + g.write("#ifndef _ICU_DATA_H\n") + g.write("#define _ICU_DATA_H\n") + g.write('#include "unicode/utypes.h"\n') + g.write('#include "unicode/udata.h"\n') + g.write('#include "unicode/uversion.h"\n') + + f = open(source[0].srcnode().abspath, "rb") + buf = f.read() + + g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n") + g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n') + for i in range(len(buf)): + g.write("\t" + str(buf[i]) + ",\n") + + g.write("};\n") + g.write("#endif") + + +def write_osx_plist(target, binary_name, identifier, name): + os.makedirs(f"{target}/Resourece/", exist_ok=True) + f = open(f"{target}/Resourece/Info.plist", "w") + + f.write(f'\n') + f.write(f'\n') + f.write(f'\n') + f.write(f"\n") + f.write(f"\tCFBundleExecutable\n") + f.write(f"\t{binary_name}\n") + f.write(f"\tCFBundleIdentifier\n") + f.write(f"\t{identifier}\n") + f.write(f"\tCFBundleInfoDictionaryVersion\n") + f.write(f"\t6.0\n") + f.write(f"\tCFBundleName\n") + f.write(f"\t{name}\n") + f.write(f"\tCFBundlePackageType\n") + f.write(f"\tFMWK\n") + f.write(f"\tCFBundleShortVersionString\n") + f.write(f"\t1.0.0\n") + f.write(f"\tCFBundleSupportedPlatforms\n") + f.write(f"\t\n") + f.write(f"\t\tMacOSX\n") + f.write(f"\t\n") + f.write(f"\tCFBundleVersion\n") + f.write(f"\t1.0.0\n") + f.write(f"\tLSMinimumSystemVersion\n") + f.write(f"\t10.14\n") + f.write(f"\n") + f.write(f"\n") diff --git a/modules/text_server_adv/gdextension_build/text_server_adv.gdextension b/modules/text_server_adv/gdextension_build/text_server_adv.gdextension new file mode 100644 index 00000000000..5956476a5e8 --- /dev/null +++ b/modules/text_server_adv/gdextension_build/text_server_adv.gdextension @@ -0,0 +1,12 @@ +[configuration] + +entry_symbol = "textserver_advanced_init" + +[libraries] + +linux.64.debug = "bin/libtextserver_advanced.linux.debug.64.so" +linux.64.release = "bin/libtextserver_advanced.linux.release.64.so" +windows.64.debug = "bin/libtextserver_advanced.windows.debug.64.dll" +windows.64.release = "bin/libtextserver_advanced.windows.release.64.dll" +macos.debug = "bin/libtextserver_advanced.osx.debug.framework" +macos.release = "bin/libtextserver_advanced.osx.release.framework" diff --git a/modules/text_server_adv/register_types.cpp b/modules/text_server_adv/register_types.cpp index d2dbfa045b4..ed00bdfbf92 100644 --- a/modules/text_server_adv/register_types.cpp +++ b/modules/text_server_adv/register_types.cpp @@ -34,10 +34,11 @@ void preregister_text_server_adv_types() { GDREGISTER_CLASS(TextServerAdvanced); - if (TextServerManager::get_singleton()) { + TextServerManager *tsman = TextServerManager::get_singleton(); + if (tsman) { Ref ts; ts.instantiate(); - TextServerManager::get_singleton()->add_interface(ts); + tsman->add_interface(ts); } } @@ -46,3 +47,26 @@ void register_text_server_adv_types() { void unregister_text_server_adv_types() { } + +#ifdef GDEXTENSION + +#include +#include +#include + +using namespace godot; + +extern "C" { + +GDNativeBool GDN_EXPORT textserver_advanced_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { + GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); + + init_obj.register_server_initializer(&preregister_text_server_adv_types); + init_obj.register_server_terminator(&unregister_text_server_adv_types); + + return init_obj.init(); +} + +} // ! extern "C" + +#endif // ! GDEXTENSION diff --git a/modules/text_server_adv/script_iterator.h b/modules/text_server_adv/script_iterator.h index 1e11b51521c..2bd045b91ae 100644 --- a/modules/text_server_adv/script_iterator.h +++ b/modules/text_server_adv/script_iterator.h @@ -31,7 +31,22 @@ #ifndef SCRIPT_ITERATOR_H #define SCRIPT_ITERATOR_H -#include "servers/text_server.h" +#ifdef GDEXTENSION + +// Headers for building as GDExtension plug-in. +#include +#include +#include + +using namespace godot; + +#else + +// Headers for building as built-in module. +#include "core/string/ustring.h" +#include "core/templates/vector.h" + +#endif #include #include diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 7fd9cd42ed2..b5912893b1f 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -30,15 +30,37 @@ #include "text_server_adv.h" +#ifdef GDEXTENSION +// Headers for building as GDExtension plug-in. + +#include +#include +#include +#include + +using namespace godot; + +#else +// Headers for building as built-in module. + +#include "core/core_bind.h" #include "core/error/error_macros.h" #include "core/string/print_string.h" #include "core/string/translation.h" -#ifdef ICU_STATIC_DATA -#include "thirdparty/icu4c/icudata.gen.h" +#include "modules/modules_enabled.gen.h" // For freetype, msdfgen. + +using namespace core_bind; + #endif -#include "modules/modules_enabled.gen.h" // For freetype, msdfgen. +// Built-in ICU data. + +#ifdef ICU_STATIC_DATA +#include "icudata.gen.h" +#endif + +// Thirdparty headers. #ifdef MODULE_MSDFGEN_ENABLED #include "core/ShapeDistanceFinder.h" @@ -79,8 +101,8 @@ hb_bool_t TextServerAdvanced::_bmp_get_nominal_glyph(hb_font_t *p_font, void *p_ } if (!bm_font->face->glyph_map.has(p_unicode)) { - if (bm_font->face->glyph_map.has(0xF000u + p_unicode)) { - *r_glyph = 0xF000u + p_unicode; + if (bm_font->face->glyph_map.has(0xf000u + p_unicode)) { + *r_glyph = 0xf000u + p_unicode; return true; } else { return false; @@ -305,22 +327,52 @@ _FORCE_INLINE_ bool is_connected_to_prev(char32_t p_chr, char32_t p_pchr) { /*************************************************************************/ -String TextServerAdvanced::interface_name = "ICU / HarfBuzz / Graphite"; -uint32_t TextServerAdvanced::interface_features = FEATURE_BIDI_LAYOUT | FEATURE_VERTICAL_LAYOUT | FEATURE_SHAPING | FEATURE_KASHIDA_JUSTIFICATION | FEATURE_BREAK_ITERATORS | FEATURE_USE_SUPPORT_DATA | FEATURE_FONT_VARIABLE | FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION; - bool TextServerAdvanced::has_feature(Feature p_feature) const { - return (interface_features & p_feature) == p_feature; + switch (p_feature) { + case FEATURE_SIMPLE_LAYOUT: + case FEATURE_BIDI_LAYOUT: + case FEATURE_VERTICAL_LAYOUT: + case FEATURE_SHAPING: + case FEATURE_KASHIDA_JUSTIFICATION: + case FEATURE_BREAK_ITERATORS: + case FEATURE_FONT_BITMAP: +#ifdef MODULE_FREETYPE_ENABLED + case FEATURE_FONT_DYNAMIC: +#endif +#ifdef MODULE_MSDFGEN_ENABLED + case FEATURE_FONT_MSDF: +#endif + case FEATURE_FONT_VARIABLE: + case FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION: + case FEATURE_USE_SUPPORT_DATA: + return true; + default: { + } + } + return false; } String TextServerAdvanced::get_name() const { - return interface_name; +#ifdef GDEXTENSION + return "ICU / HarfBuzz / Graphite (GDExtension)"; +#else + return "ICU / HarfBuzz / Graphite (Built-in)"; +#endif } -uint32_t TextServerAdvanced::get_features() const { +int64_t TextServerAdvanced::get_features() const { + int64_t interface_features = FEATURE_SIMPLE_LAYOUT | FEATURE_BIDI_LAYOUT | FEATURE_VERTICAL_LAYOUT | FEATURE_SHAPING | FEATURE_KASHIDA_JUSTIFICATION | FEATURE_BREAK_ITERATORS | FEATURE_FONT_BITMAP | FEATURE_FONT_VARIABLE | FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION | FEATURE_USE_SUPPORT_DATA; +#ifdef MODULE_FREETYPE_ENABLED + interface_features |= FEATURE_FONT_DYNAMIC; +#endif +#ifdef MODULE_MSDFGEN_ENABLED + interface_features |= FEATURE_FONT_MSDF; +#endif + return interface_features; } -void TextServerAdvanced::free(RID p_rid) { +void TextServerAdvanced::free_rid(const RID &p_rid) { _THREAD_SAFE_METHOD_ if (font_owner.owns(p_rid)) { FontDataAdvanced *fd = font_owner.get_or_null(p_rid); @@ -333,7 +385,7 @@ void TextServerAdvanced::free(RID p_rid) { } } -bool TextServerAdvanced::has(RID p_rid) { +bool TextServerAdvanced::has(const RID &p_rid) { _THREAD_SAFE_METHOD_ return font_owner.owns(p_rid) || shaped_owner.owns(p_rid); } @@ -342,43 +394,36 @@ bool TextServerAdvanced::load_support_data(const String &p_filename) { _THREAD_SAFE_METHOD_ #ifdef ICU_STATIC_DATA - if (icu_data == nullptr) { + if (!icu_data_loaded) { UErrorCode err = U_ZERO_ERROR; u_init(&err); // Do not check for errors, since we only load part of the data. - icu_data = (uint8_t *)&U_ICUDATA_ENTRY_POINT; + icu_data_loaded = true; } #else - if (icu_data == nullptr) { + if (!icu_data_loaded) { String filename = (p_filename.is_empty()) ? String("res://") + _MKSTR(ICU_DATA_NAME) : p_filename; - FileAccess *f = FileAccess::open(filename, FileAccess::READ); - if (!f) { + Ref f; + f.instantiate(); + if (f->open(filename, File::READ) != OK) { return false; } + uint64_t len = f->get_length(); + PackedByteArray icu_data = f->get_buffer(len); + f->close(); UErrorCode err = U_ZERO_ERROR; - - // ICU data found. - uint64_t len = f->get_length(); - icu_data = (uint8_t *)memalloc(len); - f->get_buffer(icu_data, len); - f->close(); - memdelete(f); - - udata_setCommonData(icu_data, &err); + udata_setCommonData(icu_data.ptr(), &err); if (U_FAILURE(err)) { - memfree(icu_data); - icu_data = nullptr; ERR_FAIL_V_MSG(false, u_errorName(err)); } err = U_ZERO_ERROR; u_init(&err); if (U_FAILURE(err)) { - memfree(icu_data); - icu_data = nullptr; ERR_FAIL_V_MSG(false, u_errorName(err)); } + icu_data_loaded = true; } #endif return true; @@ -405,13 +450,18 @@ bool TextServerAdvanced::save_support_data(const String &p_filename) const { #ifdef ICU_STATIC_DATA // Store data to the res file if it's available. - FileAccess *f = FileAccess::open(p_filename, FileAccess::WRITE); - if (!f) { + + Ref f; + f.instantiate(); + if (f->open(p_filename, File::WRITE) != OK) { return false; } - f->store_buffer(U_ICUDATA_ENTRY_POINT, U_ICUDATA_SIZE); + + PackedByteArray icu_data; + icu_data.resize(U_ICUDATA_SIZE); + memcpy(icu_data.ptrw(), U_ICUDATA_ENTRY_POINT, U_ICUDATA_SIZE); + f->store_buffer(icu_data); f->close(); - memdelete(f); return true; #else @@ -428,256 +478,262 @@ bool TextServerAdvanced::is_locale_right_to_left(const String &p_locale) const { } } -void TextServerAdvanced::_insert_feature_sets() { - // Registered OpenType feature tags. - feature_sets.insert("access_all_alternates", HB_TAG('a', 'a', 'l', 't')); - feature_sets.insert("above_base_forms", HB_TAG('a', 'b', 'v', 'f')); - feature_sets.insert("above_base_mark_positioning", HB_TAG('a', 'b', 'v', 'm')); - feature_sets.insert("above_base_substitutions", HB_TAG('a', 'b', 'v', 's')); - feature_sets.insert("alternative_fractions", HB_TAG('a', 'f', 'r', 'c')); - feature_sets.insert("akhands", HB_TAG('a', 'k', 'h', 'n')); - feature_sets.insert("below_base_forms", HB_TAG('b', 'l', 'w', 'f')); - feature_sets.insert("below_base_mark_positioning", HB_TAG('b', 'l', 'w', 'm')); - feature_sets.insert("below_base_substitutions", HB_TAG('b', 'l', 'w', 's')); - feature_sets.insert("contextual_alternates", HB_TAG('c', 'a', 'l', 't')); - feature_sets.insert("case_sensitive_forms", HB_TAG('c', 'a', 's', 'e')); - feature_sets.insert("glyph_composition", HB_TAG('c', 'c', 'm', 'p')); - feature_sets.insert("conjunct_form_after_ro", HB_TAG('c', 'f', 'a', 'r')); - feature_sets.insert("conjunct_forms", HB_TAG('c', 'j', 'c', 't')); - feature_sets.insert("contextual_ligatures", HB_TAG('c', 'l', 'i', 'g')); - feature_sets.insert("centered_cjk_punctuation", HB_TAG('c', 'p', 'c', 't')); - feature_sets.insert("capital_spacing", HB_TAG('c', 'p', 's', 'p')); - feature_sets.insert("contextual_swash", HB_TAG('c', 's', 'w', 'h')); - feature_sets.insert("cursive_positioning", HB_TAG('c', 'u', 'r', 's')); - feature_sets.insert("character_variant_01", HB_TAG('c', 'v', '0', '1')); - feature_sets.insert("character_variant_02", HB_TAG('c', 'v', '0', '2')); - feature_sets.insert("character_variant_03", HB_TAG('c', 'v', '0', '3')); - feature_sets.insert("character_variant_04", HB_TAG('c', 'v', '0', '4')); - feature_sets.insert("character_variant_05", HB_TAG('c', 'v', '0', '5')); - feature_sets.insert("character_variant_06", HB_TAG('c', 'v', '0', '6')); - feature_sets.insert("character_variant_07", HB_TAG('c', 'v', '0', '7')); - feature_sets.insert("character_variant_08", HB_TAG('c', 'v', '0', '8')); - feature_sets.insert("character_variant_09", HB_TAG('c', 'v', '0', '9')); - feature_sets.insert("character_variant_10", HB_TAG('c', 'v', '1', '0')); - feature_sets.insert("character_variant_11", HB_TAG('c', 'v', '1', '1')); - feature_sets.insert("character_variant_12", HB_TAG('c', 'v', '1', '2')); - feature_sets.insert("character_variant_13", HB_TAG('c', 'v', '1', '3')); - feature_sets.insert("character_variant_14", HB_TAG('c', 'v', '1', '4')); - feature_sets.insert("character_variant_15", HB_TAG('c', 'v', '1', '5')); - feature_sets.insert("character_variant_16", HB_TAG('c', 'v', '1', '6')); - feature_sets.insert("character_variant_17", HB_TAG('c', 'v', '1', '7')); - feature_sets.insert("character_variant_18", HB_TAG('c', 'v', '1', '8')); - feature_sets.insert("character_variant_19", HB_TAG('c', 'v', '1', '9')); - feature_sets.insert("character_variant_20", HB_TAG('c', 'v', '2', '0')); - feature_sets.insert("character_variant_21", HB_TAG('c', 'v', '2', '1')); - feature_sets.insert("character_variant_22", HB_TAG('c', 'v', '2', '2')); - feature_sets.insert("character_variant_23", HB_TAG('c', 'v', '2', '3')); - feature_sets.insert("character_variant_24", HB_TAG('c', 'v', '2', '4')); - feature_sets.insert("character_variant_25", HB_TAG('c', 'v', '2', '5')); - feature_sets.insert("character_variant_26", HB_TAG('c', 'v', '2', '6')); - feature_sets.insert("character_variant_27", HB_TAG('c', 'v', '2', '7')); - feature_sets.insert("character_variant_28", HB_TAG('c', 'v', '2', '8')); - feature_sets.insert("character_variant_29", HB_TAG('c', 'v', '2', '9')); - feature_sets.insert("character_variant_30", HB_TAG('c', 'v', '3', '0')); - feature_sets.insert("character_variant_31", HB_TAG('c', 'v', '3', '1')); - feature_sets.insert("character_variant_32", HB_TAG('c', 'v', '3', '2')); - feature_sets.insert("character_variant_33", HB_TAG('c', 'v', '3', '3')); - feature_sets.insert("character_variant_34", HB_TAG('c', 'v', '3', '4')); - feature_sets.insert("character_variant_35", HB_TAG('c', 'v', '3', '5')); - feature_sets.insert("character_variant_36", HB_TAG('c', 'v', '3', '6')); - feature_sets.insert("character_variant_37", HB_TAG('c', 'v', '3', '7')); - feature_sets.insert("character_variant_38", HB_TAG('c', 'v', '3', '8')); - feature_sets.insert("character_variant_39", HB_TAG('c', 'v', '3', '9')); - feature_sets.insert("character_variant_40", HB_TAG('c', 'v', '4', '0')); - feature_sets.insert("character_variant_41", HB_TAG('c', 'v', '4', '1')); - feature_sets.insert("character_variant_42", HB_TAG('c', 'v', '4', '2')); - feature_sets.insert("character_variant_43", HB_TAG('c', 'v', '4', '3')); - feature_sets.insert("character_variant_44", HB_TAG('c', 'v', '4', '4')); - feature_sets.insert("character_variant_45", HB_TAG('c', 'v', '4', '5')); - feature_sets.insert("character_variant_46", HB_TAG('c', 'v', '4', '6')); - feature_sets.insert("character_variant_47", HB_TAG('c', 'v', '4', '7')); - feature_sets.insert("character_variant_48", HB_TAG('c', 'v', '4', '8')); - feature_sets.insert("character_variant_49", HB_TAG('c', 'v', '4', '9')); - feature_sets.insert("character_variant_50", HB_TAG('c', 'v', '5', '0')); - feature_sets.insert("character_variant_51", HB_TAG('c', 'v', '5', '1')); - feature_sets.insert("character_variant_52", HB_TAG('c', 'v', '5', '2')); - feature_sets.insert("character_variant_53", HB_TAG('c', 'v', '5', '3')); - feature_sets.insert("character_variant_54", HB_TAG('c', 'v', '5', '4')); - feature_sets.insert("character_variant_55", HB_TAG('c', 'v', '5', '5')); - feature_sets.insert("character_variant_56", HB_TAG('c', 'v', '5', '6')); - feature_sets.insert("character_variant_57", HB_TAG('c', 'v', '5', '7')); - feature_sets.insert("character_variant_58", HB_TAG('c', 'v', '5', '8')); - feature_sets.insert("character_variant_59", HB_TAG('c', 'v', '5', '9')); - feature_sets.insert("character_variant_60", HB_TAG('c', 'v', '6', '0')); - feature_sets.insert("character_variant_61", HB_TAG('c', 'v', '6', '1')); - feature_sets.insert("character_variant_62", HB_TAG('c', 'v', '6', '2')); - feature_sets.insert("character_variant_63", HB_TAG('c', 'v', '6', '3')); - feature_sets.insert("character_variant_64", HB_TAG('c', 'v', '6', '4')); - feature_sets.insert("character_variant_65", HB_TAG('c', 'v', '6', '5')); - feature_sets.insert("character_variant_66", HB_TAG('c', 'v', '6', '6')); - feature_sets.insert("character_variant_67", HB_TAG('c', 'v', '6', '7')); - feature_sets.insert("character_variant_68", HB_TAG('c', 'v', '6', '8')); - feature_sets.insert("character_variant_69", HB_TAG('c', 'v', '6', '9')); - feature_sets.insert("character_variant_70", HB_TAG('c', 'v', '7', '0')); - feature_sets.insert("character_variant_71", HB_TAG('c', 'v', '7', '1')); - feature_sets.insert("character_variant_72", HB_TAG('c', 'v', '7', '2')); - feature_sets.insert("character_variant_73", HB_TAG('c', 'v', '7', '3')); - feature_sets.insert("character_variant_74", HB_TAG('c', 'v', '7', '4')); - feature_sets.insert("character_variant_75", HB_TAG('c', 'v', '7', '5')); - feature_sets.insert("character_variant_76", HB_TAG('c', 'v', '7', '6')); - feature_sets.insert("character_variant_77", HB_TAG('c', 'v', '7', '7')); - feature_sets.insert("character_variant_78", HB_TAG('c', 'v', '7', '8')); - feature_sets.insert("character_variant_79", HB_TAG('c', 'v', '7', '9')); - feature_sets.insert("character_variant_80", HB_TAG('c', 'v', '8', '0')); - feature_sets.insert("character_variant_81", HB_TAG('c', 'v', '8', '1')); - feature_sets.insert("character_variant_82", HB_TAG('c', 'v', '8', '2')); - feature_sets.insert("character_variant_83", HB_TAG('c', 'v', '8', '3')); - feature_sets.insert("character_variant_84", HB_TAG('c', 'v', '8', '4')); - feature_sets.insert("character_variant_85", HB_TAG('c', 'v', '8', '5')); - feature_sets.insert("character_variant_86", HB_TAG('c', 'v', '8', '6')); - feature_sets.insert("character_variant_87", HB_TAG('c', 'v', '8', '7')); - feature_sets.insert("character_variant_88", HB_TAG('c', 'v', '8', '8')); - feature_sets.insert("character_variant_89", HB_TAG('c', 'v', '8', '9')); - feature_sets.insert("character_variant_90", HB_TAG('c', 'v', '9', '0')); - feature_sets.insert("character_variant_91", HB_TAG('c', 'v', '9', '1')); - feature_sets.insert("character_variant_92", HB_TAG('c', 'v', '9', '2')); - feature_sets.insert("character_variant_93", HB_TAG('c', 'v', '9', '3')); - feature_sets.insert("character_variant_94", HB_TAG('c', 'v', '9', '4')); - feature_sets.insert("character_variant_95", HB_TAG('c', 'v', '9', '5')); - feature_sets.insert("character_variant_96", HB_TAG('c', 'v', '9', '6')); - feature_sets.insert("character_variant_97", HB_TAG('c', 'v', '9', '7')); - feature_sets.insert("character_variant_98", HB_TAG('c', 'v', '9', '8')); - feature_sets.insert("character_variant_99", HB_TAG('c', 'v', '9', '9')); - feature_sets.insert("petite_capitals_from_capitals", HB_TAG('c', '2', 'p', 'c')); - feature_sets.insert("small_capitals_from_capitals", HB_TAG('c', '2', 's', 'c')); - feature_sets.insert("distances", HB_TAG('d', 'i', 's', 't')); - feature_sets.insert("discretionary_ligatures", HB_TAG('d', 'l', 'i', 'g')); - feature_sets.insert("denominators", HB_TAG('d', 'n', 'o', 'm')); - feature_sets.insert("dotless_forms", HB_TAG('d', 't', 'l', 's')); - feature_sets.insert("expert_forms", HB_TAG('e', 'x', 'p', 't')); - feature_sets.insert("final_glyph_on_line_alternates", HB_TAG('f', 'a', 'l', 't')); - feature_sets.insert("terminal_forms_2", HB_TAG('f', 'i', 'n', '2')); - feature_sets.insert("terminal_forms_3", HB_TAG('f', 'i', 'n', '3')); - feature_sets.insert("terminal_forms", HB_TAG('f', 'i', 'n', 'a')); - feature_sets.insert("flattened_accent_forms", HB_TAG('f', 'l', 'a', 'c')); - feature_sets.insert("fractions", HB_TAG('f', 'r', 'a', 'c')); - feature_sets.insert("full_widths", HB_TAG('f', 'w', 'i', 'd')); - feature_sets.insert("half_forms", HB_TAG('h', 'a', 'l', 'f')); - feature_sets.insert("halant_forms", HB_TAG('h', 'a', 'l', 'n')); - feature_sets.insert("alternate_half_widths", HB_TAG('h', 'a', 'l', 't')); - feature_sets.insert("historical_forms", HB_TAG('h', 'i', 's', 't')); - feature_sets.insert("horizontal_kana_alternates", HB_TAG('h', 'k', 'n', 'a')); - feature_sets.insert("historical_ligatures", HB_TAG('h', 'l', 'i', 'g')); - feature_sets.insert("hangul", HB_TAG('h', 'n', 'g', 'l')); - feature_sets.insert("hojo_kanji_forms", HB_TAG('h', 'o', 'j', 'o')); - feature_sets.insert("half_widths", HB_TAG('h', 'w', 'i', 'd')); - feature_sets.insert("initial_forms", HB_TAG('i', 'n', 'i', 't')); - feature_sets.insert("isolated_forms", HB_TAG('i', 's', 'o', 'l')); - feature_sets.insert("italics", HB_TAG('i', 't', 'a', 'l')); - feature_sets.insert("justification_alternates", HB_TAG('j', 'a', 'l', 't')); - feature_sets.insert("jis78_forms", HB_TAG('j', 'p', '7', '8')); - feature_sets.insert("jis83_forms", HB_TAG('j', 'p', '8', '3')); - feature_sets.insert("jis90_forms", HB_TAG('j', 'p', '9', '0')); - feature_sets.insert("jis2004_forms", HB_TAG('j', 'p', '0', '4')); - feature_sets.insert("kerning", HB_TAG('k', 'e', 'r', 'n')); - feature_sets.insert("left_bounds", HB_TAG('l', 'f', 'b', 'd')); - feature_sets.insert("standard_ligatures", HB_TAG('l', 'i', 'g', 'a')); - feature_sets.insert("leading_jamo_forms", HB_TAG('l', 'j', 'm', 'o')); - feature_sets.insert("lining_figures", HB_TAG('l', 'n', 'u', 'm')); - feature_sets.insert("localized_forms", HB_TAG('l', 'o', 'c', 'l')); - feature_sets.insert("left_to_right_alternates", HB_TAG('l', 't', 'r', 'a')); - feature_sets.insert("left_to_right_mirrored_forms", HB_TAG('l', 't', 'r', 'm')); - feature_sets.insert("mark_positioning", HB_TAG('m', 'a', 'r', 'k')); - feature_sets.insert("medial_forms_2", HB_TAG('m', 'e', 'd', '2')); - feature_sets.insert("medial_forms", HB_TAG('m', 'e', 'd', 'i')); - feature_sets.insert("mathematical_greek", HB_TAG('m', 'g', 'r', 'k')); - feature_sets.insert("mark_to_mark_positioning", HB_TAG('m', 'k', 'm', 'k')); - feature_sets.insert("mark_positioning_via_substitution", HB_TAG('m', 's', 'e', 't')); - feature_sets.insert("alternate_annotation_forms", HB_TAG('n', 'a', 'l', 't')); - feature_sets.insert("nlc_kanji_forms", HB_TAG('n', 'l', 'c', 'k')); - feature_sets.insert("nukta_forms", HB_TAG('n', 'u', 'k', 't')); - feature_sets.insert("numerators", HB_TAG('n', 'u', 'm', 'r')); - feature_sets.insert("oldstyle_figures", HB_TAG('o', 'n', 'u', 'm')); - feature_sets.insert("optical_bounds", HB_TAG('o', 'p', 'b', 'd')); - feature_sets.insert("ordinals", HB_TAG('o', 'r', 'd', 'n')); - feature_sets.insert("ornaments", HB_TAG('o', 'r', 'n', 'm')); - feature_sets.insert("proportional_alternate_widths", HB_TAG('p', 'a', 'l', 't')); - feature_sets.insert("petite_capitals", HB_TAG('p', 'c', 'a', 'p')); - feature_sets.insert("proportional_kana", HB_TAG('p', 'k', 'n', 'a')); - feature_sets.insert("proportional_figures", HB_TAG('p', 'n', 'u', 'm')); - feature_sets.insert("pre_base_forms", HB_TAG('p', 'r', 'e', 'f')); - feature_sets.insert("pre_base_substitutions", HB_TAG('p', 'r', 'e', 's')); - feature_sets.insert("post_base_forms", HB_TAG('p', 's', 't', 'f')); - feature_sets.insert("post_base_substitutions", HB_TAG('p', 's', 't', 's')); - feature_sets.insert("proportional_widths", HB_TAG('p', 'w', 'i', 'd')); - feature_sets.insert("quarter_widths", HB_TAG('q', 'w', 'i', 'd')); - feature_sets.insert("randomize", HB_TAG('r', 'a', 'n', 'd')); - feature_sets.insert("required_contextual_alternates", HB_TAG('r', 'c', 'l', 't')); - feature_sets.insert("rakar_forms", HB_TAG('r', 'k', 'r', 'f')); - feature_sets.insert("required_ligatures", HB_TAG('r', 'l', 'i', 'g')); - feature_sets.insert("reph_forms", HB_TAG('r', 'p', 'h', 'f')); - feature_sets.insert("right_bounds", HB_TAG('r', 't', 'b', 'd')); - feature_sets.insert("right_to_left_alternates", HB_TAG('r', 't', 'l', 'a')); - feature_sets.insert("right_to_left_mirrored_forms", HB_TAG('r', 't', 'l', 'm')); - feature_sets.insert("ruby_notation_forms", HB_TAG('r', 'u', 'b', 'y')); - feature_sets.insert("required_variation_alternates", HB_TAG('r', 'v', 'r', 'n')); - feature_sets.insert("stylistic_alternates", HB_TAG('s', 'a', 'l', 't')); - feature_sets.insert("scientific_inferiors", HB_TAG('s', 'i', 'n', 'f')); - feature_sets.insert("optical_size", HB_TAG('s', 'i', 'z', 'e')); - feature_sets.insert("small_capitals", HB_TAG('s', 'm', 'c', 'p')); - feature_sets.insert("simplified_forms", HB_TAG('s', 'm', 'p', 'l')); - feature_sets.insert("stylistic_set_01", HB_TAG('s', 's', '0', '1')); - feature_sets.insert("stylistic_set_02", HB_TAG('s', 's', '0', '2')); - feature_sets.insert("stylistic_set_03", HB_TAG('s', 's', '0', '3')); - feature_sets.insert("stylistic_set_04", HB_TAG('s', 's', '0', '4')); - feature_sets.insert("stylistic_set_05", HB_TAG('s', 's', '0', '5')); - feature_sets.insert("stylistic_set_06", HB_TAG('s', 's', '0', '6')); - feature_sets.insert("stylistic_set_07", HB_TAG('s', 's', '0', '7')); - feature_sets.insert("stylistic_set_08", HB_TAG('s', 's', '0', '8')); - feature_sets.insert("stylistic_set_09", HB_TAG('s', 's', '0', '9')); - feature_sets.insert("stylistic_set_10", HB_TAG('s', 's', '1', '0')); - feature_sets.insert("stylistic_set_11", HB_TAG('s', 's', '1', '1')); - feature_sets.insert("stylistic_set_12", HB_TAG('s', 's', '1', '2')); - feature_sets.insert("stylistic_set_13", HB_TAG('s', 's', '1', '3')); - feature_sets.insert("stylistic_set_14", HB_TAG('s', 's', '1', '4')); - feature_sets.insert("stylistic_set_15", HB_TAG('s', 's', '1', '5')); - feature_sets.insert("stylistic_set_16", HB_TAG('s', 's', '1', '6')); - feature_sets.insert("stylistic_set_17", HB_TAG('s', 's', '1', '7')); - feature_sets.insert("stylistic_set_18", HB_TAG('s', 's', '1', '8')); - feature_sets.insert("stylistic_set_19", HB_TAG('s', 's', '1', '9')); - feature_sets.insert("stylistic_set_20", HB_TAG('s', 's', '2', '0')); - feature_sets.insert("math_script_style_alternates", HB_TAG('s', 's', 't', 'y')); - feature_sets.insert("stretching_glyph_decomposition", HB_TAG('s', 't', 'c', 'h')); - feature_sets.insert("subscript", HB_TAG('s', 'u', 'b', 's')); - feature_sets.insert("superscript", HB_TAG('s', 'u', 'p', 's')); - feature_sets.insert("swash", HB_TAG('s', 'w', 's', 'h')); - feature_sets.insert("titling", HB_TAG('t', 'i', 't', 'l')); - feature_sets.insert("trailing_jamo_forms", HB_TAG('t', 'j', 'm', 'o')); - feature_sets.insert("traditional_name_forms", HB_TAG('t', 'n', 'a', 'm')); - feature_sets.insert("tabular_figures", HB_TAG('t', 'n', 'u', 'm')); - feature_sets.insert("traditional_forms", HB_TAG('t', 'r', 'a', 'd')); - feature_sets.insert("third_widths", HB_TAG('t', 'w', 'i', 'd')); - feature_sets.insert("unicase", HB_TAG('u', 'n', 'i', 'c')); - feature_sets.insert("alternate_vertical_metrics", HB_TAG('v', 'a', 'l', 't')); - feature_sets.insert("vattu_variants", HB_TAG('v', 'a', 't', 'u')); - feature_sets.insert("vertical_writing", HB_TAG('v', 'e', 'r', 't')); - feature_sets.insert("alternate_vertical_half_metrics", HB_TAG('v', 'h', 'a', 'l')); - feature_sets.insert("vowel_jamo_forms", HB_TAG('v', 'j', 'm', 'o')); - feature_sets.insert("vertical_kana_alternates", HB_TAG('v', 'k', 'n', 'a')); - feature_sets.insert("vertical_kerning", HB_TAG('v', 'k', 'r', 'n')); - feature_sets.insert("proportional_alternate_vertical_metrics", HB_TAG('v', 'p', 'a', 'l')); - feature_sets.insert("vertical_alternates_and_rotation", HB_TAG('v', 'r', 't', '2')); - feature_sets.insert("vertical_alternates_for_rotation", HB_TAG('v', 'r', 't', 'r')); - feature_sets.insert("slashed_zero", HB_TAG('z', 'e', 'r', 'o')); - // Registered OpenType variation tag. - feature_sets.insert("italic", HB_TAG('i', 't', 'a', 'l')); - feature_sets.insert("optical_size", HB_TAG('o', 'p', 's', 'z')); - feature_sets.insert("slant", HB_TAG('s', 'l', 'n', 't')); - feature_sets.insert("width", HB_TAG('w', 'd', 't', 'h')); - feature_sets.insert("weight", HB_TAG('w', 'g', 'h', 't')); +_FORCE_INLINE_ void TextServerAdvanced::_insert_feature(const StringName &p_name, int32_t p_tag) { + feature_sets.insert(p_name, p_tag); + feature_sets_inv.insert(p_tag, p_name); } -int32_t TextServerAdvanced::name_to_tag(const String &p_name) const { +void TextServerAdvanced::_insert_feature_sets() { + // Registered OpenType feature tags. + _insert_feature("access_all_alternates", HB_TAG('a', 'a', 'l', 't')); + _insert_feature("above_base_forms", HB_TAG('a', 'b', 'v', 'f')); + _insert_feature("above_base_mark_positioning", HB_TAG('a', 'b', 'v', 'm')); + _insert_feature("above_base_substitutions", HB_TAG('a', 'b', 'v', 's')); + _insert_feature("alternative_fractions", HB_TAG('a', 'f', 'r', 'c')); + _insert_feature("akhands", HB_TAG('a', 'k', 'h', 'n')); + _insert_feature("below_base_forms", HB_TAG('b', 'l', 'w', 'f')); + _insert_feature("below_base_mark_positioning", HB_TAG('b', 'l', 'w', 'm')); + _insert_feature("below_base_substitutions", HB_TAG('b', 'l', 'w', 's')); + _insert_feature("contextual_alternates", HB_TAG('c', 'a', 'l', 't')); + _insert_feature("case_sensitive_forms", HB_TAG('c', 'a', 's', 'e')); + _insert_feature("glyph_composition", HB_TAG('c', 'c', 'm', 'p')); + _insert_feature("conjunct_form_after_ro", HB_TAG('c', 'f', 'a', 'r')); + _insert_feature("conjunct_forms", HB_TAG('c', 'j', 'c', 't')); + _insert_feature("contextual_ligatures", HB_TAG('c', 'l', 'i', 'g')); + _insert_feature("centered_cjk_punctuation", HB_TAG('c', 'p', 'c', 't')); + _insert_feature("capital_spacing", HB_TAG('c', 'p', 's', 'p')); + _insert_feature("contextual_swash", HB_TAG('c', 's', 'w', 'h')); + _insert_feature("cursive_positioning", HB_TAG('c', 'u', 'r', 's')); + _insert_feature("character_variant_01", HB_TAG('c', 'v', '0', '1')); + _insert_feature("character_variant_02", HB_TAG('c', 'v', '0', '2')); + _insert_feature("character_variant_03", HB_TAG('c', 'v', '0', '3')); + _insert_feature("character_variant_04", HB_TAG('c', 'v', '0', '4')); + _insert_feature("character_variant_05", HB_TAG('c', 'v', '0', '5')); + _insert_feature("character_variant_06", HB_TAG('c', 'v', '0', '6')); + _insert_feature("character_variant_07", HB_TAG('c', 'v', '0', '7')); + _insert_feature("character_variant_08", HB_TAG('c', 'v', '0', '8')); + _insert_feature("character_variant_09", HB_TAG('c', 'v', '0', '9')); + _insert_feature("character_variant_10", HB_TAG('c', 'v', '1', '0')); + _insert_feature("character_variant_11", HB_TAG('c', 'v', '1', '1')); + _insert_feature("character_variant_12", HB_TAG('c', 'v', '1', '2')); + _insert_feature("character_variant_13", HB_TAG('c', 'v', '1', '3')); + _insert_feature("character_variant_14", HB_TAG('c', 'v', '1', '4')); + _insert_feature("character_variant_15", HB_TAG('c', 'v', '1', '5')); + _insert_feature("character_variant_16", HB_TAG('c', 'v', '1', '6')); + _insert_feature("character_variant_17", HB_TAG('c', 'v', '1', '7')); + _insert_feature("character_variant_18", HB_TAG('c', 'v', '1', '8')); + _insert_feature("character_variant_19", HB_TAG('c', 'v', '1', '9')); + _insert_feature("character_variant_20", HB_TAG('c', 'v', '2', '0')); + _insert_feature("character_variant_21", HB_TAG('c', 'v', '2', '1')); + _insert_feature("character_variant_22", HB_TAG('c', 'v', '2', '2')); + _insert_feature("character_variant_23", HB_TAG('c', 'v', '2', '3')); + _insert_feature("character_variant_24", HB_TAG('c', 'v', '2', '4')); + _insert_feature("character_variant_25", HB_TAG('c', 'v', '2', '5')); + _insert_feature("character_variant_26", HB_TAG('c', 'v', '2', '6')); + _insert_feature("character_variant_27", HB_TAG('c', 'v', '2', '7')); + _insert_feature("character_variant_28", HB_TAG('c', 'v', '2', '8')); + _insert_feature("character_variant_29", HB_TAG('c', 'v', '2', '9')); + _insert_feature("character_variant_30", HB_TAG('c', 'v', '3', '0')); + _insert_feature("character_variant_31", HB_TAG('c', 'v', '3', '1')); + _insert_feature("character_variant_32", HB_TAG('c', 'v', '3', '2')); + _insert_feature("character_variant_33", HB_TAG('c', 'v', '3', '3')); + _insert_feature("character_variant_34", HB_TAG('c', 'v', '3', '4')); + _insert_feature("character_variant_35", HB_TAG('c', 'v', '3', '5')); + _insert_feature("character_variant_36", HB_TAG('c', 'v', '3', '6')); + _insert_feature("character_variant_37", HB_TAG('c', 'v', '3', '7')); + _insert_feature("character_variant_38", HB_TAG('c', 'v', '3', '8')); + _insert_feature("character_variant_39", HB_TAG('c', 'v', '3', '9')); + _insert_feature("character_variant_40", HB_TAG('c', 'v', '4', '0')); + _insert_feature("character_variant_41", HB_TAG('c', 'v', '4', '1')); + _insert_feature("character_variant_42", HB_TAG('c', 'v', '4', '2')); + _insert_feature("character_variant_43", HB_TAG('c', 'v', '4', '3')); + _insert_feature("character_variant_44", HB_TAG('c', 'v', '4', '4')); + _insert_feature("character_variant_45", HB_TAG('c', 'v', '4', '5')); + _insert_feature("character_variant_46", HB_TAG('c', 'v', '4', '6')); + _insert_feature("character_variant_47", HB_TAG('c', 'v', '4', '7')); + _insert_feature("character_variant_48", HB_TAG('c', 'v', '4', '8')); + _insert_feature("character_variant_49", HB_TAG('c', 'v', '4', '9')); + _insert_feature("character_variant_50", HB_TAG('c', 'v', '5', '0')); + _insert_feature("character_variant_51", HB_TAG('c', 'v', '5', '1')); + _insert_feature("character_variant_52", HB_TAG('c', 'v', '5', '2')); + _insert_feature("character_variant_53", HB_TAG('c', 'v', '5', '3')); + _insert_feature("character_variant_54", HB_TAG('c', 'v', '5', '4')); + _insert_feature("character_variant_55", HB_TAG('c', 'v', '5', '5')); + _insert_feature("character_variant_56", HB_TAG('c', 'v', '5', '6')); + _insert_feature("character_variant_57", HB_TAG('c', 'v', '5', '7')); + _insert_feature("character_variant_58", HB_TAG('c', 'v', '5', '8')); + _insert_feature("character_variant_59", HB_TAG('c', 'v', '5', '9')); + _insert_feature("character_variant_60", HB_TAG('c', 'v', '6', '0')); + _insert_feature("character_variant_61", HB_TAG('c', 'v', '6', '1')); + _insert_feature("character_variant_62", HB_TAG('c', 'v', '6', '2')); + _insert_feature("character_variant_63", HB_TAG('c', 'v', '6', '3')); + _insert_feature("character_variant_64", HB_TAG('c', 'v', '6', '4')); + _insert_feature("character_variant_65", HB_TAG('c', 'v', '6', '5')); + _insert_feature("character_variant_66", HB_TAG('c', 'v', '6', '6')); + _insert_feature("character_variant_67", HB_TAG('c', 'v', '6', '7')); + _insert_feature("character_variant_68", HB_TAG('c', 'v', '6', '8')); + _insert_feature("character_variant_69", HB_TAG('c', 'v', '6', '9')); + _insert_feature("character_variant_70", HB_TAG('c', 'v', '7', '0')); + _insert_feature("character_variant_71", HB_TAG('c', 'v', '7', '1')); + _insert_feature("character_variant_72", HB_TAG('c', 'v', '7', '2')); + _insert_feature("character_variant_73", HB_TAG('c', 'v', '7', '3')); + _insert_feature("character_variant_74", HB_TAG('c', 'v', '7', '4')); + _insert_feature("character_variant_75", HB_TAG('c', 'v', '7', '5')); + _insert_feature("character_variant_76", HB_TAG('c', 'v', '7', '6')); + _insert_feature("character_variant_77", HB_TAG('c', 'v', '7', '7')); + _insert_feature("character_variant_78", HB_TAG('c', 'v', '7', '8')); + _insert_feature("character_variant_79", HB_TAG('c', 'v', '7', '9')); + _insert_feature("character_variant_80", HB_TAG('c', 'v', '8', '0')); + _insert_feature("character_variant_81", HB_TAG('c', 'v', '8', '1')); + _insert_feature("character_variant_82", HB_TAG('c', 'v', '8', '2')); + _insert_feature("character_variant_83", HB_TAG('c', 'v', '8', '3')); + _insert_feature("character_variant_84", HB_TAG('c', 'v', '8', '4')); + _insert_feature("character_variant_85", HB_TAG('c', 'v', '8', '5')); + _insert_feature("character_variant_86", HB_TAG('c', 'v', '8', '6')); + _insert_feature("character_variant_87", HB_TAG('c', 'v', '8', '7')); + _insert_feature("character_variant_88", HB_TAG('c', 'v', '8', '8')); + _insert_feature("character_variant_89", HB_TAG('c', 'v', '8', '9')); + _insert_feature("character_variant_90", HB_TAG('c', 'v', '9', '0')); + _insert_feature("character_variant_91", HB_TAG('c', 'v', '9', '1')); + _insert_feature("character_variant_92", HB_TAG('c', 'v', '9', '2')); + _insert_feature("character_variant_93", HB_TAG('c', 'v', '9', '3')); + _insert_feature("character_variant_94", HB_TAG('c', 'v', '9', '4')); + _insert_feature("character_variant_95", HB_TAG('c', 'v', '9', '5')); + _insert_feature("character_variant_96", HB_TAG('c', 'v', '9', '6')); + _insert_feature("character_variant_97", HB_TAG('c', 'v', '9', '7')); + _insert_feature("character_variant_98", HB_TAG('c', 'v', '9', '8')); + _insert_feature("character_variant_99", HB_TAG('c', 'v', '9', '9')); + _insert_feature("petite_capitals_from_capitals", HB_TAG('c', '2', 'p', 'c')); + _insert_feature("small_capitals_from_capitals", HB_TAG('c', '2', 's', 'c')); + _insert_feature("distances", HB_TAG('d', 'i', 's', 't')); + _insert_feature("discretionary_ligatures", HB_TAG('d', 'l', 'i', 'g')); + _insert_feature("denominators", HB_TAG('d', 'n', 'o', 'm')); + _insert_feature("dotless_forms", HB_TAG('d', 't', 'l', 's')); + _insert_feature("expert_forms", HB_TAG('e', 'x', 'p', 't')); + _insert_feature("final_glyph_on_line_alternates", HB_TAG('f', 'a', 'l', 't')); + _insert_feature("terminal_forms_2", HB_TAG('f', 'i', 'n', '2')); + _insert_feature("terminal_forms_3", HB_TAG('f', 'i', 'n', '3')); + _insert_feature("terminal_forms", HB_TAG('f', 'i', 'n', 'a')); + _insert_feature("flattened_accent_forms", HB_TAG('f', 'l', 'a', 'c')); + _insert_feature("fractions", HB_TAG('f', 'r', 'a', 'c')); + _insert_feature("full_widths", HB_TAG('f', 'w', 'i', 'd')); + _insert_feature("half_forms", HB_TAG('h', 'a', 'l', 'f')); + _insert_feature("halant_forms", HB_TAG('h', 'a', 'l', 'n')); + _insert_feature("alternate_half_widths", HB_TAG('h', 'a', 'l', 't')); + _insert_feature("historical_forms", HB_TAG('h', 'i', 's', 't')); + _insert_feature("horizontal_kana_alternates", HB_TAG('h', 'k', 'n', 'a')); + _insert_feature("historical_ligatures", HB_TAG('h', 'l', 'i', 'g')); + _insert_feature("hangul", HB_TAG('h', 'n', 'g', 'l')); + _insert_feature("hojo_kanji_forms", HB_TAG('h', 'o', 'j', 'o')); + _insert_feature("half_widths", HB_TAG('h', 'w', 'i', 'd')); + _insert_feature("initial_forms", HB_TAG('i', 'n', 'i', 't')); + _insert_feature("isolated_forms", HB_TAG('i', 's', 'o', 'l')); + _insert_feature("italics", HB_TAG('i', 't', 'a', 'l')); + _insert_feature("justification_alternates", HB_TAG('j', 'a', 'l', 't')); + _insert_feature("jis78_forms", HB_TAG('j', 'p', '7', '8')); + _insert_feature("jis83_forms", HB_TAG('j', 'p', '8', '3')); + _insert_feature("jis90_forms", HB_TAG('j', 'p', '9', '0')); + _insert_feature("jis2004_forms", HB_TAG('j', 'p', '0', '4')); + _insert_feature("kerning", HB_TAG('k', 'e', 'r', 'n')); + _insert_feature("left_bounds", HB_TAG('l', 'f', 'b', 'd')); + _insert_feature("standard_ligatures", HB_TAG('l', 'i', 'g', 'a')); + _insert_feature("leading_jamo_forms", HB_TAG('l', 'j', 'm', 'o')); + _insert_feature("lining_figures", HB_TAG('l', 'n', 'u', 'm')); + _insert_feature("localized_forms", HB_TAG('l', 'o', 'c', 'l')); + _insert_feature("left_to_right_alternates", HB_TAG('l', 't', 'r', 'a')); + _insert_feature("left_to_right_mirrored_forms", HB_TAG('l', 't', 'r', 'm')); + _insert_feature("mark_positioning", HB_TAG('m', 'a', 'r', 'k')); + _insert_feature("medial_forms_2", HB_TAG('m', 'e', 'd', '2')); + _insert_feature("medial_forms", HB_TAG('m', 'e', 'd', 'i')); + _insert_feature("mathematical_greek", HB_TAG('m', 'g', 'r', 'k')); + _insert_feature("mark_to_mark_positioning", HB_TAG('m', 'k', 'm', 'k')); + _insert_feature("mark_positioning_via_substitution", HB_TAG('m', 's', 'e', 't')); + _insert_feature("alternate_annotation_forms", HB_TAG('n', 'a', 'l', 't')); + _insert_feature("nlc_kanji_forms", HB_TAG('n', 'l', 'c', 'k')); + _insert_feature("nukta_forms", HB_TAG('n', 'u', 'k', 't')); + _insert_feature("numerators", HB_TAG('n', 'u', 'm', 'r')); + _insert_feature("oldstyle_figures", HB_TAG('o', 'n', 'u', 'm')); + _insert_feature("optical_bounds", HB_TAG('o', 'p', 'b', 'd')); + _insert_feature("ordinals", HB_TAG('o', 'r', 'd', 'n')); + _insert_feature("ornaments", HB_TAG('o', 'r', 'n', 'm')); + _insert_feature("proportional_alternate_widths", HB_TAG('p', 'a', 'l', 't')); + _insert_feature("petite_capitals", HB_TAG('p', 'c', 'a', 'p')); + _insert_feature("proportional_kana", HB_TAG('p', 'k', 'n', 'a')); + _insert_feature("proportional_figures", HB_TAG('p', 'n', 'u', 'm')); + _insert_feature("pre_base_forms", HB_TAG('p', 'r', 'e', 'f')); + _insert_feature("pre_base_substitutions", HB_TAG('p', 'r', 'e', 's')); + _insert_feature("post_base_forms", HB_TAG('p', 's', 't', 'f')); + _insert_feature("post_base_substitutions", HB_TAG('p', 's', 't', 's')); + _insert_feature("proportional_widths", HB_TAG('p', 'w', 'i', 'd')); + _insert_feature("quarter_widths", HB_TAG('q', 'w', 'i', 'd')); + _insert_feature("randomize", HB_TAG('r', 'a', 'n', 'd')); + _insert_feature("required_contextual_alternates", HB_TAG('r', 'c', 'l', 't')); + _insert_feature("rakar_forms", HB_TAG('r', 'k', 'r', 'f')); + _insert_feature("required_ligatures", HB_TAG('r', 'l', 'i', 'g')); + _insert_feature("reph_forms", HB_TAG('r', 'p', 'h', 'f')); + _insert_feature("right_bounds", HB_TAG('r', 't', 'b', 'd')); + _insert_feature("right_to_left_alternates", HB_TAG('r', 't', 'l', 'a')); + _insert_feature("right_to_left_mirrored_forms", HB_TAG('r', 't', 'l', 'm')); + _insert_feature("ruby_notation_forms", HB_TAG('r', 'u', 'b', 'y')); + _insert_feature("required_variation_alternates", HB_TAG('r', 'v', 'r', 'n')); + _insert_feature("stylistic_alternates", HB_TAG('s', 'a', 'l', 't')); + _insert_feature("scientific_inferiors", HB_TAG('s', 'i', 'n', 'f')); + _insert_feature("optical_size", HB_TAG('s', 'i', 'z', 'e')); + _insert_feature("small_capitals", HB_TAG('s', 'm', 'c', 'p')); + _insert_feature("simplified_forms", HB_TAG('s', 'm', 'p', 'l')); + _insert_feature("stylistic_set_01", HB_TAG('s', 's', '0', '1')); + _insert_feature("stylistic_set_02", HB_TAG('s', 's', '0', '2')); + _insert_feature("stylistic_set_03", HB_TAG('s', 's', '0', '3')); + _insert_feature("stylistic_set_04", HB_TAG('s', 's', '0', '4')); + _insert_feature("stylistic_set_05", HB_TAG('s', 's', '0', '5')); + _insert_feature("stylistic_set_06", HB_TAG('s', 's', '0', '6')); + _insert_feature("stylistic_set_07", HB_TAG('s', 's', '0', '7')); + _insert_feature("stylistic_set_08", HB_TAG('s', 's', '0', '8')); + _insert_feature("stylistic_set_09", HB_TAG('s', 's', '0', '9')); + _insert_feature("stylistic_set_10", HB_TAG('s', 's', '1', '0')); + _insert_feature("stylistic_set_11", HB_TAG('s', 's', '1', '1')); + _insert_feature("stylistic_set_12", HB_TAG('s', 's', '1', '2')); + _insert_feature("stylistic_set_13", HB_TAG('s', 's', '1', '3')); + _insert_feature("stylistic_set_14", HB_TAG('s', 's', '1', '4')); + _insert_feature("stylistic_set_15", HB_TAG('s', 's', '1', '5')); + _insert_feature("stylistic_set_16", HB_TAG('s', 's', '1', '6')); + _insert_feature("stylistic_set_17", HB_TAG('s', 's', '1', '7')); + _insert_feature("stylistic_set_18", HB_TAG('s', 's', '1', '8')); + _insert_feature("stylistic_set_19", HB_TAG('s', 's', '1', '9')); + _insert_feature("stylistic_set_20", HB_TAG('s', 's', '2', '0')); + _insert_feature("math_script_style_alternates", HB_TAG('s', 's', 't', 'y')); + _insert_feature("stretching_glyph_decomposition", HB_TAG('s', 't', 'c', 'h')); + _insert_feature("subscript", HB_TAG('s', 'u', 'b', 's')); + _insert_feature("superscript", HB_TAG('s', 'u', 'p', 's')); + _insert_feature("swash", HB_TAG('s', 'w', 's', 'h')); + _insert_feature("titling", HB_TAG('t', 'i', 't', 'l')); + _insert_feature("trailing_jamo_forms", HB_TAG('t', 'j', 'm', 'o')); + _insert_feature("traditional_name_forms", HB_TAG('t', 'n', 'a', 'm')); + _insert_feature("tabular_figures", HB_TAG('t', 'n', 'u', 'm')); + _insert_feature("traditional_forms", HB_TAG('t', 'r', 'a', 'd')); + _insert_feature("third_widths", HB_TAG('t', 'w', 'i', 'd')); + _insert_feature("unicase", HB_TAG('u', 'n', 'i', 'c')); + _insert_feature("alternate_vertical_metrics", HB_TAG('v', 'a', 'l', 't')); + _insert_feature("vattu_variants", HB_TAG('v', 'a', 't', 'u')); + _insert_feature("vertical_writing", HB_TAG('v', 'e', 'r', 't')); + _insert_feature("alternate_vertical_half_metrics", HB_TAG('v', 'h', 'a', 'l')); + _insert_feature("vowel_jamo_forms", HB_TAG('v', 'j', 'm', 'o')); + _insert_feature("vertical_kana_alternates", HB_TAG('v', 'k', 'n', 'a')); + _insert_feature("vertical_kerning", HB_TAG('v', 'k', 'r', 'n')); + _insert_feature("proportional_alternate_vertical_metrics", HB_TAG('v', 'p', 'a', 'l')); + _insert_feature("vertical_alternates_and_rotation", HB_TAG('v', 'r', 't', '2')); + _insert_feature("vertical_alternates_for_rotation", HB_TAG('v', 'r', 't', 'r')); + _insert_feature("slashed_zero", HB_TAG('z', 'e', 'r', 'o')); + + // Registered OpenType variation tag. + _insert_feature("italic", HB_TAG('i', 't', 'a', 'l')); + _insert_feature("optical_size", HB_TAG('o', 'p', 's', 'z')); + _insert_feature("slant", HB_TAG('s', 'l', 'n', 't')); + _insert_feature("width", HB_TAG('w', 'd', 't', 'h')); + _insert_feature("weight", HB_TAG('w', 'g', 'h', 't')); +} + +int64_t TextServerAdvanced::name_to_tag(const String &p_name) const { if (feature_sets.has(p_name)) { return feature_sets[p_name]; } @@ -686,11 +742,9 @@ int32_t TextServerAdvanced::name_to_tag(const String &p_name) const { return hb_tag_from_string(p_name.replace("custom_", "").ascii().get_data(), -1); } -String TextServerAdvanced::tag_to_name(int32_t p_tag) const { - for (const KeyValue &E : feature_sets) { - if (E.value == p_tag) { - return E.key; - } +String TextServerAdvanced::tag_to_name(int64_t p_tag) const { + if (feature_sets_inv.has(p_tag)) { + return feature_sets_inv[p_tag]; } // No readable name, use tag string. @@ -728,7 +782,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_ continue; } - ret.y = 0x7FFFFFFF; + ret.y = 0x7fffffff; ret.x = 0; for (int j = 0; j < ct.texture_w - mw; j++) { @@ -747,7 +801,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_ } } - if (ret.y == 0x7FFFFFFF || ret.y + mh > ct.texture_h) { + if (ret.y == 0x7fffffff || ret.y + mh > ct.texture_h) { continue; // Fail, could not fit it here. } @@ -768,7 +822,11 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_ texsize = mh; // Special case, adapt to it? } +#ifdef GDEXTENSION + texsize = Math::next_power_of_2(texsize); +#else texsize = next_power_of_2(texsize); +#endif if (p_msdf) { texsize = MIN(texsize, 2048); } else { @@ -804,8 +862,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_ } } tex.offsets.resize(texsize); + int32_t *offw = tex.offsets.ptrw(); for (int i = 0; i < texsize; i++) { // Zero offsets. - tex.offsets.write[i] = 0; + offw[i] = 0; } p_data->textures.push_back(tex); @@ -983,7 +1042,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf( // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, Image::FORMAT_RGBA8, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, Image::FORMAT_RGBA8, tex.imgdata); if (tex.texture.is_null()) { tex.texture.instantiate(); tex.texture->create_from_image(img); @@ -994,8 +1055,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf( } // Update height array. + int32_t *offw = tex.offsets.ptrw(); for (int k = tex_pos.x; k < tex_pos.x + mw; k++) { - tex.offsets.write[k] = tex_pos.y + mh; + offw[k] = tex_pos.y + mh; } chr.texture_idx = tex_pos.index; @@ -1055,7 +1117,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma wr[ofs + 3] = bitmap.buffer[ofs_color + 3]; } break; default: - ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + itos(bitmap.pixel_mode) + "."); + ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(bitmap.pixel_mode) + "."); break; } } @@ -1065,7 +1127,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, require_format, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, require_format, tex.imgdata); if (tex.texture.is_null()) { tex.texture.instantiate(); @@ -1077,8 +1141,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma } // Update height array. + int32_t *offw = tex.offsets.ptrw(); for (int k = tex_pos.x; k < tex_pos.x + mw; k++) { - tex.offsets.write[k] = tex_pos.y + mh; + offw[k] = tex_pos.y + mh; } FontGlyph chr; @@ -1100,7 +1165,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma _FORCE_INLINE_ bool TextServerAdvanced::_ensure_glyph(FontDataAdvanced *p_font_data, const Vector2i &p_size, int32_t p_glyph) const { ERR_FAIL_COND_V(!_ensure_cache_for_size(p_font_data, p_size), false); - int32_t glyph_index = p_glyph & 0xFFFFFF; // Remove subpixel shifts. + int32_t glyph_index = p_glyph & 0xffffff; // Remove subpixel shifts. FontDataForSizeAdvanced *fd = p_font_data->cache[p_size]; if (fd->glyph_map.has(p_glyph)) { @@ -1187,7 +1252,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_glyph(FontDataAdvanced *p_font_d } } else { FT_Stroker stroker; - if (FT_Stroker_New(library, &stroker) != 0) { + if (FT_Stroker_New(ft_library, &stroker) != 0) { fd->glyph_map[p_glyph] = FontGlyph(); ERR_FAIL_V_MSG(false, "FreeType: Failed to load glyph stroker."); } @@ -1233,8 +1298,8 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced // Init dynamic font. #ifdef MODULE_FREETYPE_ENABLED int error = 0; - if (!library) { - error = FT_Init_FreeType(&library); + if (!ft_library) { + error = FT_Init_FreeType(&ft_library); ERR_FAIL_COND_V_MSG(error != 0, false, "FreeType: Error initializing library: '" + String(FT_Error_String(error)) + "'."); } @@ -1249,7 +1314,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced fargs.memory_size = p_font_data->data_size; fargs.flags = FT_OPEN_MEMORY; fargs.stream = &fd->stream; - error = FT_Open_Face(library, &fargs, 0, &fd->face); + error = FT_Open_Face(ft_library, &fargs, 0, &fd->face); if (error) { FT_Done_Face(fd->face); fd->face = nullptr; @@ -1257,9 +1322,9 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced } if (p_font_data->msdf) { - fd->oversampling = 1.0f; + fd->oversampling = 1.0; fd->size.x = p_font_data->msdf_source_size; - } else if (p_font_data->oversampling <= 0.0f) { + } else if (p_font_data->oversampling <= 0.0) { fd->oversampling = font_get_global_oversampling(); } else { fd->oversampling = p_font_data->oversampling; @@ -1268,19 +1333,19 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced if (FT_HAS_COLOR(fd->face) && fd->face->num_fixed_sizes > 0) { int best_match = 0; int diff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[0].width)); - fd->scale = float(fd->size.x * fd->oversampling) / fd->face->available_sizes[0].width; + fd->scale = double(fd->size.x * fd->oversampling) / fd->face->available_sizes[0].width; for (int i = 1; i < fd->face->num_fixed_sizes; i++) { int ndiff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[i].width)); if (ndiff < diff) { best_match = i; diff = ndiff; - fd->scale = float(fd->size.x * fd->oversampling) / fd->face->available_sizes[i].width; + fd->scale = double(fd->size.x * fd->oversampling) / fd->face->available_sizes[i].width; } } FT_Select_Size(fd->face, best_match); } else { - FT_Set_Pixel_Sizes(fd->face, 0, float(fd->size.x * fd->oversampling)); - fd->scale = ((float)fd->size.x * fd->oversampling) / (float)fd->face->size->metrics.y_ppem; + FT_Set_Pixel_Sizes(fd->face, 0, double(fd->size.x * fd->oversampling)); + fd->scale = ((double)fd->size.x * fd->oversampling) / (double)fd->face->size->metrics.y_ppem; } fd->hb_handle = hb_ft_font_create(fd->face, nullptr); @@ -1573,7 +1638,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced for (FT_UInt i = 0; i < amaster->num_axis; i++) { p_font_data->supported_varaitions[(int32_t)amaster->axis[i].tag] = Vector3i(amaster->axis[i].minimum / 65536, amaster->axis[i].maximum / 65536, amaster->axis[i].def / 65536); } - FT_Done_MM_Var(library, amaster); + FT_Done_MM_Var(ft_library, amaster); } p_font_data->face_init = true; } @@ -1595,17 +1660,17 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced // Reset to default. var.tag = amaster->axis[i].tag; - var.value = (double)amaster->axis[i].def / 65536.f; + var.value = (double)amaster->axis[i].def / 65536.0; coords.write[i] = amaster->axis[i].def; if (p_font_data->variation_coordinates.has(var.tag)) { var.value = p_font_data->variation_coordinates[var.tag]; - coords.write[i] = CLAMP(var.value * 65536.f, amaster->axis[i].minimum, amaster->axis[i].maximum); + coords.write[i] = CLAMP(var.value * 65536.0, amaster->axis[i].minimum, amaster->axis[i].maximum); } if (p_font_data->variation_coordinates.has(tag_to_name(var.tag))) { var.value = p_font_data->variation_coordinates[tag_to_name(var.tag)]; - coords.write[i] = CLAMP(var.value * 65536.f, amaster->axis[i].minimum, amaster->axis[i].maximum); + coords.write[i] = CLAMP(var.value * 65536.0, amaster->axis[i].minimum, amaster->axis[i].maximum); } hb_vars.push_back(var); @@ -1613,7 +1678,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced FT_Set_Var_Design_Coordinates(fd->face, coords.size(), coords.ptrw()); hb_font_set_variations(fd->hb_handle, hb_vars.is_empty() ? nullptr : &hb_vars[0], hb_vars.size()); - FT_Done_MM_Var(library, amaster); + FT_Done_MM_Var(ft_library, amaster); } #else ERR_FAIL_V_MSG(false, "FreeType: Can't load dynamic font, engine is compiled without FreeType support!"); @@ -1637,7 +1702,7 @@ _FORCE_INLINE_ void TextServerAdvanced::_font_clear_cache(FontDataAdvanced *p_fo p_font_data->supported_scripts.clear(); } -hb_font_t *TextServerAdvanced::_font_get_hb_handle(RID p_font_rid, int p_size) const { +hb_font_t *TextServerAdvanced::_font_get_hb_handle(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, nullptr); @@ -1655,7 +1720,7 @@ RID TextServerAdvanced::create_font() { return font_owner.make_rid(fd); } -void TextServerAdvanced::font_set_data(RID p_font_rid, const PackedByteArray &p_data) { +void TextServerAdvanced::font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1666,18 +1731,18 @@ void TextServerAdvanced::font_set_data(RID p_font_rid, const PackedByteArray &p_ fd->data_size = fd->data.size(); } -void TextServerAdvanced::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) { +void TextServerAdvanced::font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); _font_clear_cache(fd); - fd->data.clear(); + fd->data.resize(0); fd->data_ptr = p_data_ptr; fd->data_size = p_data_size; } -void TextServerAdvanced::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { +void TextServerAdvanced::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1687,7 +1752,7 @@ void TextServerAdvanced::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p fd->style_flags = p_style; } -uint32_t /*FontStyle*/ TextServerAdvanced::font_get_style(RID p_font_rid) const { +int64_t /*FontStyle*/ TextServerAdvanced::font_get_style(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -1697,7 +1762,7 @@ uint32_t /*FontStyle*/ TextServerAdvanced::font_get_style(RID p_font_rid) const return fd->style_flags; } -void TextServerAdvanced::font_set_style_name(RID p_font_rid, const String &p_name) { +void TextServerAdvanced::font_set_style_name(const RID &p_font_rid, const String &p_name) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1707,7 +1772,7 @@ void TextServerAdvanced::font_set_style_name(RID p_font_rid, const String &p_nam fd->style_name = p_name; } -String TextServerAdvanced::font_get_style_name(RID p_font_rid) const { +String TextServerAdvanced::font_get_style_name(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -1717,7 +1782,7 @@ String TextServerAdvanced::font_get_style_name(RID p_font_rid) const { return fd->style_name; } -void TextServerAdvanced::font_set_name(RID p_font_rid, const String &p_name) { +void TextServerAdvanced::font_set_name(const RID &p_font_rid, const String &p_name) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1727,7 +1792,7 @@ void TextServerAdvanced::font_set_name(RID p_font_rid, const String &p_name) { fd->font_name = p_name; } -String TextServerAdvanced::font_get_name(RID p_font_rid) const { +String TextServerAdvanced::font_get_name(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -1737,7 +1802,7 @@ String TextServerAdvanced::font_get_name(RID p_font_rid) const { return fd->font_name; } -void TextServerAdvanced::font_set_antialiased(RID p_font_rid, bool p_antialiased) { +void TextServerAdvanced::font_set_antialiased(const RID &p_font_rid, bool p_antialiased) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1748,7 +1813,7 @@ void TextServerAdvanced::font_set_antialiased(RID p_font_rid, bool p_antialiased } } -bool TextServerAdvanced::font_is_antialiased(RID p_font_rid) const { +bool TextServerAdvanced::font_is_antialiased(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1756,7 +1821,7 @@ bool TextServerAdvanced::font_is_antialiased(RID p_font_rid) const { return fd->antialiased; } -void TextServerAdvanced::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) { +void TextServerAdvanced::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1767,7 +1832,7 @@ void TextServerAdvanced::font_set_multichannel_signed_distance_field(RID p_font_ } } -bool TextServerAdvanced::font_is_multichannel_signed_distance_field(RID p_font_rid) const { +bool TextServerAdvanced::font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1775,7 +1840,7 @@ bool TextServerAdvanced::font_is_multichannel_signed_distance_field(RID p_font_r return fd->msdf; } -void TextServerAdvanced::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) { +void TextServerAdvanced::font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1786,7 +1851,7 @@ void TextServerAdvanced::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pi } } -int TextServerAdvanced::font_get_msdf_pixel_range(RID p_font_rid) const { +int64_t TextServerAdvanced::font_get_msdf_pixel_range(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1794,7 +1859,7 @@ int TextServerAdvanced::font_get_msdf_pixel_range(RID p_font_rid) const { return fd->msdf_range; } -void TextServerAdvanced::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { +void TextServerAdvanced::font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1805,7 +1870,7 @@ void TextServerAdvanced::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { } } -int TextServerAdvanced::font_get_msdf_size(RID p_font_rid) const { +int64_t TextServerAdvanced::font_get_msdf_size(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1813,7 +1878,7 @@ int TextServerAdvanced::font_get_msdf_size(RID p_font_rid) const { return fd->msdf_source_size; } -void TextServerAdvanced::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { +void TextServerAdvanced::font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1823,7 +1888,7 @@ void TextServerAdvanced::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { } } -int TextServerAdvanced::font_get_fixed_size(RID p_font_rid) const { +int64_t TextServerAdvanced::font_get_fixed_size(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1831,7 +1896,7 @@ int TextServerAdvanced::font_get_fixed_size(RID p_font_rid) const { return fd->fixed_size; } -void TextServerAdvanced::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) { +void TextServerAdvanced::font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1842,7 +1907,7 @@ void TextServerAdvanced::font_set_force_autohinter(RID p_font_rid, bool p_force_ } } -bool TextServerAdvanced::font_is_force_autohinter(RID p_font_rid) const { +bool TextServerAdvanced::font_is_force_autohinter(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1850,7 +1915,7 @@ bool TextServerAdvanced::font_is_force_autohinter(RID p_font_rid) const { return fd->force_autohinter; } -void TextServerAdvanced::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) { +void TextServerAdvanced::font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1861,7 +1926,7 @@ void TextServerAdvanced::font_set_hinting(RID p_font_rid, TextServer::Hinting p_ } } -TextServer::Hinting TextServerAdvanced::font_get_hinting(RID p_font_rid) const { +TextServer::Hinting TextServerAdvanced::font_get_hinting(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, HINTING_NONE); @@ -1869,7 +1934,7 @@ TextServer::Hinting TextServerAdvanced::font_get_hinting(RID p_font_rid) const { return fd->hinting; } -void TextServerAdvanced::font_set_subpixel_positioning(RID p_font_rid, TextServer::SubpixelPositioning p_subpixel) { +void TextServerAdvanced::font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1879,7 +1944,7 @@ void TextServerAdvanced::font_set_subpixel_positioning(RID p_font_rid, TextServe } } -TextServer::SubpixelPositioning TextServerAdvanced::font_get_subpixel_positioning(RID p_font_rid) const { +TextServer::SubpixelPositioning TextServerAdvanced::font_get_subpixel_positioning(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, SUBPIXEL_POSITIONING_DISABLED); @@ -1887,7 +1952,7 @@ TextServer::SubpixelPositioning TextServerAdvanced::font_get_subpixel_positionin return fd->subpixel_positioning; } -void TextServerAdvanced::font_set_embolden(RID p_font_rid, float p_strength) { +void TextServerAdvanced::font_set_embolden(const RID &p_font_rid, double p_strength) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1898,15 +1963,15 @@ void TextServerAdvanced::font_set_embolden(RID p_font_rid, float p_strength) { } } -float TextServerAdvanced::font_get_embolden(RID p_font_rid) const { +double TextServerAdvanced::font_get_embolden(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); return fd->embolden; } -void TextServerAdvanced::font_set_transform(RID p_font_rid, Transform2D p_transform) { +void TextServerAdvanced::font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1917,7 +1982,7 @@ void TextServerAdvanced::font_set_transform(RID p_font_rid, Transform2D p_transf } } -Transform2D TextServerAdvanced::font_get_transform(RID p_font_rid) const { +Transform2D TextServerAdvanced::font_get_transform(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Transform2D()); @@ -1925,7 +1990,7 @@ Transform2D TextServerAdvanced::font_get_transform(RID p_font_rid) const { return fd->transform; } -void TextServerAdvanced::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) { +void TextServerAdvanced::font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1936,7 +2001,7 @@ void TextServerAdvanced::font_set_variation_coordinates(RID p_font_rid, const Di } } -Dictionary TextServerAdvanced::font_get_variation_coordinates(RID p_font_rid) const { +Dictionary TextServerAdvanced::font_get_variation_coordinates(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -1944,7 +2009,7 @@ Dictionary TextServerAdvanced::font_get_variation_coordinates(RID p_font_rid) co return fd->variation_coordinates; } -void TextServerAdvanced::font_set_oversampling(RID p_font_rid, float p_oversampling) { +void TextServerAdvanced::font_set_oversampling(const RID &p_font_rid, double p_oversampling) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1955,27 +2020,27 @@ void TextServerAdvanced::font_set_oversampling(RID p_font_rid, float p_oversampl } } -float TextServerAdvanced::font_get_oversampling(RID p_font_rid) const { +double TextServerAdvanced::font_get_oversampling(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); return fd->oversampling; } -Array TextServerAdvanced::font_get_size_cache_list(RID p_font_rid) const { +Array TextServerAdvanced::font_get_size_cache_list(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); MutexLock lock(fd->mutex); Array ret; - for (const Map::Element *E = fd->cache.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue &E : fd->cache) { + ret.push_back(E.key); } return ret; } -void TextServerAdvanced::font_clear_size_cache(RID p_font_rid) { +void TextServerAdvanced::font_clear_size_cache(const RID &p_font_rid) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1986,7 +2051,7 @@ void TextServerAdvanced::font_clear_size_cache(RID p_font_rid) { fd->cache.clear(); } -void TextServerAdvanced::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) { +void TextServerAdvanced::font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1997,7 +2062,7 @@ void TextServerAdvanced::font_remove_size_cache(RID p_font_rid, const Vector2i & } } -void TextServerAdvanced::font_set_ascent(RID p_font_rid, int p_size, float p_ascent) { +void TextServerAdvanced::font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2008,23 +2073,23 @@ void TextServerAdvanced::font_set_ascent(RID p_font_rid, int p_size, float p_asc fd->cache[size]->ascent = p_ascent; } -float TextServerAdvanced::font_get_ascent(RID p_font_rid, int p_size) const { +double TextServerAdvanced::font_get_ascent(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->ascent * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->ascent * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->ascent; } } -void TextServerAdvanced::font_set_descent(RID p_font_rid, int p_size, float p_descent) { +void TextServerAdvanced::font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2034,23 +2099,23 @@ void TextServerAdvanced::font_set_descent(RID p_font_rid, int p_size, float p_de fd->cache[size]->descent = p_descent; } -float TextServerAdvanced::font_get_descent(RID p_font_rid, int p_size) const { +double TextServerAdvanced::font_get_descent(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->descent * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->descent * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->descent; } } -void TextServerAdvanced::font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) { +void TextServerAdvanced::font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2061,23 +2126,23 @@ void TextServerAdvanced::font_set_underline_position(RID p_font_rid, int p_size, fd->cache[size]->underline_position = p_underline_position; } -float TextServerAdvanced::font_get_underline_position(RID p_font_rid, int p_size) const { +double TextServerAdvanced::font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->underline_position * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->underline_position * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->underline_position; } } -void TextServerAdvanced::font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) { +void TextServerAdvanced::font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2088,23 +2153,23 @@ void TextServerAdvanced::font_set_underline_thickness(RID p_font_rid, int p_size fd->cache[size]->underline_thickness = p_underline_thickness; } -float TextServerAdvanced::font_get_underline_thickness(RID p_font_rid, int p_size) const { +double TextServerAdvanced::font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->underline_thickness * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->underline_thickness * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->underline_thickness; } } -void TextServerAdvanced::font_set_scale(RID p_font_rid, int p_size, float p_scale) { +void TextServerAdvanced::font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2115,23 +2180,23 @@ void TextServerAdvanced::font_set_scale(RID p_font_rid, int p_size, float p_scal fd->cache[size]->scale = p_scale; } -float TextServerAdvanced::font_get_scale(RID p_font_rid, int p_size) const { +double TextServerAdvanced::font_get_scale(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->scale * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->scale * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->scale / fd->cache[size]->oversampling; } } -void TextServerAdvanced::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) { +void TextServerAdvanced::font_set_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing, int64_t p_value) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2147,12 +2212,12 @@ void TextServerAdvanced::font_set_spacing(RID p_font_rid, int p_size, TextServer fd->cache[size]->spacing_space = p_value; } break; default: { - ERR_FAIL_MSG("Invalid spacing type: " + itos(p_spacing)); + ERR_FAIL_MSG("Invalid spacing type: " + String::num_int64(p_spacing)); } break; } } -int TextServerAdvanced::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const { +int64_t TextServerAdvanced::font_get_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -2164,26 +2229,26 @@ int TextServerAdvanced::font_get_spacing(RID p_font_rid, int p_size, TextServer: switch (p_spacing) { case TextServer::SPACING_GLYPH: { if (fd->msdf) { - return fd->cache[size]->spacing_glyph * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->spacing_glyph * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->spacing_glyph; } } break; case TextServer::SPACING_SPACE: { if (fd->msdf) { - return fd->cache[size]->spacing_space * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->spacing_space * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->spacing_space; } } break; default: { - ERR_FAIL_V_MSG(0, "Invalid spacing type: " + itos(p_spacing)); + ERR_FAIL_V_MSG(0, "Invalid spacing type: " + String::num_int64(p_spacing)); } break; } return 0; } -int TextServerAdvanced::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const { +int64_t TextServerAdvanced::font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -2195,7 +2260,7 @@ int TextServerAdvanced::font_get_texture_count(RID p_font_rid, const Vector2i &p return fd->cache[size]->textures.size(); } -void TextServerAdvanced::font_clear_textures(RID p_font_rid, const Vector2i &p_size) { +void TextServerAdvanced::font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); @@ -2205,7 +2270,7 @@ void TextServerAdvanced::font_clear_textures(RID p_font_rid, const Vector2i &p_s fd->cache[size]->textures.clear(); } -void TextServerAdvanced::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) { +void TextServerAdvanced::font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2217,7 +2282,7 @@ void TextServerAdvanced::font_remove_texture(RID p_font_rid, const Vector2i &p_s fd->cache[size]->textures.remove_at(p_texture_index); } -void TextServerAdvanced::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) { +void TextServerAdvanced::font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); ERR_FAIL_COND(p_image.is_null()); @@ -2237,13 +2302,16 @@ void TextServerAdvanced::font_set_texture_image(RID p_font_rid, const Vector2i & tex.texture_h = p_image->get_height(); tex.format = p_image->get_format(); - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata); + tex.texture = Ref(); tex.texture.instantiate(); tex.texture->create_from_image(img); } -Ref TextServerAdvanced::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +Ref TextServerAdvanced::font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Ref()); @@ -2252,13 +2320,15 @@ Ref TextServerAdvanced::font_get_texture_image(RID p_font_rid, const Vect ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Ref()); ERR_FAIL_INDEX_V(p_texture_index, fd->cache[size]->textures.size(), Ref()); - const FontTexture &tex = fd->cache[size]->textures.write[p_texture_index]; - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata)); + const FontTexture &tex = fd->cache[size]->textures[p_texture_index]; + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata); return img; } -void TextServerAdvanced::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) { +void TextServerAdvanced::font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2274,7 +2344,7 @@ void TextServerAdvanced::font_set_texture_offsets(RID p_font_rid, const Vector2i tex.offsets = p_offset; } -PackedInt32Array TextServerAdvanced::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +PackedInt32Array TextServerAdvanced::font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, PackedInt32Array()); @@ -2283,11 +2353,11 @@ PackedInt32Array TextServerAdvanced::font_get_texture_offsets(RID p_font_rid, co ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), PackedInt32Array()); ERR_FAIL_INDEX_V(p_texture_index, fd->cache[size]->textures.size(), PackedInt32Array()); - const FontTexture &tex = fd->cache[size]->textures.write[p_texture_index]; + const FontTexture &tex = fd->cache[size]->textures[p_texture_index]; return tex.offsets; } -Array TextServerAdvanced::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const { +Array TextServerAdvanced::font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); @@ -2304,7 +2374,7 @@ Array TextServerAdvanced::font_get_glyph_list(RID p_font_rid, const Vector2i &p_ return ret; } -void TextServerAdvanced::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) { +void TextServerAdvanced::font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2315,7 +2385,7 @@ void TextServerAdvanced::font_clear_glyphs(RID p_font_rid, const Vector2i &p_siz fd->cache[size]->glyph_map.clear(); } -void TextServerAdvanced::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) { +void TextServerAdvanced::font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2326,7 +2396,7 @@ void TextServerAdvanced::font_remove_glyph(RID p_font_rid, const Vector2i &p_siz fd->cache[size]->glyph_map.erase(p_glyph); } -float TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) const { +double TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) const { const FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0.0); @@ -2334,13 +2404,13 @@ float TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) co Vector2i size = _get_size(fd, p_font_size); if (fd->embolden != 0.0) { - return fd->embolden * float(size.x) / 64.0; + return fd->embolden * double(size.x) / 64.0; } else { return 0.0; } } -Vector2 TextServerAdvanced::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const { +Vector2 TextServerAdvanced::font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -2356,11 +2426,11 @@ Vector2 TextServerAdvanced::font_get_glyph_advance(RID p_font_rid, int p_size, i Vector2 ea; if (fd->embolden != 0.0) { - ea.x = fd->embolden * float(size.x) / 64.0; + ea.x = fd->embolden * double(size.x) / 64.0; } if (fd->msdf) { - return (gl[p_glyph].advance + ea) * (float)p_size / (float)fd->msdf_source_size; + return (gl[p_glyph].advance + ea) * (double)p_size / (double)fd->msdf_source_size; } else if ((fd->subpixel_positioning == SUBPIXEL_POSITIONING_DISABLED) || (fd->subpixel_positioning == SUBPIXEL_POSITIONING_AUTO && size.x > SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE)) { return (gl[p_glyph].advance + ea).round(); } else { @@ -2368,7 +2438,7 @@ Vector2 TextServerAdvanced::font_get_glyph_advance(RID p_font_rid, int p_size, i } } -void TextServerAdvanced::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) { +void TextServerAdvanced::font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2383,7 +2453,7 @@ void TextServerAdvanced::font_set_glyph_advance(RID p_font_rid, int p_size, int3 gl[p_glyph].found = true; } -Vector2 TextServerAdvanced::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerAdvanced::font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -2398,13 +2468,13 @@ Vector2 TextServerAdvanced::font_get_glyph_offset(RID p_font_rid, const Vector2i const HashMap &gl = fd->cache[size]->glyph_map; if (fd->msdf) { - return gl[p_glyph].rect.position * (float)p_size.x / (float)fd->msdf_source_size; + return gl[p_glyph].rect.position * (double)p_size.x / (double)fd->msdf_source_size; } else { return gl[p_glyph].rect.position; } } -void TextServerAdvanced::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) { +void TextServerAdvanced::font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2419,7 +2489,7 @@ void TextServerAdvanced::font_set_glyph_offset(RID p_font_rid, const Vector2i &p gl[p_glyph].found = true; } -Vector2 TextServerAdvanced::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerAdvanced::font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -2434,13 +2504,13 @@ Vector2 TextServerAdvanced::font_get_glyph_size(RID p_font_rid, const Vector2i & const HashMap &gl = fd->cache[size]->glyph_map; if (fd->msdf) { - return gl[p_glyph].rect.size * (float)p_size.x / (float)fd->msdf_source_size; + return gl[p_glyph].rect.size * (double)p_size.x / (double)fd->msdf_source_size; } else { return gl[p_glyph].rect.size; } } -void TextServerAdvanced::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) { +void TextServerAdvanced::font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2455,7 +2525,7 @@ void TextServerAdvanced::font_set_glyph_size(RID p_font_rid, const Vector2i &p_s gl[p_glyph].found = true; } -Rect2 TextServerAdvanced::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Rect2 TextServerAdvanced::font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Rect2()); @@ -2471,7 +2541,7 @@ Rect2 TextServerAdvanced::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i return gl[p_glyph].uv_rect; } -void TextServerAdvanced::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) { +void TextServerAdvanced::font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2486,7 +2556,7 @@ void TextServerAdvanced::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i & gl[p_glyph].found = true; } -int TextServerAdvanced::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +int64_t TextServerAdvanced::font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, -1); @@ -2502,7 +2572,7 @@ int TextServerAdvanced::font_get_glyph_texture_idx(RID p_font_rid, const Vector2 return gl[p_glyph].texture_idx; } -void TextServerAdvanced::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) { +void TextServerAdvanced::font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2517,7 +2587,7 @@ void TextServerAdvanced::font_set_glyph_texture_idx(RID p_font_rid, const Vector gl[p_glyph].found = true; } -Dictionary TextServerAdvanced::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index) const { +Dictionary TextServerAdvanced::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -2526,20 +2596,19 @@ Dictionary TextServerAdvanced::font_get_glyph_contours(RID p_font_rid, int p_siz ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Dictionary()); - Vector points; - Vector contours; + PackedVector3Array points; + PackedInt32Array contours; bool orientation; #ifdef MODULE_FREETYPE_ENABLED - int error = FT_Load_Glyph(fd->cache[size]->face, p_index, FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)); + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. + + int error = FT_Load_Glyph(fd->cache[size]->face, index, FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)); ERR_FAIL_COND_V(error, Dictionary()); - points.clear(); - contours.clear(); - - float h = fd->cache[size]->ascent; - float scale = (1.0 / 64.0) / fd->cache[size]->oversampling * fd->cache[size]->scale; + double h = fd->cache[size]->ascent; + double scale = (1.0 / 64.0) / fd->cache[size]->oversampling * fd->cache[size]->scale; if (fd->msdf) { - scale = scale * (float)p_size / (float)fd->msdf_source_size; + scale = scale * (double)p_size / (double)fd->msdf_source_size; } for (short i = 0; i < fd->cache[size]->face->glyph->outline.n_points; i++) { points.push_back(Vector3(fd->cache[size]->face->glyph->outline.points[i].x * scale, h - fd->cache[size]->face->glyph->outline.points[i].y * scale, FT_CURVE_TAG(fd->cache[size]->face->glyph->outline.tags[i]))); @@ -2559,7 +2628,7 @@ Dictionary TextServerAdvanced::font_get_glyph_contours(RID p_font_rid, int p_siz return out; } -Array TextServerAdvanced::font_get_kerning_list(RID p_font_rid, int p_size) const { +Array TextServerAdvanced::font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); @@ -2569,13 +2638,13 @@ Array TextServerAdvanced::font_get_kerning_list(RID p_font_rid, int p_size) cons ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Array()); Array ret; - for (const Map::Element *E = fd->cache[size]->kerning_map.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue &E : fd->cache) { + ret.push_back(E.key); } return ret; } -void TextServerAdvanced::font_clear_kerning_map(RID p_font_rid, int p_size) { +void TextServerAdvanced::font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2586,7 +2655,7 @@ void TextServerAdvanced::font_clear_kerning_map(RID p_font_rid, int p_size) { fd->cache[size]->kerning_map.clear(); } -void TextServerAdvanced::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) { +void TextServerAdvanced::font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2597,7 +2666,7 @@ void TextServerAdvanced::font_remove_kerning(RID p_font_rid, int p_size, const V fd->cache[size]->kerning_map.erase(p_glyph_pair); } -void TextServerAdvanced::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { +void TextServerAdvanced::font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2608,7 +2677,7 @@ void TextServerAdvanced::font_set_kerning(RID p_font_rid, int p_size, const Vect fd->cache[size]->kerning_map[p_glyph_pair] = p_kerning; } -Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const { +Vector2 TextServerAdvanced::font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -2621,7 +2690,7 @@ Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const V if (kern.has(p_glyph_pair)) { if (fd->msdf) { - return kern[p_glyph_pair] * (float)p_size / (float)fd->msdf_source_size; + return kern[p_glyph_pair] * (double)p_size / (double)fd->msdf_source_size; } else { return kern[p_glyph_pair]; } @@ -2631,7 +2700,7 @@ Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const V FT_Vector delta; FT_Get_Kerning(fd->cache[size]->face, p_glyph_pair.x, p_glyph_pair.y, FT_KERNING_DEFAULT, &delta); if (fd->msdf) { - return Vector2(delta.x, delta.y) * (float)p_size / (float)fd->msdf_source_size; + return Vector2(delta.x, delta.y) * (double)p_size / (double)fd->msdf_source_size; } else { return Vector2(delta.x, delta.y); } @@ -2641,7 +2710,7 @@ Vector2 TextServerAdvanced::font_get_kerning(RID p_font_rid, int p_size, const V return Vector2(); } -int32_t TextServerAdvanced::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const { +int64_t TextServerAdvanced::font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); @@ -2659,14 +2728,14 @@ 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 (int32_t)p_char; + return (int64_t)p_char; } #else - return (int32_t)p_char; + return (int64_t)p_char; #endif } -bool TextServerAdvanced::font_has_char(RID p_font_rid, char32_t p_char) const { +bool TextServerAdvanced::font_has_char(const RID &p_font_rid, int64_t p_char) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), false, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); @@ -2685,7 +2754,7 @@ bool TextServerAdvanced::font_has_char(RID p_font_rid, char32_t p_char) const { return (at_size) ? at_size->glyph_map.has((int32_t)p_char) : false; } -String TextServerAdvanced::font_get_supported_chars(RID p_font_rid) const { +String TextServerAdvanced::font_get_supported_chars(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -2702,7 +2771,7 @@ String TextServerAdvanced::font_get_supported_chars(RID p_font_rid) const { FT_ULong charcode = FT_Get_First_Char(at_size->face, &gindex); while (gindex != 0) { if (charcode != 0) { - chars += char32_t(charcode); + chars = chars + String::chr(charcode); } charcode = FT_Get_Next_Char(at_size->face, charcode, &gindex); } @@ -2713,13 +2782,13 @@ String TextServerAdvanced::font_get_supported_chars(RID p_font_rid) const { const HashMap &gl = at_size->glyph_map; const int32_t *E = nullptr; while ((E = gl.next(E))) { - chars += char32_t(*E); + chars = chars + String::chr(*E); } } return chars; } -void TextServerAdvanced::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) { +void TextServerAdvanced::font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); ERR_FAIL_COND_MSG((p_start >= 0xd800 && p_start <= 0xdfff) || (p_start > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_start, 16) + "."); @@ -2728,7 +2797,7 @@ void TextServerAdvanced::font_render_range(RID p_font_rid, const Vector2i &p_siz MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - for (char32_t i = p_start; i <= p_end; i++) { + for (int64_t i = p_start; i <= p_end; i++) { #ifdef MODULE_FREETYPE_ENABLED int32_t idx = FT_Get_Char_Index(fd->cache[size]->face, i); if (fd->cache[size]->face) { @@ -2752,7 +2821,7 @@ void TextServerAdvanced::font_render_range(RID p_font_rid, const Vector2i &p_siz } } -void TextServerAdvanced::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) { +void TextServerAdvanced::font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2760,7 +2829,7 @@ void TextServerAdvanced::font_render_glyph(RID p_font_rid, const Vector2i &p_siz Vector2i size = _get_size_outline(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); #ifdef MODULE_FREETYPE_ENABLED - int32_t idx = p_index; + int32_t idx = p_index & 0xffffff; // Remove subpixel shifts. if (fd->cache[size]->face) { if (fd->msdf) { _ensure_glyph(fd, size, (int32_t)idx); @@ -2781,7 +2850,7 @@ void TextServerAdvanced::font_render_glyph(RID p_font_rid, const Vector2i &p_siz #endif } -void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { +void TextServerAdvanced::font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2789,7 +2858,7 @@ void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz Vector2i size = _get_size(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - int32_t index = p_index; + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. #ifdef MODULE_FREETYPE_ENABLED if (!fd->msdf && fd->cache[size]->face) { @@ -2822,8 +2891,8 @@ void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz RID texture = fd->cache[size]->textures[gl.texture_idx].texture->get_rid(); if (fd->msdf) { Point2 cpos = p_pos; - cpos += gl.rect.position * (float)p_size / (float)fd->msdf_source_size; - Size2 csize = gl.rect.size * (float)p_size / (float)fd->msdf_source_size; + cpos += gl.rect.position * (double)p_size / (double)fd->msdf_source_size; + Size2 csize = gl.rect.size * (double)p_size / (double)fd->msdf_source_size; RenderingServer::get_singleton()->canvas_item_add_msdf_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate, 0, fd->msdf_range); } else { Point2 cpos = p_pos; @@ -2844,7 +2913,7 @@ void TextServerAdvanced::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz } } -void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { +void TextServerAdvanced::font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2852,7 +2921,7 @@ void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i Vector2i size = _get_size_outline(fd, Vector2i(p_size, p_outline_size)); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - int32_t index = p_index; + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. #ifdef MODULE_FREETYPE_ENABLED if (!fd->msdf && fd->cache[size]->face) { @@ -2885,8 +2954,8 @@ void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i RID texture = fd->cache[size]->textures[gl.texture_idx].texture->get_rid(); if (fd->msdf) { Point2 cpos = p_pos; - cpos += gl.rect.position * (float)p_size / (float)fd->msdf_source_size; - Size2 csize = gl.rect.size * (float)p_size / (float)fd->msdf_source_size; + cpos += gl.rect.position * (double)p_size / (double)fd->msdf_source_size; + Size2 csize = gl.rect.size * (double)p_size / (double)fd->msdf_source_size; RenderingServer::get_singleton()->canvas_item_add_msdf_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate, p_outline_size * 2, fd->msdf_range); } else { Point2 cpos = p_pos; @@ -2907,7 +2976,7 @@ void TextServerAdvanced::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i } } -bool TextServerAdvanced::font_is_language_supported(RID p_font_rid, const String &p_language) const { +bool TextServerAdvanced::font_is_language_supported(const RID &p_font_rid, const String &p_language) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2919,7 +2988,7 @@ bool TextServerAdvanced::font_is_language_supported(RID p_font_rid, const String } } -void TextServerAdvanced::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) { +void TextServerAdvanced::font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2927,7 +2996,7 @@ void TextServerAdvanced::font_set_language_support_override(RID p_font_rid, cons fd->language_support_overrides[p_language] = p_supported; } -bool TextServerAdvanced::font_get_language_support_override(RID p_font_rid, const String &p_language) { +bool TextServerAdvanced::font_get_language_support_override(const RID &p_font_rid, const String &p_language) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2935,7 +3004,7 @@ bool TextServerAdvanced::font_get_language_support_override(RID p_font_rid, cons return fd->language_support_overrides[p_language]; } -void TextServerAdvanced::font_remove_language_support_override(RID p_font_rid, const String &p_language) { +void TextServerAdvanced::font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2943,19 +3012,19 @@ void TextServerAdvanced::font_remove_language_support_override(RID p_font_rid, c fd->language_support_overrides.erase(p_language); } -Vector TextServerAdvanced::font_get_language_support_overrides(RID p_font_rid) { +PackedStringArray TextServerAdvanced::font_get_language_support_overrides(const RID &p_font_rid) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector out; + PackedStringArray out; for (const KeyValue &E : fd->language_support_overrides) { out.push_back(E.key); } return out; } -bool TextServerAdvanced::font_is_script_supported(RID p_font_rid, const String &p_script) const { +bool TextServerAdvanced::font_is_script_supported(const RID &p_font_rid, const String &p_script) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2969,7 +3038,7 @@ bool TextServerAdvanced::font_is_script_supported(RID p_font_rid, const String & } } -void TextServerAdvanced::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) { +void TextServerAdvanced::font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2977,7 +3046,7 @@ void TextServerAdvanced::font_set_script_support_override(RID p_font_rid, const fd->script_support_overrides[p_script] = p_supported; } -bool TextServerAdvanced::font_get_script_support_override(RID p_font_rid, const String &p_script) { +bool TextServerAdvanced::font_get_script_support_override(const RID &p_font_rid, const String &p_script) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2985,7 +3054,7 @@ bool TextServerAdvanced::font_get_script_support_override(RID p_font_rid, const return fd->script_support_overrides[p_script]; } -void TextServerAdvanced::font_remove_script_support_override(RID p_font_rid, const String &p_script) { +void TextServerAdvanced::font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2993,19 +3062,19 @@ void TextServerAdvanced::font_remove_script_support_override(RID p_font_rid, con fd->script_support_overrides.erase(p_script); } -Vector TextServerAdvanced::font_get_script_support_overrides(RID p_font_rid) { +PackedStringArray TextServerAdvanced::font_get_script_support_overrides(const RID &p_font_rid) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector out; - for (const Map::Element *E = fd->script_support_overrides.front(); E; E = E->next()) { - out.push_back(E->key()); + PackedStringArray out; + for (const KeyValue &E : fd->script_support_overrides) { + out.push_back(E.key); } return out; } -void TextServerAdvanced::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { +void TextServerAdvanced::font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -3015,7 +3084,7 @@ void TextServerAdvanced::font_set_opentype_feature_overrides(RID p_font_rid, con fd->feature_overrides = p_overrides; } -Dictionary TextServerAdvanced::font_get_opentype_feature_overrides(RID p_font_rid) const { +Dictionary TextServerAdvanced::font_get_opentype_feature_overrides(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -3023,7 +3092,7 @@ Dictionary TextServerAdvanced::font_get_opentype_feature_overrides(RID p_font_ri return fd->feature_overrides; } -Dictionary TextServerAdvanced::font_supported_feature_list(RID p_font_rid) const { +Dictionary TextServerAdvanced::font_supported_feature_list(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -3033,7 +3102,7 @@ Dictionary TextServerAdvanced::font_supported_feature_list(RID p_font_rid) const return fd->supported_features; } -Dictionary TextServerAdvanced::font_supported_variation_list(RID p_font_rid) const { +Dictionary TextServerAdvanced::font_supported_variation_list(const RID &p_font_rid) const { FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -3043,11 +3112,11 @@ Dictionary TextServerAdvanced::font_supported_variation_list(RID p_font_rid) con return fd->supported_varaitions; } -float TextServerAdvanced::font_get_global_oversampling() const { +double TextServerAdvanced::font_get_global_oversampling() const { return oversampling; } -void TextServerAdvanced::font_set_global_oversampling(float p_oversampling) { +void TextServerAdvanced::font_set_global_oversampling(double p_oversampling) { _THREAD_SAFE_METHOD_ if (oversampling != p_oversampling) { oversampling = p_oversampling; @@ -3075,10 +3144,10 @@ void TextServerAdvanced::font_set_global_oversampling(float p_oversampling) { /* Shaped text buffer interface */ /*************************************************************************/ -int TextServerAdvanced::_convert_pos(const ShapedTextDataAdvanced *p_sd, int p_pos) const { - int32_t limit = p_pos; +int64_t TextServerAdvanced::_convert_pos(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const { + int64_t limit = p_pos; if (p_sd->text.length() != p_sd->utf16.length()) { - const UChar *data = p_sd->utf16.ptr(); + const UChar *data = p_sd->utf16.get_data(); for (int i = 0; i < p_pos; i++) { if (U16_IS_LEAD(data[i])) { limit--; @@ -3088,11 +3157,11 @@ int TextServerAdvanced::_convert_pos(const ShapedTextDataAdvanced *p_sd, int p_p return limit; } -int TextServerAdvanced::_convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int p_pos) const { - int32_t limit = p_pos; +int64_t TextServerAdvanced::_convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const { + int64_t limit = p_pos; if (p_sd->text.length() != p_sd->utf16.length()) { for (int i = 0; i < p_pos; i++) { - if (p_sd->text[i] > 0xFFFF) { + if (p_sd->text[i] > 0xffff) { limit++; } } @@ -3106,11 +3175,11 @@ void TextServerAdvanced::invalidate(TextServerAdvanced::ShapedTextDataAdvanced * p_shaped->line_breaks_valid = false; p_shaped->justification_ops_valid = false; p_shaped->text_trimmed = false; - p_shaped->ascent = 0.f; - p_shaped->descent = 0.f; - p_shaped->width = 0.f; - p_shaped->upos = 0.f; - p_shaped->uthk = 0.f; + p_shaped->ascent = 0.0; + p_shaped->descent = 0.0; + p_shaped->width = 0.0; + p_shaped->upos = 0.0; + p_shaped->uthk = 0.0; p_shaped->glyphs.clear(); p_shaped->glyphs_logical.clear(); p_shaped->overrun_trim_data = TrimData(); @@ -3161,7 +3230,7 @@ RID TextServerAdvanced::create_shaped_text(TextServer::Direction p_direction, Te return shaped_owner.make_rid(sd); } -void TextServerAdvanced::shaped_text_clear(RID p_shaped) { +void TextServerAdvanced::shaped_text_clear(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3176,7 +3245,7 @@ void TextServerAdvanced::shaped_text_clear(RID p_shaped) { invalidate(sd, true); } -void TextServerAdvanced::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) { +void TextServerAdvanced::shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3190,7 +3259,7 @@ void TextServerAdvanced::shaped_text_set_direction(RID p_shaped, TextServer::Dir } } -TextServer::Direction TextServerAdvanced::shaped_text_get_direction(RID p_shaped) const { +TextServer::Direction TextServerAdvanced::shaped_text_get_direction(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, TextServer::DIRECTION_LTR); @@ -3198,7 +3267,7 @@ TextServer::Direction TextServerAdvanced::shaped_text_get_direction(RID p_shaped return sd->direction; } -TextServer::Direction TextServerAdvanced::shaped_text_get_inferred_direction(RID p_shaped) const { +TextServer::Direction TextServerAdvanced::shaped_text_get_inferred_direction(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, TextServer::DIRECTION_LTR); @@ -3206,7 +3275,7 @@ TextServer::Direction TextServerAdvanced::shaped_text_get_inferred_direction(RID return sd->para_direction; } -void TextServerAdvanced::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { +void TextServerAdvanced::shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) { _THREAD_SAFE_METHOD_ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3220,14 +3289,14 @@ void TextServerAdvanced::shaped_text_set_custom_punctuation(RID p_shaped, const } } -String TextServerAdvanced::shaped_text_get_custom_punctuation(RID p_shaped) const { +String TextServerAdvanced::shaped_text_get_custom_punctuation(const RID &p_shaped) const { _THREAD_SAFE_METHOD_ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, String()); return sd->custom_punct; } -void TextServerAdvanced::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) { +void TextServerAdvanced::shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3242,7 +3311,7 @@ void TextServerAdvanced::shaped_text_set_bidi_override(RID p_shaped, const Array invalidate(sd, false); } -void TextServerAdvanced::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) { +void TextServerAdvanced::shaped_text_set_orientation(const RID &p_shaped, TextServer::Orientation p_orientation) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3256,7 +3325,7 @@ void TextServerAdvanced::shaped_text_set_orientation(RID p_shaped, TextServer::O } } -void TextServerAdvanced::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) { +void TextServerAdvanced::shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3268,7 +3337,7 @@ void TextServerAdvanced::shaped_text_set_preserve_invalid(RID p_shaped, bool p_e } } -bool TextServerAdvanced::shaped_text_get_preserve_invalid(RID p_shaped) const { +bool TextServerAdvanced::shaped_text_get_preserve_invalid(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3276,7 +3345,7 @@ bool TextServerAdvanced::shaped_text_get_preserve_invalid(RID p_shaped) const { return sd->preserve_invalid; } -void TextServerAdvanced::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) { +void TextServerAdvanced::shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -3290,7 +3359,7 @@ void TextServerAdvanced::shaped_text_set_preserve_control(RID p_shaped, bool p_e } } -bool TextServerAdvanced::shaped_text_get_preserve_control(RID p_shaped) const { +bool TextServerAdvanced::shaped_text_get_preserve_control(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3298,7 +3367,7 @@ bool TextServerAdvanced::shaped_text_get_preserve_control(RID p_shaped) const { return sd->preserve_control; } -TextServer::Orientation TextServerAdvanced::shaped_text_get_orientation(RID p_shaped) const { +TextServer::Orientation TextServerAdvanced::shaped_text_get_orientation(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, TextServer::ORIENTATION_HORIZONTAL); @@ -3306,25 +3375,25 @@ TextServer::Orientation TextServerAdvanced::shaped_text_get_orientation(RID p_sh return sd->orientation; } -int TextServerAdvanced::shaped_get_span_count(RID p_shaped) const { +int64_t TextServerAdvanced::shaped_get_span_count(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, 0); return sd->spans.size(); } -Variant TextServerAdvanced::shaped_get_span_meta(RID p_shaped, int p_index) const { +Variant TextServerAdvanced::shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Variant()); ERR_FAIL_INDEX_V(p_index, sd->spans.size(), Variant()); return sd->spans[p_index].meta; } -void TextServerAdvanced::shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features) { +void TextServerAdvanced::shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); ERR_FAIL_INDEX(p_index, sd->spans.size()); - ShapedTextDataAdvanced::Span &span = sd->spans.write[p_index]; + ShapedTextDataAdvanced::Span &span = sd->spans.ptrw()[p_index]; bool changed = (span.font_size != p_size) || (span.features != p_opentype_features) || (p_fonts.size() != span.fonts.size()); if (!changed) { for (int i = 0; i < p_fonts.size(); i++) { @@ -3340,7 +3409,7 @@ void TextServerAdvanced::shaped_set_span_update_font(RID p_shaped, int p_index, } } -bool TextServerAdvanced::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { +bool TextServerAdvanced::shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); ERR_FAIL_COND_V(p_size <= 0, false); @@ -3368,14 +3437,14 @@ bool TextServerAdvanced::shaped_text_add_string(RID p_shaped, const String &p_te span.meta = p_meta; sd->spans.push_back(span); - sd->text += p_text; + sd->text = sd->text + p_text; sd->end += p_text.length(); invalidate(sd, true); return true; } -bool TextServerAdvanced::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align, int p_length) { +bool TextServerAdvanced::shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, int64_t p_length) { _THREAD_SAFE_METHOD_ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3397,7 +3466,7 @@ bool TextServerAdvanced::shaped_text_add_object(RID p_shaped, Variant p_key, con obj.pos = span.start; sd->spans.push_back(span); - sd->text += String::chr(0xfffc).repeat(p_length); + sd->text = sd->text + String::chr(0xfffc).repeat(p_length); sd->end += p_length; sd->objects[p_key] = obj; invalidate(sd, true); @@ -3405,7 +3474,7 @@ bool TextServerAdvanced::shaped_text_add_object(RID p_shaped, Variant p_key, con return true; } -bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align) { +bool TextServerAdvanced::shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3459,8 +3528,8 @@ bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, if (sd->orientation == ORIENTATION_HORIZONTAL) { sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y); } else { - sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); - sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); + sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); + sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); } } sd->width += gl.advance * gl.repeat; @@ -3473,8 +3542,8 @@ bool TextServerAdvanced::shaped_text_resize_object(RID p_shaped, Variant p_key, void TextServerAdvanced::_realign(ShapedTextDataAdvanced *p_sd) const { // Align embedded objects to baseline. - float full_ascent = p_sd->ascent; - float full_descent = p_sd->descent; + double full_ascent = p_sd->ascent; + double full_descent = p_sd->descent; for (KeyValue &E : p_sd->objects) { if ((E.value.pos >= p_sd->start) && (E.value.pos < p_sd->end)) { if (p_sd->orientation == ORIENTATION_HORIZONTAL) { @@ -3540,7 +3609,7 @@ void TextServerAdvanced::_realign(ShapedTextDataAdvanced *p_sd) const { p_sd->descent = full_descent; } -RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_length) const { +RID TextServerAdvanced::shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, RID()); @@ -3571,7 +3640,7 @@ RID TextServerAdvanced::shaped_text_substr(RID p_shaped, int p_start, int p_leng return shaped_owner.make_rid(new_sd); } -bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int p_start, int p_length) const { +bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_length) const { if (p_new_sd->valid) { return true; } @@ -3661,8 +3730,8 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S if (p_new_sd->orientation == ORIENTATION_HORIZONTAL) { p_new_sd->ascent = MAX(p_new_sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y); } else { - p_new_sd->ascent = MAX(p_new_sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); - p_new_sd->descent = MAX(p_new_sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); + p_new_sd->ascent = MAX(p_new_sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); + p_new_sd->descent = MAX(p_new_sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); } } p_new_sd->width += gl.advance * gl.repeat; @@ -3680,7 +3749,7 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S return true; } -RID TextServerAdvanced::shaped_text_get_parent(RID p_shaped) const { +RID TextServerAdvanced::shaped_text_get_parent(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, RID()); @@ -3688,9 +3757,9 @@ RID TextServerAdvanced::shaped_text_get_parent(RID p_shaped) const { return sd->parent; } -float TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags) { +double TextServerAdvanced::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3729,7 +3798,7 @@ float TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, float p_width, } } - float justification_width; + double justification_width; if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) == JUSTIFICATION_CONSTRAIN_ELLIPSIS) { if (sd->overrun_trim_data.trim_pos >= 0) { if (sd->para_direction == DIRECTION_RTL) { @@ -3785,7 +3854,7 @@ float TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, float p_width, } if ((elongation_count > 0) && ((p_jst_flags & JUSTIFICATION_KASHIDA) == JUSTIFICATION_KASHIDA)) { - float delta_width_per_kashida = (p_width - justification_width) / elongation_count; + double delta_width_per_kashida = (p_width - justification_width) / elongation_count; for (int i = start_pos; i <= end_pos; i++) { Glyph &gl = sd->glyphs.write[i]; if (gl.count > 0) { @@ -3805,17 +3874,17 @@ float TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, float p_width, } } } - float adv_remain = 0; + double adv_remain = 0; if ((space_count > 0) && ((p_jst_flags & JUSTIFICATION_WORD_BOUND) == JUSTIFICATION_WORD_BOUND)) { - float delta_width_per_space = (p_width - justification_width) / space_count; + double delta_width_per_space = (p_width - justification_width) / space_count; for (int i = start_pos; i <= end_pos; i++) { Glyph &gl = sd->glyphs.write[i]; if (gl.count > 0) { if ((gl.flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE) { - float old_adv = gl.advance; - float new_advance; + double old_adv = gl.advance; + double new_advance; if ((gl.flags & GRAPHEME_IS_VIRTUAL) == GRAPHEME_IS_VIRTUAL) { - new_advance = MAX(gl.advance + delta_width_per_space, 0.f); + new_advance = MAX(gl.advance + delta_width_per_space, 0.0); } else { new_advance = MAX(gl.advance + delta_width_per_space, 0.1 * gl.font_size); } @@ -3845,9 +3914,9 @@ float TextServerAdvanced::shaped_text_fit_to_width(RID p_shaped, float p_width, return Math::ceil(justification_width); } -float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) { +double TextServerAdvanced::shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3859,12 +3928,12 @@ float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat3 for (int i = 0; i < p_tab_stops.size(); i++) { if (p_tab_stops[i] <= 0) { - return 0.f; + return 0.0; } } int tab_index = 0; - float off = 0.f; + double off = 0.0; int start, end, delta; if (sd->para_direction == DIRECTION_LTR) { @@ -3881,7 +3950,7 @@ float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat3 for (int i = start; i != end; i += delta) { if ((gl[i].flags & GRAPHEME_IS_TAB) == GRAPHEME_IS_TAB) { - float tab_off = 0.f; + double tab_off = 0.0; while (tab_off <= off) { tab_off += p_tab_stops[tab_index]; tab_index++; @@ -3889,7 +3958,7 @@ float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat3 tab_index = 0; } } - float old_adv = gl[i].advance; + double old_adv = gl[i].advance; gl[i].advance = tab_off - off; sd->width += gl[i].advance - old_adv; off = 0; @@ -3898,10 +3967,10 @@ float TextServerAdvanced::shaped_text_tab_align(RID p_shaped, const PackedFloat3 off += gl[i].advance * gl[i].repeat; } - return 0.f; + return 0.0; } -void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, float p_width, uint16_t p_trim_flags) { +void TextServerAdvanced::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped_line); ERR_FAIL_COND_MSG(!sd, "ShapedTextDataAdvanced invalid."); @@ -3947,20 +4016,20 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl // Find usable fonts, if fonts from the last glyph do not have required chars. RID dot_gl_font_rid = sd_glyphs[sd_size - 1].font_rid; if (!font_has_char(dot_gl_font_rid, '.')) { - const Vector &fonts = spans[spans.size() - 1].fonts; - for (const RID &font : fonts) { - if (font_has_char(font, '.')) { - dot_gl_font_rid = font; + const Array &fonts = spans[spans.size() - 1].fonts; + for (int i = 0; i < fonts.size(); i++) { + if (font_has_char(fonts[i], '.')) { + dot_gl_font_rid = fonts[i]; break; } } } RID whitespace_gl_font_rid = sd_glyphs[sd_size - 1].font_rid; if (!font_has_char(whitespace_gl_font_rid, '.')) { - const Vector &fonts = spans[spans.size() - 1].fonts; - for (const RID &font : fonts) { - if (font_has_char(font, ' ')) { - whitespace_gl_font_rid = font; + const Array &fonts = spans[spans.size() - 1].fonts; + for (int i = 0; i < fonts.size(); i++) { + if (font_has_char(fonts[i], ' ')) { + whitespace_gl_font_rid = fonts[i]; break; } } @@ -3977,7 +4046,7 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl } int ell_min_characters = 6; - float width = sd->width; + double width = sd->width; bool is_rtl = sd->para_direction == DIRECTION_RTL; @@ -4063,7 +4132,7 @@ void TextServerAdvanced::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl } } -int TextServerAdvanced::shaped_text_get_trim_pos(RID p_shaped) const { +int64_t TextServerAdvanced::shaped_text_get_trim_pos(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataAdvanced invalid."); @@ -4071,7 +4140,7 @@ int TextServerAdvanced::shaped_text_get_trim_pos(RID p_shaped) const { return sd->overrun_trim_data.trim_pos; } -int TextServerAdvanced::shaped_text_get_ellipsis_pos(RID p_shaped) const { +int64_t TextServerAdvanced::shaped_text_get_ellipsis_pos(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataAdvanced invalid."); @@ -4079,7 +4148,7 @@ int TextServerAdvanced::shaped_text_get_ellipsis_pos(RID p_shaped) const { return sd->overrun_trim_data.ellipsis_pos; } -const Glyph *TextServerAdvanced::shaped_text_get_ellipsis_glyphs(RID p_shaped) const { +const Glyph *TextServerAdvanced::shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, nullptr, "ShapedTextDataAdvanced invalid."); @@ -4087,7 +4156,7 @@ const Glyph *TextServerAdvanced::shaped_text_get_ellipsis_glyphs(RID p_shaped) c return sd->overrun_trim_data.ellipsis_glyph_buf.ptr(); } -int TextServerAdvanced::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const { +int64_t TextServerAdvanced::shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, 0, "ShapedTextDataAdvanced invalid."); @@ -4095,7 +4164,7 @@ int TextServerAdvanced::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const return sd->overrun_trim_data.ellipsis_glyph_buf.size(); } -bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { +bool TextServerAdvanced::shaped_text_update_breaks(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -4108,7 +4177,7 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { return true; // Nothing to do. } - const UChar *data = sd->utf16.ptr(); + const UChar *data = sd->utf16.get_data(); if (!sd->break_ops_valid) { sd->breaks.clear(); @@ -4171,7 +4240,7 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; } if (c_punct_size == 0) { - if (u_ispunct(c) && c != 0x005F) { + if (u_ispunct(c) && c != 0x005f) { sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; } } else { @@ -4237,10 +4306,10 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { return sd->line_breaks_valid; } -_FORCE_INLINE_ int _generate_kashida_justification_opportunies(const String &p_data, int p_start, int p_end) { - int kashida_pos = -1; +_FORCE_INLINE_ int64_t _generate_kashida_justification_opportunies(const String &p_data, int64_t p_start, int64_t p_end) { + int64_t kashida_pos = -1; int8_t priority = 100; - int i = p_start; + int64_t i = p_start; char32_t pc = 0; @@ -4256,7 +4325,7 @@ _FORCE_INLINE_ int _generate_kashida_justification_opportunies(const String &p_d priority = 0; } if (priority >= 1 && i < p_end - 1) { - if (is_seen_sad(c) && (p_data[i + 1] != 0x200C)) { + if (is_seen_sad(c) && (p_data[i + 1] != 0x200c)) { kashida_pos = i; priority = 1; } @@ -4312,7 +4381,7 @@ _FORCE_INLINE_ int _generate_kashida_justification_opportunies(const String &p_d return kashida_pos; } -bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) { +bool TextServerAdvanced::shaped_text_update_justification_ops(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -4328,8 +4397,8 @@ bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) { return true; // Nothing to do. } - const UChar *data = sd->utf16.ptr(); - int32_t data_size = sd->utf16.length(); + const UChar *data = sd->utf16.get_data(); + int data_size = sd->utf16.length(); if (!sd->js_ops_valid) { sd->jstops.clear(); @@ -4459,7 +4528,7 @@ bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) { return sd->justification_ops_valid; } -Glyph TextServerAdvanced::_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) { +Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, const RID &p_font, int64_t p_font_size) { hb_font_t *hb_font = _font_get_hb_handle(p_font, p_font_size); bool subpos = (font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_ONE_HALF) || (font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_AUTO && p_font_size <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE); ERR_FAIL_COND_V(hb_font == nullptr, Glyph()); @@ -4487,7 +4556,7 @@ Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char gl.font_size = p_font_size; if (glyph_count > 0) { - float scale = font_get_scale(p_font, p_font_size); + double scale = font_get_scale(p_font, p_font_size); if (p_sd->orientation == ORIENTATION_HORIZONTAL) { if (subpos) { gl.advance = glyph_pos[0].x_advance / (64.0 / scale) + _get_extra_advance(p_font, p_font_size); @@ -4515,16 +4584,18 @@ Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char } _FORCE_INLINE_ void TextServerAdvanced::_add_featuers(const Dictionary &p_source, Vector &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) { + Array keys = p_source.keys(); + Array values = p_source.values(); + for (int i = 0; i < keys.size(); i++) { + int32_t value = values[i]; + if (value >= 0) { hb_feature_t feature; - if (ftr->get_type() == Variant::STRING) { - feature.tag = name_to_tag(*ftr); + if (keys[i].get_type() == Variant::STRING) { + feature.tag = name_to_tag(keys[i]); } else { - feature.tag = *ftr; + feature.tag = keys[i]; } - feature.value = values; + feature.value = value; feature.start = 0; feature.end = -1; r_ftrs.push_back(feature); @@ -4532,7 +4603,7 @@ _FORCE_INLINE_ void TextServerAdvanced::_add_featuers(const Dictionary &p_source } } -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 p_fonts, int p_span, int p_fb_index) { +void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_end, hb_script_t p_script, hb_direction_t p_direction, Array p_fonts, int64_t p_span, int64_t p_fb_index) { int fs = p_sd->spans[p_span].font_size; if (p_fb_index >= p_fonts.size()) { // Add fallback glyphs. @@ -4553,8 +4624,8 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star p_sd->ascent = MAX(p_sd->ascent, get_hex_code_box_size(fs, gl.index).y); } else { gl.advance = get_hex_code_box_size(fs, gl.index).y; - p_sd->ascent = MAX(p_sd->ascent, Math::round(get_hex_code_box_size(fs, gl.index).x * 0.5f)); - p_sd->descent = MAX(p_sd->descent, Math::round(get_hex_code_box_size(fs, gl.index).x * 0.5f)); + p_sd->ascent = MAX(p_sd->ascent, Math::round(get_hex_code_box_size(fs, gl.index).x * 0.5)); + p_sd->descent = MAX(p_sd->descent, Math::round(get_hex_code_box_size(fs, gl.index).x * 0.5)); } p_sd->width += gl.advance; @@ -4566,10 +4637,10 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star RID f = p_fonts[p_fb_index]; hb_font_t *hb_font = _font_get_hb_handle(f, fs); - float scale = font_get_scale(f, fs); - float sp_sp = font_get_spacing(f, fs, SPACING_SPACE); - float sp_gl = font_get_spacing(f, fs, SPACING_GLYPH); - float ea = _get_extra_advance(f, fs); + double scale = font_get_scale(f, fs); + double sp_sp = font_get_spacing(f, fs, SPACING_SPACE); + double sp_gl = font_get_spacing(f, fs, SPACING_GLYPH); + double ea = _get_extra_advance(f, fs); bool subpos = (font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_ONE_HALF) || (font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_AUTO && fs <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE); ERR_FAIL_COND(hb_font == nullptr); @@ -4703,7 +4774,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star p_sd->ascent = MAX(p_sd->ascent, -w[i + j].y_off); p_sd->descent = MAX(p_sd->descent, w[i + j].y_off); } else { - float gla = Math::round(font_get_glyph_advance(f, fs, w[i + j].index).x * 0.5); + double gla = Math::round(font_get_glyph_advance(f, fs, w[i + j].index).x * 0.5); p_sd->ascent = MAX(p_sd->ascent, gla); p_sd->descent = MAX(p_sd->descent, gla); } @@ -4733,7 +4804,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star } } -bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { +bool TextServerAdvanced::shaped_text_shape(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -4757,7 +4828,7 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { } sd->utf16 = sd->text.utf16(); - const UChar *data = sd->utf16.ptr(); + const UChar *data = sd->utf16.get_data(); // Create script iterator. if (sd->script_iter == nullptr) { @@ -4876,9 +4947,9 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { } sd->glyphs.push_back(gl); } else { - Vector fonts; - Vector fonts_scr_only; - Vector fonts_no_match; + Array fonts; + Array fonts_scr_only; + Array fonts_no_match; int font_count = span.fonts.size(); for (int l = 0; l < font_count; l++) { if (font_is_script_supported(span.fonts[l], script)) { @@ -4906,7 +4977,7 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { return sd->valid; } -bool TextServerAdvanced::shaped_text_is_ready(RID p_shaped) const { +bool TextServerAdvanced::shaped_text_is_ready(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -4914,7 +4985,7 @@ bool TextServerAdvanced::shaped_text_is_ready(RID p_shaped) const { return sd->valid; } -const Glyph *TextServerAdvanced::shaped_text_get_glyphs(RID p_shaped) const { +const Glyph *TextServerAdvanced::shaped_text_get_glyphs(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, nullptr); @@ -4925,7 +4996,7 @@ const Glyph *TextServerAdvanced::shaped_text_get_glyphs(RID p_shaped) const { return sd->glyphs.ptr(); } -int TextServerAdvanced::shaped_text_get_glyph_count(RID p_shaped) const { +int64_t TextServerAdvanced::shaped_text_get_glyph_count(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, 0); @@ -4936,7 +5007,7 @@ int TextServerAdvanced::shaped_text_get_glyph_count(RID p_shaped) const { return sd->glyphs.size(); } -const Glyph *TextServerAdvanced::shaped_text_sort_logical(RID p_shaped) { +const Glyph *TextServerAdvanced::shaped_text_sort_logical(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, nullptr); @@ -4954,7 +5025,7 @@ const Glyph *TextServerAdvanced::shaped_text_sort_logical(RID p_shaped) { return sd->glyphs_logical.ptr(); } -Vector2i TextServerAdvanced::shaped_text_get_range(RID p_shaped) const { +Vector2i TextServerAdvanced::shaped_text_get_range(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Vector2i()); @@ -4962,7 +5033,7 @@ Vector2i TextServerAdvanced::shaped_text_get_range(RID p_shaped) const { return Vector2(sd->start, sd->end); } -Array TextServerAdvanced::shaped_text_get_objects(RID p_shaped) const { +Array TextServerAdvanced::shaped_text_get_objects(const RID &p_shaped) const { Array ret; const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, ret); @@ -4975,7 +5046,7 @@ Array TextServerAdvanced::shaped_text_get_objects(RID p_shaped) const { return ret; } -Rect2 TextServerAdvanced::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const { +Rect2 TextServerAdvanced::shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Rect2()); @@ -4987,7 +5058,7 @@ Rect2 TextServerAdvanced::shaped_text_get_object_rect(RID p_shaped, Variant p_ke return sd->objects[p_key].rect; } -Size2 TextServerAdvanced::shaped_text_get_size(RID p_shaped) const { +Size2 TextServerAdvanced::shaped_text_get_size(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Size2()); @@ -5002,9 +5073,9 @@ Size2 TextServerAdvanced::shaped_text_get_size(RID p_shaped) const { } } -float TextServerAdvanced::shaped_text_get_ascent(RID p_shaped) const { +double TextServerAdvanced::shaped_text_get_ascent(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5013,9 +5084,9 @@ float TextServerAdvanced::shaped_text_get_ascent(RID p_shaped) const { return sd->ascent; } -float TextServerAdvanced::shaped_text_get_descent(RID p_shaped) const { +double TextServerAdvanced::shaped_text_get_descent(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5024,9 +5095,9 @@ float TextServerAdvanced::shaped_text_get_descent(RID p_shaped) const { return sd->descent; } -float TextServerAdvanced::shaped_text_get_width(RID p_shaped) const { +double TextServerAdvanced::shaped_text_get_width(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5035,9 +5106,9 @@ float TextServerAdvanced::shaped_text_get_width(RID p_shaped) const { return Math::ceil(sd->text_trimmed ? sd->width_trimmed : sd->width); } -float TextServerAdvanced::shaped_text_get_underline_position(RID p_shaped) const { +double TextServerAdvanced::shaped_text_get_underline_position(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5047,9 +5118,9 @@ float TextServerAdvanced::shaped_text_get_underline_position(RID p_shaped) const return sd->upos; } -float TextServerAdvanced::shaped_text_get_underline_thickness(RID p_shaped) const { +double TextServerAdvanced::shaped_text_get_underline_thickness(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5246,7 +5317,7 @@ String TextServerAdvanced::format_number(const String &p_string, const String &p res.replace("e", num_systems[i].exp); res.replace("E", num_systems[i].exp); char32_t *data = res.ptrw(); - for (int j = 0; j < res.size(); j++) { + for (int j = 0; j < res.length(); j++) { if (data[j] >= 0x30 && data[j] <= 0x39) { data[j] = num_systems[i].digits[data[j] - 0x30]; } else if (data[j] == '.' || data[j] == ',') { @@ -5270,7 +5341,7 @@ String TextServerAdvanced::parse_number(const String &p_string, const String &p_ } res.replace(num_systems[i].exp, "e"); char32_t *data = res.ptrw(); - for (int j = 0; j < res.size(); j++) { + for (int j = 0; j < res.length(); j++) { if (data[j] == num_systems[i].digits[10]) { data[j] = '.'; } else { @@ -5312,13 +5383,13 @@ String TextServerAdvanced::strip_diacritics(const String &p_string) const { Char16String utf16 = p_string.utf16(); // Normalize. - Char16String normalized; + Vector normalized; err = U_ZERO_ERROR; - int32_t len = unorm2_normalize(unorm, utf16.ptr(), -1, nullptr, 0, &err); + int32_t len = unorm2_normalize(unorm, utf16.get_data(), -1, nullptr, 0, &err); ERR_FAIL_COND_V_MSG(err != U_BUFFER_OVERFLOW_ERROR, TextServer::strip_diacritics(p_string), u_errorName(err)); normalized.resize(len); err = U_ZERO_ERROR; - unorm2_normalize(unorm, utf16.ptr(), -1, normalized.ptrw(), len, &err); + unorm2_normalize(unorm, utf16.get_data(), -1, normalized.ptrw(), len, &err); ERR_FAIL_COND_V_MSG(U_FAILURE(err), TextServer::strip_diacritics(p_string), u_errorName(err)); // Convert back to UTF-32. @@ -5328,7 +5399,7 @@ String TextServerAdvanced::strip_diacritics(const String &p_string) const { String result; for (int i = 0; i < normalized_string.length(); i++) { if (u_getCombiningClass(normalized_string[i]) == 0) { - result += normalized_string[i]; + result = result + normalized_string[i]; } } return result; @@ -5338,13 +5409,13 @@ String TextServerAdvanced::string_to_upper(const String &p_string, const String // Convert to UTF-16. Char16String utf16 = p_string.utf16(); - Char16String upper; + Vector upper; UErrorCode err = U_ZERO_ERROR; - int32_t len = u_strToUpper(nullptr, 0, utf16.ptr(), -1, p_language.ascii().get_data(), &err); + int32_t len = u_strToUpper(nullptr, 0, utf16.get_data(), -1, p_language.ascii().get_data(), &err); ERR_FAIL_COND_V_MSG(err != U_BUFFER_OVERFLOW_ERROR, p_string, u_errorName(err)); upper.resize(len); err = U_ZERO_ERROR; - u_strToUpper(upper.ptrw(), len, utf16.ptr(), -1, p_language.ascii().get_data(), &err); + u_strToUpper(upper.ptrw(), len, utf16.get_data(), -1, p_language.ascii().get_data(), &err); ERR_FAIL_COND_V_MSG(U_FAILURE(err), p_string, u_errorName(err)); // Convert back to UTF-32. @@ -5355,13 +5426,13 @@ String TextServerAdvanced::string_to_lower(const String &p_string, const String // Convert to UTF-16. Char16String utf16 = p_string.utf16(); - Char16String lower; + Vector lower; UErrorCode err = U_ZERO_ERROR; - int32_t len = u_strToLower(nullptr, 0, utf16.ptr(), -1, p_language.ascii().get_data(), &err); + int32_t len = u_strToLower(nullptr, 0, utf16.get_data(), -1, p_language.ascii().get_data(), &err); ERR_FAIL_COND_V_MSG(err != U_BUFFER_OVERFLOW_ERROR, p_string, u_errorName(err)); lower.resize(len); err = U_ZERO_ERROR; - u_strToLower(lower.ptrw(), len, utf16.ptr(), -1, p_language.ascii().get_data(), &err); + u_strToLower(lower.ptrw(), len, utf16.get_data(), -1, p_language.ascii().get_data(), &err); ERR_FAIL_COND_V_MSG(U_FAILURE(err), p_string, u_errorName(err)); // Convert back to UTF-32. @@ -5376,14 +5447,8 @@ TextServerAdvanced::TextServerAdvanced() { TextServerAdvanced::~TextServerAdvanced() { _bmp_free_font_funcs(); - if (library != nullptr) { - FT_Done_FreeType(library); + if (ft_library != nullptr) { + FT_Done_FreeType(ft_library); } u_cleanup(); -#ifndef ICU_STATIC_DATA - if (icu_data != nullptr) { - memfree(icu_data); - icu_data = nullptr; - } -#endif } diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index e5958fc162e..bb3968ee3f8 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -36,13 +36,61 @@ /* shaping and advanced font features support. */ /*************************************************************************/ -#include "servers/text_server.h" +#ifdef GDEXTENSION +// Headers for building as GDExtension plug-in. + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace godot; + +#else +// Headers for building as built-in module. #include "core/templates/rid_owner.h" #include "core/templates/thread_work_pool.h" #include "scene/resources/texture.h" +#include "servers/text/text_server_extension.h" + +#include "modules/modules_enabled.gen.h" // For freetype, msdfgen. + +#endif + #include "script_iterator.h" +// Thirdparty headers. + #include #include #include @@ -55,8 +103,6 @@ #include #include -#include "modules/modules_enabled.gen.h" // For freetype, msdfgen. - #ifdef MODULE_FREETYPE_ENABLED #include #include FT_FREETYPE_H @@ -73,12 +119,11 @@ #include #include -class TextServerAdvanced : public TextServer { - GDCLASS(TextServerAdvanced, TextServer); - _THREAD_SAFE_CLASS_ +/*************************************************************************/ - static String interface_name; - static uint32_t interface_features; +class TextServerAdvanced : public TextServerExtension { + GDCLASS(TextServerAdvanced, TextServerExtension); + _THREAD_SAFE_CLASS_ struct NumSystemData { Set lang; @@ -89,21 +134,23 @@ class TextServerAdvanced : public TextServer { Vector num_systems; Map feature_sets; + Map feature_sets_inv; void _insert_num_systems_lang(); void _insert_feature_sets(); + _FORCE_INLINE_ void _insert_feature(const StringName &p_name, int32_t p_tag); // ICU support data. - uint8_t *icu_data = nullptr; + bool icu_data_loaded = false; // Font cache data. #ifdef MODULE_FREETYPE_ENABLED - mutable FT_Library library = nullptr; + mutable FT_Library ft_library = nullptr; #endif - const int rect_range = 2; + const int rect_range = 1; struct FontTexture { Image::Format format; @@ -129,12 +176,12 @@ class TextServerAdvanced : public TextServer { }; struct FontDataForSizeAdvanced { - float ascent = 0.f; - float descent = 0.f; - float underline_position = 0.f; - float underline_thickness = 0.f; - float scale = 1.f; - float oversampling = 1.f; + double ascent = 0.0; + double descent = 0.0; + double underline_position = 0.0; + double underline_thickness = 0.0; + double scale = 1.0; + double oversampling = 1.0; int spacing_glyph = 0; int spacing_space = 0; @@ -176,8 +223,8 @@ class TextServerAdvanced : public TextServer { TextServer::Hinting hinting = TextServer::HINTING_LIGHT; TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO; Dictionary variation_coordinates; - float oversampling = 0.f; - float embolden = 0.f; + double oversampling = 0.0; + double embolden = 0.0; Transform2D transform; uint32_t style_flags = 0; @@ -203,8 +250,8 @@ class TextServerAdvanced : public TextServer { ~FontDataAdvanced() { work_pool.finish(); - for (const Map::Element *E = cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue &E : cache) { + memdelete(E.value); } cache.clear(); } @@ -242,16 +289,34 @@ class TextServerAdvanced : public TextServer { } } - _FORCE_INLINE_ float _get_extra_advance(RID p_font_rid, int p_font_size) const; + _FORCE_INLINE_ double _get_extra_advance(RID p_font_rid, int p_font_size) const; // Shaped text cache data. + struct TrimData { + int trim_pos = -1; + int ellipsis_pos = -1; + Vector ellipsis_glyph_buf; + }; + + struct ShapedTextDataAdvanced { + Mutex mutex; + + /* Source data */ + RID parent; // Substring parent ShapedTextData. + + int start = 0; // Substring start offset in the parent string. + int end = 0; // Substring end offset in the parent string. + + String text; + String custom_punct; + TextServer::Direction direction = DIRECTION_LTR; // Desired text direction. + TextServer::Orientation orientation = ORIENTATION_HORIZONTAL; - struct ShapedTextDataAdvanced : public ShapedTextData { struct Span { int start = -1; int end = -1; - Vector fonts; + Array fonts; int font_size = 0; Variant embedded_key; @@ -262,6 +327,38 @@ class TextServerAdvanced : public TextServer { }; Vector spans; + struct EmbeddedObject { + int pos = 0; + InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER; + Rect2 rect; + }; + Map objects; + + /* Shaped data */ + TextServer::Direction para_direction = DIRECTION_LTR; // Detected text direction. + bool valid = false; // String is shaped. + bool line_breaks_valid = false; // Line and word break flags are populated (and virtual zero width spaces inserted). + bool justification_ops_valid = false; // Virtual elongation glyphs are added to the string. + bool sort_valid = false; + bool text_trimmed = false; + + bool preserve_invalid = true; // Draw hex code box instead of missing characters. + bool preserve_control = false; // Draw control characters. + + double ascent = 0.0; // Ascent for horizontal layout, 1/2 of width for vertical. + double descent = 0.0; // Descent for horizontal layout, 1/2 of width for vertical. + double width = 0.0; // Width for horizontal layout, height for vertical. + double width_trimmed = 0.0; + + double upos = 0.0; + double uthk = 0.0; + + TrimData overrun_trim_data; + bool fit_width_minimum_reached = false; + + Vector glyphs; + Vector glyphs_logical; + /* Intermediate data */ Char16String utf16; Vector bidi_iter; @@ -289,16 +386,16 @@ class TextServerAdvanced : public TextServer { // Common data. - float oversampling = 1.f; + double oversampling = 1.0; mutable RID_PtrOwner font_owner; mutable RID_PtrOwner shaped_owner; void _realign(ShapedTextDataAdvanced *p_sd) const; - int _convert_pos(const ShapedTextDataAdvanced *p_sd, int p_pos) const; - int _convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int p_pos) const; - 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 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); + int64_t _convert_pos(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const; + int64_t _convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const; + bool _shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_length) const; + void _shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_end, hb_script_t p_script, hb_direction_t p_direction, Array p_fonts, int64_t p_span, int64_t p_fb_index); + Glyph _shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, const RID &p_font, int64_t p_font_size); _FORCE_INLINE_ void _add_featuers(const Dictionary &p_source, Vector &r_ftrs); // HarfBuzz bitmap font interface. @@ -324,6 +421,25 @@ class TextServerAdvanced : public TextServer { static void _bmp_font_set_funcs(hb_font_t *p_font, TextServerAdvanced::FontDataForSizeAdvanced *p_face, bool p_unref); static hb_font_t *_bmp_font_create(TextServerAdvanced::FontDataForSizeAdvanced *p_face, hb_destroy_func_t p_destroy); + hb_font_t *_font_get_hb_handle(const RID &p_font, int64_t p_font_size) const; + + struct GlyphCompare { // For line breaking reordering. + _FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const { + if (l.start == r.start) { + if (l.count == r.count) { + if ((l.flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL) { + return false; + } else { + return true; + } + } + return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant. + } else { + return l.start < r.start; + } + } + }; + protected: static void _bind_methods(){}; @@ -333,10 +449,10 @@ protected: public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual uint32_t get_features() const override; + virtual int64_t get_features() const override; - virtual void free(RID p_rid) override; - virtual bool has(RID p_rid) override; + virtual void free_rid(const RID &p_rid) override; + virtual bool has(const RID &p_rid) override; virtual bool load_support_data(const String &p_filename) override; virtual String get_support_data_filename() const override; @@ -345,220 +461,218 @@ public: virtual bool is_locale_right_to_left(const String &p_locale) const override; - virtual int32_t name_to_tag(const String &p_name) const override; - virtual String tag_to_name(int32_t p_tag) const override; + virtual int64_t name_to_tag(const String &p_name) const override; + virtual String tag_to_name(int64_t p_tag) const override; /* Font interface */ virtual RID create_font() override; - virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; - virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; + virtual void font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) override; + virtual void font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) override; - virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; - virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; + virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override; + virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override; - virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_style_name(RID p_font_rid) const override; + virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_style_name(const RID &p_font_rid) const override; - virtual void font_set_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_name(RID p_font_rid) const override; + virtual void font_set_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_name(const RID &p_font_rid) const override; - virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; - virtual bool font_is_antialiased(RID p_font_rid) const override; + virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) override; + virtual bool font_is_antialiased(const RID &p_font_rid) const override; - virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) override; - virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const override; + virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override; + virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override; - virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) override; - virtual int font_get_msdf_pixel_range(RID p_font_rid) const override; + virtual void font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) override; + virtual int64_t font_get_msdf_pixel_range(const RID &p_font_rid) const override; - virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) override; - virtual int font_get_msdf_size(RID p_font_rid) const override; + virtual void font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) override; + virtual int64_t font_get_msdf_size(const RID &p_font_rid) const override; - virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) override; - virtual int font_get_fixed_size(RID p_font_rid) const override; + virtual void font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) override; + virtual int64_t font_get_fixed_size(const RID &p_font_rid) const override; - virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) override; - virtual bool font_is_force_autohinter(RID p_font_rid) const override; + virtual void font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) override; + virtual bool font_is_force_autohinter(const RID &p_font_rid) const override; - virtual void font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) override; - virtual TextServer::Hinting font_get_hinting(RID p_font_rid) const override; + virtual void font_set_subpixel_positioning(const RID &p_font_rid, SubpixelPositioning p_subpixel) override; + virtual SubpixelPositioning font_get_subpixel_positioning(const RID &p_font_rid) const override; - virtual void font_set_subpixel_positioning(RID p_font_rid, SubpixelPositioning p_subpixel) override; - virtual SubpixelPositioning font_get_subpixel_positioning(RID p_font_rid) const override; + virtual void font_set_embolden(const RID &p_font_rid, double p_strength) override; + virtual double font_get_embolden(const RID &p_font_rid) const override; - virtual void font_set_embolden(RID p_font_rid, float p_strength) override; - virtual float font_get_embolden(RID p_font_rid) const override; + virtual void font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) override; + virtual Transform2D font_get_transform(const RID &p_font_rid) const override; - virtual void font_set_transform(RID p_font_rid, Transform2D p_transform) override; - virtual Transform2D font_get_transform(RID p_font_rid) const override; + virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) override; + virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const override; - virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) override; - virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const override; + virtual void font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) override; + virtual TextServer::Hinting font_get_hinting(const RID &p_font_rid) const override; - virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) override; - virtual float font_get_oversampling(RID p_font_rid) const override; + virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) override; + virtual double font_get_oversampling(const RID &p_font_rid) const override; - virtual Array font_get_size_cache_list(RID p_font_rid) const override; - virtual void font_clear_size_cache(RID p_font_rid) override; - virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) override; + virtual Array font_get_size_cache_list(const RID &p_font_rid) const override; + virtual void font_clear_size_cache(const RID &p_font_rid) override; + virtual void font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) override; - hb_font_t *_font_get_hb_handle(RID p_font, int p_font_size) const; + virtual void font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) override; + virtual double font_get_ascent(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) override; - virtual float font_get_ascent(RID p_font_rid, int p_size) const override; + virtual void font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) override; + virtual double font_get_descent(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) override; - virtual float font_get_descent(RID p_font_rid, int p_size) const override; + virtual void font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) override; + virtual double font_get_underline_position(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) override; - virtual float font_get_underline_position(RID p_font_rid, int p_size) const override; + virtual void font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) override; + virtual double font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) override; - virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const override; + virtual void font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) override; + virtual double font_get_scale(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) override; - virtual float font_get_scale(RID p_font_rid, int p_size) const override; + virtual void font_set_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing, int64_t p_value) override; + virtual int64_t font_get_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing) const override; - virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) override; - virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const override; + virtual int64_t font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) override; - virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) override; + virtual void font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) override; + virtual Ref font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; - virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) override; - virtual Ref font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; + virtual void font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) override; + virtual PackedInt32Array font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; - virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) override; - virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; + virtual Array font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) override; - virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) override; + virtual Vector2 font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) override; - virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) override; + virtual Vector2 font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) override; - virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) override; + virtual Vector2 font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) override; - virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) override; + virtual Rect2 font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) override; - virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) override; + virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override; - virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) override; + virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override; - virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const override; + virtual Array font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const override; + virtual void font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) override; + virtual void font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) override; - virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const override; - virtual void font_clear_kerning_map(RID p_font_rid, int p_size) override; - virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) override; + virtual void font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; + virtual Vector2 font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const override; - virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; - virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const override; + virtual int64_t font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector = 0) const override; - virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector = 0) const override; + virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const override; + virtual String font_get_supported_chars(const RID &p_font_rid) const override; - virtual bool font_has_char(RID p_font_rid, char32_t p_char) const override; - virtual String font_get_supported_chars(RID p_font_rid) const override; + virtual void font_render_range(const RID &p_font, const Vector2i &p_size, int64_t p_start, int64_t p_end) override; + virtual void font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) override; - virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) override; - virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) override; + virtual void font_draw_glyph(const RID &p_font, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + virtual void font_draw_glyph_outline(const RID &p_font, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + virtual bool font_is_language_supported(const RID &p_font_rid, const String &p_language) const override; + virtual void font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) override; + virtual bool font_get_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual void font_remove_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual PackedStringArray font_get_language_support_overrides(const RID &p_font_rid) override; - virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const override; - virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) override; - virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) override; - virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) override; - virtual Vector font_get_language_support_overrides(RID p_font_rid) override; + virtual bool font_is_script_supported(const RID &p_font_rid, const String &p_script) const override; + virtual void font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) override; + virtual bool font_get_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual void font_remove_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual PackedStringArray font_get_script_support_overrides(const RID &p_font_rid) override; - virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const override; - virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) override; - virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) override; - virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; - virtual Vector font_get_script_support_overrides(RID p_font_rid) override; + virtual void font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(const RID &p_font_rid) const 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(const RID &p_font_rid) const override; + virtual Dictionary font_supported_variation_list(const 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; - - virtual float font_get_global_oversampling() const override; - virtual void font_set_global_oversampling(float p_oversampling) override; + virtual double font_get_global_oversampling() const override; + virtual void font_set_global_oversampling(double p_oversampling) override; /* Shaped text buffer interface */ virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual void shaped_text_clear(RID p_shaped) override; + virtual void shaped_text_clear(const RID &p_shaped) override; - virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override; - virtual Direction shaped_text_get_direction(RID p_shaped) const override; - virtual Direction shaped_text_get_inferred_direction(RID p_shaped) const override; + virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) override; + virtual Direction shaped_text_get_direction(const RID &p_shaped) const override; + virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const override; - virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; + virtual void shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) override; - virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; - virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; + virtual void shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(const RID &p_shaped) const override; - virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; + virtual void shaped_text_set_orientation(const RID &p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; + virtual Orientation shaped_text_get_orientation(const RID &p_shaped) const override; - virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override; + virtual void shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_invalid(const RID &p_shaped) const override; - virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_control(RID p_shaped) const override; + virtual void shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_control(const RID &p_shaped) const override; - virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; - virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int p_length = 1) override; - virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; + virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) override; + virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; - virtual int shaped_get_span_count(RID p_shaped) const override; - virtual Variant shaped_get_span_meta(RID p_shaped, int p_index) const override; - virtual void shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary()) override; + virtual int64_t shaped_get_span_count(const RID &p_shaped) const override; + virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override; - virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override; - virtual RID shaped_text_get_parent(RID p_shaped) const override; + virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override; + virtual RID shaped_text_get_parent(const RID &p_shaped) const override; - virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; - virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) override; + virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; + virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override; - virtual bool shaped_text_shape(RID p_shaped) override; - virtual bool shaped_text_update_breaks(RID p_shaped) override; - virtual bool shaped_text_update_justification_ops(RID p_shaped) override; + virtual bool shaped_text_shape(const RID &p_shaped) override; + virtual bool shaped_text_update_breaks(const RID &p_shaped) override; + virtual bool shaped_text_update_justification_ops(const RID &p_shaped) override; - virtual int shaped_text_get_trim_pos(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const override; - virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const override; + virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override; - virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) override; + virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override; - virtual bool shaped_text_is_ready(RID p_shaped) const override; + virtual bool shaped_text_is_ready(const RID &p_shaped) const override; - virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const override; - virtual const Glyph *shaped_text_sort_logical(RID p_shaped) override; - virtual int shaped_text_get_glyph_count(RID p_shaped) const override; + virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) override; + virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const override; - virtual Vector2i shaped_text_get_range(RID p_shaped) const override; + virtual Vector2i shaped_text_get_range(const RID &p_shaped) const override; - virtual Array shaped_text_get_objects(RID p_shaped) const override; - virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override; + virtual Array shaped_text_get_objects(const RID &p_shaped) const override; + virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const override; - virtual Size2 shaped_text_get_size(RID p_shaped) const override; - virtual float shaped_text_get_ascent(RID p_shaped) const override; - virtual float shaped_text_get_descent(RID p_shaped) const override; - virtual float shaped_text_get_width(RID p_shaped) const override; - virtual float shaped_text_get_underline_position(RID p_shaped) const override; - virtual float shaped_text_get_underline_thickness(RID p_shaped) const override; + virtual Size2 shaped_text_get_size(const RID &p_shaped) const override; + virtual double shaped_text_get_ascent(const RID &p_shaped) const override; + virtual double shaped_text_get_descent(const RID &p_shaped) const override; + virtual double shaped_text_get_width(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_position(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const override; virtual String format_number(const String &p_string, const String &p_language = "") const override; virtual String parse_number(const String &p_string, const String &p_language = "") const override; diff --git a/modules/text_server_fb/.gitignore b/modules/text_server_fb/.gitignore new file mode 100644 index 00000000000..15cc38b59c6 --- /dev/null +++ b/modules/text_server_fb/.gitignore @@ -0,0 +1,2 @@ +# Godot-cpp headers +gdextension_build/godot-cpp diff --git a/modules/text_server_fb/doc_classes/TextServerFallback.xml b/modules/text_server_fb/doc_classes/TextServerFallback.xml index 76194a7bda5..950b64e49fd 100644 --- a/modules/text_server_fb/doc_classes/TextServerFallback.xml +++ b/modules/text_server_fb/doc_classes/TextServerFallback.xml @@ -1,5 +1,5 @@ - + Fallback implementation of the Text Server, without BiDi and complex text layout support. diff --git a/modules/text_server_fb/gdextension_build/SConstruct b/modules/text_server_fb/gdextension_build/SConstruct new file mode 100644 index 00000000000..1753bc8b868 --- /dev/null +++ b/modules/text_server_fb/gdextension_build/SConstruct @@ -0,0 +1,205 @@ +#!/usr/bin/env python +import atexit +import os +import sys +import methods +import time + +# For the reference: +# - CCFLAGS are compilation flags shared between C and C++ +# - CFLAGS are for C-specific compilation flags +# - CXXFLAGS are for C++-specific compilation flags +# - CPPFLAGS are for pre-processor flags +# - CPPDEFINES are for pre-processor defines +# - LINKFLAGS are for linking flags + +time_at_start = time.time() + +env = SConscript("./godot-cpp/SConstruct") +env.__class__.disable_warnings = methods.disable_warnings + +opts = Variables([], ARGUMENTS) +opts.Add(BoolVariable("freetype_enabled", "Use FreeType library", True)) +opts.Add(BoolVariable("msdfgen_enabled", "Use MSDFgen library (require FreeType)", True)) +opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) + +opts.Update(env) + +if not env["verbose"]: + methods.no_verbose(sys, env) + +# MSDFGEN +if env["msdfgen_enabled"] and env["freetype_enabled"]: + env_msdfgen = env.Clone() + env_msdfgen.disable_warnings() + + thirdparty_msdfgen_dir = "../../../thirdparty/msdfgen/" + thirdparty_msdfgen_sources = [ + "core/Contour.cpp", + "core/EdgeHolder.cpp", + "core/MSDFErrorCorrection.cpp", + "core/Projection.cpp", + "core/Scanline.cpp", + "core/Shape.cpp", + "core/SignedDistance.cpp", + "core/Vector2.cpp", + "core/contour-combiners.cpp", + "core/edge-coloring.cpp", + "core/edge-segments.cpp", + "core/edge-selectors.cpp", + "core/equation-solver.cpp", + "core/msdf-error-correction.cpp", + "core/msdfgen.cpp", + "core/rasterization.cpp", + "core/render-sdf.cpp", + "core/sdf-error-estimation.cpp", + "core/shape-description.cpp", + ] + thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources] + + env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"]) + env.Append(CPPPATH=["../../../thirdparty/msdfgen"]) + env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"]) + + lib = env_msdfgen.Library( + f'msdfgen_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_msdfgen_sources, + ) + env.Append(LIBS=[lib]) + +# FreeType +if env["freetype_enabled"]: + env_freetype = env.Clone() + env_freetype.disable_warnings() + + thirdparty_freetype_dir = "../../../thirdparty/freetype/" + thirdparty_freetype_sources = [ + "src/autofit/autofit.c", + "src/base/ftbase.c", + "src/base/ftbbox.c", + "src/base/ftbdf.c", + "src/base/ftbitmap.c", + "src/base/ftcid.c", + "src/base/ftdebug.c", + "src/base/ftfstype.c", + "src/base/ftgasp.c", + "src/base/ftglyph.c", + "src/base/ftgxval.c", + "src/base/ftinit.c", + "src/base/ftmm.c", + "src/base/ftotval.c", + "src/base/ftpatent.c", + "src/base/ftpfr.c", + "src/base/ftstroke.c", + "src/base/ftsynth.c", + "src/base/ftsystem.c", + "src/base/fttype1.c", + "src/base/ftwinfnt.c", + "src/bdf/bdf.c", + "src/bzip2/ftbzip2.c", + "src/cache/ftcache.c", + "src/cff/cff.c", + "src/cid/type1cid.c", + "src/gxvalid/gxvalid.c", + "src/gzip/ftgzip.c", + "src/lzw/ftlzw.c", + "src/otvalid/otvalid.c", + "src/pcf/pcf.c", + "src/pfr/pfr.c", + "src/psaux/psaux.c", + "src/pshinter/pshinter.c", + "src/psnames/psnames.c", + "src/raster/raster.c", + "src/sdf/sdf.c", + "src/smooth/smooth.c", + "src/truetype/truetype.c", + "src/type1/type1.c", + "src/type42/type42.c", + "src/winfonts/winfnt.c", + "src/sfnt/sfnt.c", + ] + thirdparty_freetype_sources = [thirdparty_freetype_dir + file for file in thirdparty_freetype_sources] + + thirdparty_png_dir = "../../../thirdparty/libpng/" + thirdparty_png_sources = [ + "png.c", + "pngerror.c", + "pngget.c", + "pngmem.c", + "pngpread.c", + "pngread.c", + "pngrio.c", + "pngrtran.c", + "pngrutil.c", + "pngset.c", + "pngtrans.c", + "pngwio.c", + "pngwrite.c", + "pngwtran.c", + "pngwutil.c", + ] + thirdparty_freetype_sources += [thirdparty_png_dir + file for file in thirdparty_png_sources] + + thirdparty_zlib_dir = "../../../thirdparty/zlib/" + thirdparty_zlib_sources = [ + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", + ] + thirdparty_freetype_sources += [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources] + + env_freetype.Append(CPPPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir]) + env.Append(CPPPATH=[thirdparty_freetype_dir + "/include"]) + + env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG", ("PNG_ARM_NEON_OPT", 0)]) + if env["target"] == "debug": + env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"]) + + env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"]) + + lib = env_freetype.Library( + f'freetype_builtin.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["LIBSUFFIX"]}', + thirdparty_freetype_sources, + ) + env.Append(LIBS=[lib]) + + +env.Append(CPPDEFINES=["GDEXTENSION"]) +env.Append(CPPPATH=["../"]) +sources = Glob("../*.cpp") + +if env["platform"] == "osx": + methods.write_osx_plist( + f'./bin/libtextserver_fallback.osx.{env["target"]}.framework', + f'libtextserver_fallback.osx.{env["target"]}', + "org.godotengine.textserver_fallback", + "Fallback Text Server", + ) + library = env.SharedLibrary( + f'./bin/libtextserver_fallback.osx.{env["target"]}.framework/libtextserver_fallback.osx.{env["target"]}', + source=sources, + ) +else: + library = env.SharedLibrary( + f'./bin/libtextserver_fallback.{env["platform"]}.{env["target"]}.{env["arch_suffix"]}{env["SHLIBSUFFIX"]}', + source=sources, + ) + +Default(library) + + +def print_elapsed_time(): + elapsed_time_sec = round(time.time() - time_at_start, 3) + time_ms = round((elapsed_time_sec % 1) * 1000) + print("[Time elapsed: {}.{:03}]".format(time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)), time_ms)) + + +atexit.register(print_elapsed_time) diff --git a/modules/text_server_fb/gdextension_build/methods.py b/modules/text_server_fb/gdextension_build/methods.py new file mode 100644 index 00000000000..d404f2851e9 --- /dev/null +++ b/modules/text_server_fb/gdextension_build/methods.py @@ -0,0 +1,130 @@ +import os +import sys + + +def no_verbose(sys, env): + colors = {} + + # Colors are disabled in non-TTY environments such as pipes. This means + # that if output is redirected to a file, it will not contain color codes + if sys.stdout.isatty(): + colors["blue"] = "\033[0;94m" + colors["bold_blue"] = "\033[1;94m" + colors["reset"] = "\033[0m" + else: + colors["blue"] = "" + colors["bold_blue"] = "" + colors["reset"] = "" + + # There is a space before "..." to ensure that source file names can be + # Ctrl + clicked in the VS Code terminal. + compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_program_message = "{}Linking Program {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format( + colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"] + ) + + env.Append(CXXCOMSTR=[compile_source_message]) + env.Append(CCCOMSTR=[compile_source_message]) + env.Append(SHCCCOMSTR=[compile_shared_source_message]) + env.Append(SHCXXCOMSTR=[compile_shared_source_message]) + env.Append(ARCOMSTR=[link_library_message]) + env.Append(RANLIBCOMSTR=[ranlib_library_message]) + env.Append(SHLINKCOMSTR=[link_shared_library_message]) + env.Append(LINKCOMSTR=[link_program_message]) + env.Append(JARCOMSTR=[java_library_message]) + env.Append(JAVACCOMSTR=[java_compile_source_message]) + + +def disable_warnings(self): + # 'self' is the environment + if self["platform"] == "windows" and not self["use_mingw"]: + # We have to remove existing warning level defines before appending /w, + # otherwise we get: "warning D9025 : overriding '/W3' with '/w'" + warn_flags = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/WX"] + self.Append(CCFLAGS=["/w"]) + self.Append(CFLAGS=["/w"]) + self.Append(CXXFLAGS=["/w"]) + self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x in warn_flags] + self["CFLAGS"] = [x for x in self["CFLAGS"] if not x in warn_flags] + self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x in warn_flags] + else: + self.Append(CCFLAGS=["-w"]) + self.Append(CFLAGS=["-w"]) + self.Append(CXXFLAGS=["-w"]) + + +def make_icu_data(target, source, env): + dst = target[0].srcnode().abspath + g = open(dst, "w", encoding="utf-8") + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n") + g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n") + g.write("#ifndef _ICU_DATA_H\n") + g.write("#define _ICU_DATA_H\n") + g.write('#include "unicode/utypes.h"\n') + g.write('#include "unicode/udata.h"\n') + g.write('#include "unicode/uversion.h"\n') + + f = open(source[0].srcnode().abspath, "rb") + buf = f.read() + + g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n") + g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n') + for i in range(len(buf)): + g.write("\t" + str(buf[i]) + ",\n") + + g.write("};\n") + g.write("#endif") + + +def write_osx_plist(target, binary_name, identifier, name): + os.makedirs(f"{target}/Resourece/", exist_ok=True) + f = open(f"{target}/Resourece/Info.plist", "w") + + f.write(f'\n') + f.write(f'\n') + f.write(f'\n') + f.write(f"\n") + f.write(f"\tCFBundleExecutable\n") + f.write(f"\t{binary_name}\n") + f.write(f"\tCFBundleIdentifier\n") + f.write(f"\t{identifier}\n") + f.write(f"\tCFBundleInfoDictionaryVersion\n") + f.write(f"\t6.0\n") + f.write(f"\tCFBundleName\n") + f.write(f"\t{name}\n") + f.write(f"\tCFBundlePackageType\n") + f.write(f"\tFMWK\n") + f.write(f"\tCFBundleShortVersionString\n") + f.write(f"\t1.0.0\n") + f.write(f"\tCFBundleSupportedPlatforms\n") + f.write(f"\t\n") + f.write(f"\t\tMacOSX\n") + f.write(f"\t\n") + f.write(f"\tCFBundleVersion\n") + f.write(f"\t1.0.0\n") + f.write(f"\tLSMinimumSystemVersion\n") + f.write(f"\t10.14\n") + f.write(f"\n") + f.write(f"\n") diff --git a/modules/text_server_fb/gdextension_build/text_server_fb.gdextension b/modules/text_server_fb/gdextension_build/text_server_fb.gdextension new file mode 100644 index 00000000000..1026c6cb850 --- /dev/null +++ b/modules/text_server_fb/gdextension_build/text_server_fb.gdextension @@ -0,0 +1,12 @@ +[configuration] + +entry_symbol = "textserver_fallback_init" + +[libraries] + +linux.64.debug = "bin/libtextserver_fallback.linux.debug.64.so" +linux.64.release = "bin/libtextserver_fallback.linux.release.64.so" +windows.64.debug = "bin/libtextserver_fallback.windows.debug.64.dll" +windows.64.release = "bin/libtextserver_fallback.windows.release.64.dll" +macos.debug = "bin/libtextserver_fallback.osx.debug.framework" +macos.release = "bin/libtextserver_fallback.osx.release.framework" diff --git a/modules/text_server_fb/register_types.cpp b/modules/text_server_fb/register_types.cpp index a545f84939a..1044c3f872a 100644 --- a/modules/text_server_fb/register_types.cpp +++ b/modules/text_server_fb/register_types.cpp @@ -34,10 +34,11 @@ void preregister_text_server_fb_types() { GDREGISTER_CLASS(TextServerFallback); - if (TextServerManager::get_singleton()) { + TextServerManager *tsman = TextServerManager::get_singleton(); + if (tsman) { Ref ts; ts.instantiate(); - TextServerManager::get_singleton()->add_interface(ts); + tsman->add_interface(ts); } } @@ -46,3 +47,26 @@ void register_text_server_fb_types() { void unregister_text_server_fb_types() { } + +#ifdef GDEXTENSION + +#include +#include +#include + +using namespace godot; + +extern "C" { + +GDNativeBool GDN_EXPORT textserver_fallback_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { + GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); + + init_obj.register_server_initializer(&preregister_text_server_fb_types); + init_obj.register_server_terminator(&unregister_text_server_fb_types); + + return init_obj.init(); +} + +} // ! extern "C" + +#endif // ! GDEXTENSION diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 0d7a9d0db8a..6c2e5a60849 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -30,12 +30,29 @@ #include "text_server_fb.h" +#ifdef GDEXTENSION +// Headers for building as GDExtension plug-in. + +#include +#include +#include +#include + +using namespace godot; + +#else +// Headers for building as built-in module. + #include "core/error/error_macros.h" #include "core/string/print_string.h" #include "core/string/ucaps.h" #include "modules/modules_enabled.gen.h" // For freetype, msdfgen. +#endif + +// Thirdparty headers. + #ifdef MODULE_MSDFGEN_ENABLED #include "core/ShapeDistanceFinder.h" #include "core/contour-combiners.h" @@ -45,22 +62,46 @@ /*************************************************************************/ -String TextServerFallback::interface_name = "Fallback"; -uint32_t TextServerFallback::interface_features = 0; // Nothing is supported. +#define OT_TAG(c1, c2, c3, c4) ((int32_t)((((uint32_t)(c1)&0xff) << 24) | (((uint32_t)(c2)&0xff) << 16) | (((uint32_t)(c3)&0xff) << 8) | ((uint32_t)(c4)&0xff))) bool TextServerFallback::has_feature(Feature p_feature) const { - return (interface_features & p_feature) == p_feature; + switch (p_feature) { + case FEATURE_SIMPLE_LAYOUT: + case FEATURE_FONT_BITMAP: +#ifdef MODULE_FREETYPE_ENABLED + case FEATURE_FONT_DYNAMIC: +#endif +#ifdef MODULE_MSDFGEN_ENABLED + case FEATURE_FONT_MSDF: +#endif + return true; + default: { + } + } + return false; } String TextServerFallback::get_name() const { - return interface_name; +#ifdef GDEXTENSION + return "Fallback (GDExtension)"; +#else + return "Fallback (Built-in)"; +#endif } -uint32_t TextServerFallback::get_features() const { +int64_t TextServerFallback::get_features() const { + int64_t interface_features = FEATURE_SIMPLE_LAYOUT | FEATURE_FONT_BITMAP; +#ifdef MODULE_FREETYPE_ENABLED + interface_features |= FEATURE_FONT_DYNAMIC; +#endif +#ifdef MODULE_MSDFGEN_ENABLED + interface_features |= FEATURE_FONT_MSDF; +#endif + return interface_features; } -void TextServerFallback::free(RID p_rid) { +void TextServerFallback::free_rid(const RID &p_rid) { _THREAD_SAFE_METHOD_ if (font_owner.owns(p_rid)) { FontDataFallback *fd = font_owner.get_or_null(p_rid); @@ -73,7 +114,7 @@ void TextServerFallback::free(RID p_rid) { } } -bool TextServerFallback::has(RID p_rid) { +bool TextServerFallback::has(const RID &p_rid) { _THREAD_SAFE_METHOD_ return font_owner.owns(p_rid) || shaped_owner.owns(p_rid); } @@ -90,13 +131,18 @@ bool TextServerFallback::is_locale_right_to_left(const String &p_locale) const { return false; // No RTL support. } +_FORCE_INLINE_ void TextServerFallback::_insert_feature(const StringName &p_name, int32_t p_tag) { + feature_sets.insert(p_name, p_tag); + feature_sets_inv.insert(p_tag, p_name); +} + void TextServerFallback::_insert_feature_sets() { // Registered OpenType variation tag. - feature_sets.insert("italic", OT_TAG('i', 't', 'a', 'l')); - feature_sets.insert("optical_size", OT_TAG('o', 'p', 's', 'z')); - feature_sets.insert("slant", OT_TAG('s', 'l', 'n', 't')); - feature_sets.insert("width", OT_TAG('w', 'd', 't', 'h')); - feature_sets.insert("weight", OT_TAG('w', 'g', 'h', 't')); + _insert_feature("italic", OT_TAG('i', 't', 'a', 'l')); + _insert_feature("optical_size", OT_TAG('o', 'p', 's', 'z')); + _insert_feature("slant", OT_TAG('s', 'l', 'n', 't')); + _insert_feature("width", OT_TAG('w', 'd', 't', 'h')); + _insert_feature("weight", OT_TAG('w', 'g', 'h', 't')); } _FORCE_INLINE_ int32_t ot_tag_from_string(const char *p_str, int p_len) { @@ -121,7 +167,7 @@ _FORCE_INLINE_ int32_t ot_tag_from_string(const char *p_str, int p_len) { return OT_TAG(tag[0], tag[1], tag[2], tag[3]); } -int32_t TextServerFallback::name_to_tag(const String &p_name) const { +int64_t TextServerFallback::name_to_tag(const String &p_name) const { if (feature_sets.has(p_name)) { return feature_sets[p_name]; } @@ -137,11 +183,9 @@ _FORCE_INLINE_ void ot_tag_to_string(int32_t p_tag, char *p_buf) { p_buf[3] = (char)(uint8_t)(p_tag >> 0); } -String TextServerFallback::tag_to_name(int32_t p_tag) const { - for (const KeyValue &E : feature_sets) { - if (E.value == p_tag) { - return E.key; - } +String TextServerFallback::tag_to_name(int64_t p_tag) const { + if (feature_sets_inv.has(p_tag)) { + return feature_sets_inv[p_tag]; } // No readable name, use tag string. @@ -179,7 +223,7 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_ continue; } - ret.y = 0x7FFFFFFF; + ret.y = 0x7fffffff; ret.x = 0; for (int j = 0; j < ct.texture_w - mw; j++) { @@ -198,7 +242,7 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_ } } - if (ret.y == 0x7FFFFFFF || ret.y + mh > ct.texture_h) { + if (ret.y == 0x7fffffff || ret.y + mh > ct.texture_h) { continue; // Fail, could not fit it here. } @@ -219,7 +263,11 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_ texsize = mh; // Special case, adapt to it? } +#ifdef GDEXTENSION + texsize = Math::next_power_of_2(texsize); +#else texsize = next_power_of_2(texsize); +#endif if (p_msdf) { texsize = MIN(texsize, 2048); @@ -256,8 +304,9 @@ _FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_ } } tex.offsets.resize(texsize); + int32_t *offw = tex.offsets.ptrw(); for (int i = 0; i < texsize; i++) { // Zero offsets. - tex.offsets.write[i] = 0; + offw[i] = 0; } p_data->textures.push_back(tex); @@ -435,7 +484,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf( // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, Image::FORMAT_RGBA8, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, Image::FORMAT_RGBA8, tex.imgdata); if (tex.texture.is_null()) { tex.texture.instantiate(); tex.texture->create_from_image(img); @@ -446,8 +497,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf( } // Update height array. + int32_t *offw = tex.offsets.ptrw(); for (int k = tex_pos.x; k < tex_pos.x + mw; k++) { - tex.offsets.write[k] = tex_pos.y + mh; + offw[k] = tex_pos.y + mh; } chr.texture_idx = tex_pos.index; @@ -507,7 +559,7 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma wr[ofs + 3] = bitmap.buffer[ofs_color + 3]; } break; default: - ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + itos(bitmap.pixel_mode) + "."); + ERR_FAIL_V_MSG(FontGlyph(), "Font uses unsupported pixel format: " + String::num_int64(bitmap.pixel_mode) + "."); break; } } @@ -517,7 +569,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, require_format, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, require_format, tex.imgdata); if (tex.texture.is_null()) { tex.texture.instantiate(); @@ -529,8 +583,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma } // Update height array. + int32_t *offw = tex.offsets.ptrw(); for (int k = tex_pos.x; k < tex_pos.x + mw; k++) { - tex.offsets.write[k] = tex_pos.y + mh; + offw[k] = tex_pos.y + mh; } FontGlyph chr; @@ -552,7 +607,7 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_data, const Vector2i &p_size, int32_t p_glyph) const { ERR_FAIL_COND_V(!_ensure_cache_for_size(p_font_data, p_size), false); - int32_t glyph_index = p_glyph & 0xFFFFFF; // Remove subpixel shifts. + int32_t glyph_index = p_glyph & 0xffffff; // Remove subpixel shifts. FontDataForSizeFallback *fd = p_font_data->cache[p_size]; if (fd->glyph_map.has(p_glyph)) { @@ -641,7 +696,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_d } } else { FT_Stroker stroker; - if (FT_Stroker_New(library, &stroker) != 0) { + if (FT_Stroker_New(ft_library, &stroker) != 0) { fd->glyph_map[p_glyph] = FontGlyph(); ERR_FAIL_V_MSG(false, "FreeType: Failed to load glyph stroker."); } @@ -687,8 +742,8 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback // Init dynamic font. #ifdef MODULE_FREETYPE_ENABLED int error = 0; - if (!library) { - error = FT_Init_FreeType(&library); + if (!ft_library) { + error = FT_Init_FreeType(&ft_library); ERR_FAIL_COND_V_MSG(error != 0, false, "FreeType: Error initializing library: '" + String(FT_Error_String(error)) + "'."); } @@ -703,7 +758,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback fargs.memory_size = p_font_data->data_size; fargs.flags = FT_OPEN_MEMORY; fargs.stream = &fd->stream; - error = FT_Open_Face(library, &fargs, 0, &fd->face); + error = FT_Open_Face(ft_library, &fargs, 0, &fd->face); if (error) { FT_Done_Face(fd->face); fd->face = nullptr; @@ -711,9 +766,9 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback } if (p_font_data->msdf) { - fd->oversampling = 1.0f; + fd->oversampling = 1.0; fd->size.x = p_font_data->msdf_source_size; - } else if (p_font_data->oversampling <= 0.0f) { + } else if (p_font_data->oversampling <= 0.0) { fd->oversampling = font_get_global_oversampling(); } else { fd->oversampling = p_font_data->oversampling; @@ -722,19 +777,19 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback if (FT_HAS_COLOR(fd->face) && fd->face->num_fixed_sizes > 0) { int best_match = 0; int diff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[0].width)); - fd->scale = float(fd->size.x * fd->oversampling) / fd->face->available_sizes[0].width; + fd->scale = double(fd->size.x * fd->oversampling) / fd->face->available_sizes[0].width; for (int i = 1; i < fd->face->num_fixed_sizes; i++) { int ndiff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[i].width)); if (ndiff < diff) { best_match = i; diff = ndiff; - fd->scale = float(fd->size.x * fd->oversampling) / fd->face->available_sizes[i].width; + fd->scale = double(fd->size.x * fd->oversampling) / fd->face->available_sizes[i].width; } } FT_Select_Size(fd->face, best_match); } else { FT_Set_Pixel_Sizes(fd->face, 0, Math::round(fd->size.x * fd->oversampling)); - fd->scale = ((float)fd->size.x * fd->oversampling) / (float)fd->face->size->metrics.y_ppem; + fd->scale = ((double)fd->size.x * fd->oversampling) / (double)fd->face->size->metrics.y_ppem; } fd->ascent = (fd->face->size->metrics.ascender / 64.0) / fd->oversampling * fd->scale; @@ -768,7 +823,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback for (FT_UInt i = 0; i < amaster->num_axis; i++) { p_font_data->supported_varaitions[(int32_t)amaster->axis[i].tag] = Vector3i(amaster->axis[i].minimum / 65536, amaster->axis[i].maximum / 65536, amaster->axis[i].def / 65536); } - FT_Done_MM_Var(library, amaster); + FT_Done_MM_Var(ft_library, amaster); } p_font_data->face_init = true; } @@ -787,22 +842,22 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontDataFallback for (FT_UInt i = 0; i < amaster->num_axis; i++) { // Reset to default. int32_t var_tag = amaster->axis[i].tag; - float var_value = (double)amaster->axis[i].def / 65536.f; + double var_value = (double)amaster->axis[i].def / 65536.0; coords.write[i] = amaster->axis[i].def; if (p_font_data->variation_coordinates.has(var_tag)) { var_value = p_font_data->variation_coordinates[var_tag]; - coords.write[i] = CLAMP(var_value * 65536.f, amaster->axis[i].minimum, amaster->axis[i].maximum); + coords.write[i] = CLAMP(var_value * 65536.0, amaster->axis[i].minimum, amaster->axis[i].maximum); } if (p_font_data->variation_coordinates.has(tag_to_name(var_tag))) { var_value = p_font_data->variation_coordinates[tag_to_name(var_tag)]; - coords.write[i] = CLAMP(var_value * 65536.f, amaster->axis[i].minimum, amaster->axis[i].maximum); + coords.write[i] = CLAMP(var_value * 65536.0, amaster->axis[i].minimum, amaster->axis[i].maximum); } } FT_Set_Var_Design_Coordinates(fd->face, coords.size(), coords.ptrw()); - FT_Done_MM_Var(library, amaster); + FT_Done_MM_Var(ft_library, amaster); } #else ERR_FAIL_V_MSG(false, "FreeType: Can't load dynamic font, engine is compiled without FreeType support!"); @@ -828,7 +883,7 @@ RID TextServerFallback::create_font() { return font_owner.make_rid(fd); } -void TextServerFallback::font_set_data(RID p_font_rid, const PackedByteArray &p_data) { +void TextServerFallback::font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -839,18 +894,18 @@ void TextServerFallback::font_set_data(RID p_font_rid, const PackedByteArray &p_ fd->data_size = fd->data.size(); } -void TextServerFallback::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) { +void TextServerFallback::font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); _font_clear_cache(fd); - fd->data.clear(); + fd->data.resize(0); fd->data_ptr = p_data_ptr; fd->data_size = p_data_size; } -void TextServerFallback::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { +void TextServerFallback::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -860,7 +915,7 @@ void TextServerFallback::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p fd->style_flags = p_style; } -uint32_t /*FontStyle*/ TextServerFallback::font_get_style(RID p_font_rid) const { +int64_t /*FontStyle*/ TextServerFallback::font_get_style(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -870,7 +925,7 @@ uint32_t /*FontStyle*/ TextServerFallback::font_get_style(RID p_font_rid) const return fd->style_flags; } -void TextServerFallback::font_set_style_name(RID p_font_rid, const String &p_name) { +void TextServerFallback::font_set_style_name(const RID &p_font_rid, const String &p_name) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -880,7 +935,7 @@ void TextServerFallback::font_set_style_name(RID p_font_rid, const String &p_nam fd->style_name = p_name; } -String TextServerFallback::font_get_style_name(RID p_font_rid) const { +String TextServerFallback::font_get_style_name(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -890,7 +945,7 @@ String TextServerFallback::font_get_style_name(RID p_font_rid) const { return fd->style_name; } -void TextServerFallback::font_set_name(RID p_font_rid, const String &p_name) { +void TextServerFallback::font_set_name(const RID &p_font_rid, const String &p_name) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -900,7 +955,7 @@ void TextServerFallback::font_set_name(RID p_font_rid, const String &p_name) { fd->font_name = p_name; } -String TextServerFallback::font_get_name(RID p_font_rid) const { +String TextServerFallback::font_get_name(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -910,7 +965,7 @@ String TextServerFallback::font_get_name(RID p_font_rid) const { return fd->font_name; } -void TextServerFallback::font_set_antialiased(RID p_font_rid, bool p_antialiased) { +void TextServerFallback::font_set_antialiased(const RID &p_font_rid, bool p_antialiased) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -921,7 +976,7 @@ void TextServerFallback::font_set_antialiased(RID p_font_rid, bool p_antialiased } } -bool TextServerFallback::font_is_antialiased(RID p_font_rid) const { +bool TextServerFallback::font_is_antialiased(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -929,7 +984,7 @@ bool TextServerFallback::font_is_antialiased(RID p_font_rid) const { return fd->antialiased; } -void TextServerFallback::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) { +void TextServerFallback::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -940,7 +995,7 @@ void TextServerFallback::font_set_multichannel_signed_distance_field(RID p_font_ } } -bool TextServerFallback::font_is_multichannel_signed_distance_field(RID p_font_rid) const { +bool TextServerFallback::font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -948,7 +1003,7 @@ bool TextServerFallback::font_is_multichannel_signed_distance_field(RID p_font_r return fd->msdf; } -void TextServerFallback::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) { +void TextServerFallback::font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -959,7 +1014,7 @@ void TextServerFallback::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pi } } -int TextServerFallback::font_get_msdf_pixel_range(RID p_font_rid) const { +int64_t TextServerFallback::font_get_msdf_pixel_range(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -967,7 +1022,7 @@ int TextServerFallback::font_get_msdf_pixel_range(RID p_font_rid) const { return fd->msdf_range; } -void TextServerFallback::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { +void TextServerFallback::font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -978,7 +1033,7 @@ void TextServerFallback::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { } } -int TextServerFallback::font_get_msdf_size(RID p_font_rid) const { +int64_t TextServerFallback::font_get_msdf_size(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -986,7 +1041,7 @@ int TextServerFallback::font_get_msdf_size(RID p_font_rid) const { return fd->msdf_source_size; } -void TextServerFallback::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { +void TextServerFallback::font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -996,7 +1051,7 @@ void TextServerFallback::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { } } -int TextServerFallback::font_get_fixed_size(RID p_font_rid) const { +int64_t TextServerFallback::font_get_fixed_size(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1004,7 +1059,7 @@ int TextServerFallback::font_get_fixed_size(RID p_font_rid) const { return fd->fixed_size; } -void TextServerFallback::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) { +void TextServerFallback::font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1015,7 +1070,7 @@ void TextServerFallback::font_set_force_autohinter(RID p_font_rid, bool p_force_ } } -bool TextServerFallback::font_is_force_autohinter(RID p_font_rid) const { +bool TextServerFallback::font_is_force_autohinter(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -1023,7 +1078,7 @@ bool TextServerFallback::font_is_force_autohinter(RID p_font_rid) const { return fd->force_autohinter; } -void TextServerFallback::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) { +void TextServerFallback::font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1034,7 +1089,7 @@ void TextServerFallback::font_set_hinting(RID p_font_rid, TextServer::Hinting p_ } } -TextServer::Hinting TextServerFallback::font_get_hinting(RID p_font_rid) const { +TextServer::Hinting TextServerFallback::font_get_hinting(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, HINTING_NONE); @@ -1042,7 +1097,7 @@ TextServer::Hinting TextServerFallback::font_get_hinting(RID p_font_rid) const { return fd->hinting; } -void TextServerFallback::font_set_subpixel_positioning(RID p_font_rid, TextServer::SubpixelPositioning p_subpixel) { +void TextServerFallback::font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1052,7 +1107,7 @@ void TextServerFallback::font_set_subpixel_positioning(RID p_font_rid, TextServe } } -TextServer::SubpixelPositioning TextServerFallback::font_get_subpixel_positioning(RID p_font_rid) const { +TextServer::SubpixelPositioning TextServerFallback::font_get_subpixel_positioning(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, SUBPIXEL_POSITIONING_DISABLED); @@ -1060,7 +1115,7 @@ TextServer::SubpixelPositioning TextServerFallback::font_get_subpixel_positionin return fd->subpixel_positioning; } -void TextServerFallback::font_set_embolden(RID p_font_rid, float p_strength) { +void TextServerFallback::font_set_embolden(const RID &p_font_rid, double p_strength) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1071,15 +1126,15 @@ void TextServerFallback::font_set_embolden(RID p_font_rid, float p_strength) { } } -float TextServerFallback::font_get_embolden(RID p_font_rid) const { +double TextServerFallback::font_get_embolden(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); return fd->embolden; } -void TextServerFallback::font_set_transform(RID p_font_rid, Transform2D p_transform) { +void TextServerFallback::font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1090,7 +1145,7 @@ void TextServerFallback::font_set_transform(RID p_font_rid, Transform2D p_transf } } -Transform2D TextServerFallback::font_get_transform(RID p_font_rid) const { +Transform2D TextServerFallback::font_get_transform(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Transform2D()); @@ -1098,7 +1153,7 @@ Transform2D TextServerFallback::font_get_transform(RID p_font_rid) const { return fd->transform; } -void TextServerFallback::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) { +void TextServerFallback::font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1109,7 +1164,7 @@ void TextServerFallback::font_set_variation_coordinates(RID p_font_rid, const Di } } -Dictionary TextServerFallback::font_get_variation_coordinates(RID p_font_rid) const { +Dictionary TextServerFallback::font_get_variation_coordinates(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -1117,7 +1172,7 @@ Dictionary TextServerFallback::font_get_variation_coordinates(RID p_font_rid) co return fd->variation_coordinates; } -void TextServerFallback::font_set_oversampling(RID p_font_rid, float p_oversampling) { +void TextServerFallback::font_set_oversampling(const RID &p_font_rid, double p_oversampling) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1128,15 +1183,15 @@ void TextServerFallback::font_set_oversampling(RID p_font_rid, float p_oversampl } } -float TextServerFallback::font_get_oversampling(RID p_font_rid) const { +double TextServerFallback::font_get_oversampling(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); return fd->oversampling; } -Array TextServerFallback::font_get_size_cache_list(RID p_font_rid) const { +Array TextServerFallback::font_get_size_cache_list(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); @@ -1148,7 +1203,7 @@ Array TextServerFallback::font_get_size_cache_list(RID p_font_rid) const { return ret; } -void TextServerFallback::font_clear_size_cache(RID p_font_rid) { +void TextServerFallback::font_clear_size_cache(const RID &p_font_rid) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1159,7 +1214,7 @@ void TextServerFallback::font_clear_size_cache(RID p_font_rid) { fd->cache.clear(); } -void TextServerFallback::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) { +void TextServerFallback::font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1170,7 +1225,7 @@ void TextServerFallback::font_remove_size_cache(RID p_font_rid, const Vector2i & } } -void TextServerFallback::font_set_ascent(RID p_font_rid, int p_size, float p_ascent) { +void TextServerFallback::font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1181,23 +1236,23 @@ void TextServerFallback::font_set_ascent(RID p_font_rid, int p_size, float p_asc fd->cache[size]->ascent = p_ascent; } -float TextServerFallback::font_get_ascent(RID p_font_rid, int p_size) const { +double TextServerFallback::font_get_ascent(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->ascent * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->ascent * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->ascent; } } -void TextServerFallback::font_set_descent(RID p_font_rid, int p_size, float p_descent) { +void TextServerFallback::font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1207,23 +1262,23 @@ void TextServerFallback::font_set_descent(RID p_font_rid, int p_size, float p_de fd->cache[size]->descent = p_descent; } -float TextServerFallback::font_get_descent(RID p_font_rid, int p_size) const { +double TextServerFallback::font_get_descent(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->descent * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->descent * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->descent; } } -void TextServerFallback::font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) { +void TextServerFallback::font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1234,23 +1289,23 @@ void TextServerFallback::font_set_underline_position(RID p_font_rid, int p_size, fd->cache[size]->underline_position = p_underline_position; } -float TextServerFallback::font_get_underline_position(RID p_font_rid, int p_size) const { +double TextServerFallback::font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->underline_position * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->underline_position * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->underline_position; } } -void TextServerFallback::font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) { +void TextServerFallback::font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1261,23 +1316,23 @@ void TextServerFallback::font_set_underline_thickness(RID p_font_rid, int p_size fd->cache[size]->underline_thickness = p_underline_thickness; } -float TextServerFallback::font_get_underline_thickness(RID p_font_rid, int p_size) const { +double TextServerFallback::font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->underline_thickness * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->underline_thickness * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->underline_thickness; } } -void TextServerFallback::font_set_scale(RID p_font_rid, int p_size, float p_scale) { +void TextServerFallback::font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1288,23 +1343,23 @@ void TextServerFallback::font_set_scale(RID p_font_rid, int p_size, float p_scal fd->cache[size]->scale = p_scale; } -float TextServerFallback::font_get_scale(RID p_font_rid, int p_size) const { +double TextServerFallback::font_get_scale(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.f); + ERR_FAIL_COND_V(!fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); - ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.f); + ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), 0.0); if (fd->msdf) { - return fd->cache[size]->scale * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->scale * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->scale / fd->cache[size]->oversampling; } } -void TextServerFallback::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) { +void TextServerFallback::font_set_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing, int64_t p_value) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1320,12 +1375,12 @@ void TextServerFallback::font_set_spacing(RID p_font_rid, int p_size, TextServer fd->cache[size]->spacing_space = p_value; } break; default: { - ERR_FAIL_MSG("Invalid spacing type: " + itos(p_spacing)); + ERR_FAIL_MSG("Invalid spacing type: " + String::num_int64(p_spacing)); } break; } } -int TextServerFallback::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const { +int64_t TextServerFallback::font_get_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -1337,26 +1392,26 @@ int TextServerFallback::font_get_spacing(RID p_font_rid, int p_size, TextServer: switch (p_spacing) { case TextServer::SPACING_GLYPH: { if (fd->msdf) { - return fd->cache[size]->spacing_glyph * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->spacing_glyph * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->spacing_glyph; } } break; case TextServer::SPACING_SPACE: { if (fd->msdf) { - return fd->cache[size]->spacing_space * (float)p_size / (float)fd->msdf_source_size; + return fd->cache[size]->spacing_space * (double)p_size / (double)fd->msdf_source_size; } else { return fd->cache[size]->spacing_space; } } break; default: { - ERR_FAIL_V_MSG(0, "Invalid spacing type: " + itos(p_spacing)); + ERR_FAIL_V_MSG(0, "Invalid spacing type: " + String::num_int64(p_spacing)); } break; } return 0; } -int TextServerFallback::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const { +int64_t TextServerFallback::font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, 0); @@ -1368,7 +1423,7 @@ int TextServerFallback::font_get_texture_count(RID p_font_rid, const Vector2i &p return fd->cache[size]->textures.size(); } -void TextServerFallback::font_clear_textures(RID p_font_rid, const Vector2i &p_size) { +void TextServerFallback::font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); MutexLock lock(fd->mutex); @@ -1378,7 +1433,7 @@ void TextServerFallback::font_clear_textures(RID p_font_rid, const Vector2i &p_s fd->cache[size]->textures.clear(); } -void TextServerFallback::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) { +void TextServerFallback::font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1390,7 +1445,7 @@ void TextServerFallback::font_remove_texture(RID p_font_rid, const Vector2i &p_s fd->cache[size]->textures.remove_at(p_texture_index); } -void TextServerFallback::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) { +void TextServerFallback::font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); ERR_FAIL_COND(p_image.is_null()); @@ -1410,13 +1465,16 @@ void TextServerFallback::font_set_texture_image(RID p_font_rid, const Vector2i & tex.texture_h = p_image->get_height(); tex.format = p_image->get_format(); - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata)); + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata); + tex.texture = Ref(); tex.texture.instantiate(); tex.texture->create_from_image(img); } -Ref TextServerFallback::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +Ref TextServerFallback::font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Ref()); @@ -1425,13 +1483,15 @@ Ref TextServerFallback::font_get_texture_image(RID p_font_rid, const Vect ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Ref()); ERR_FAIL_INDEX_V(p_texture_index, fd->cache[size]->textures.size(), Ref()); - const FontTexture &tex = fd->cache[size]->textures.write[p_texture_index]; - Ref img = memnew(Image(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata)); + const FontTexture &tex = fd->cache[size]->textures[p_texture_index]; + Ref img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata); return img; } -void TextServerFallback::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) { +void TextServerFallback::font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1447,7 +1507,7 @@ void TextServerFallback::font_set_texture_offsets(RID p_font_rid, const Vector2i tex.offsets = p_offset; } -PackedInt32Array TextServerFallback::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +PackedInt32Array TextServerFallback::font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, PackedInt32Array()); @@ -1456,11 +1516,11 @@ PackedInt32Array TextServerFallback::font_get_texture_offsets(RID p_font_rid, co ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), PackedInt32Array()); ERR_FAIL_INDEX_V(p_texture_index, fd->cache[size]->textures.size(), PackedInt32Array()); - const FontTexture &tex = fd->cache[size]->textures.write[p_texture_index]; + const FontTexture &tex = fd->cache[size]->textures[p_texture_index]; return tex.offsets; } -Array TextServerFallback::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const { +Array TextServerFallback::font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); @@ -1477,7 +1537,7 @@ Array TextServerFallback::font_get_glyph_list(RID p_font_rid, const Vector2i &p_ return ret; } -void TextServerFallback::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) { +void TextServerFallback::font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1488,7 +1548,7 @@ void TextServerFallback::font_clear_glyphs(RID p_font_rid, const Vector2i &p_siz fd->cache[size]->glyph_map.clear(); } -void TextServerFallback::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) { +void TextServerFallback::font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1499,7 +1559,7 @@ void TextServerFallback::font_remove_glyph(RID p_font_rid, const Vector2i &p_siz fd->cache[size]->glyph_map.erase(p_glyph); } -Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const { +Vector2 TextServerFallback::font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -1515,11 +1575,11 @@ Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, i Vector2 ea; if (fd->embolden != 0.0) { - ea.x = fd->embolden * float(size.x) / 64.0; + ea.x = fd->embolden * double(size.x) / 64.0; } if (fd->msdf) { - return (gl[p_glyph].advance + ea) * (float)p_size / (float)fd->msdf_source_size; + return (gl[p_glyph].advance + ea) * (double)p_size / (double)fd->msdf_source_size; } else if ((fd->subpixel_positioning == SUBPIXEL_POSITIONING_DISABLED) || (fd->subpixel_positioning == SUBPIXEL_POSITIONING_AUTO && size.x > SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE)) { return (gl[p_glyph].advance + ea).round(); } else { @@ -1527,7 +1587,7 @@ Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, i } } -void TextServerFallback::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) { +void TextServerFallback::font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1542,7 +1602,7 @@ void TextServerFallback::font_set_glyph_advance(RID p_font_rid, int p_size, int3 gl[p_glyph].found = true; } -Vector2 TextServerFallback::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerFallback::font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -1557,13 +1617,13 @@ Vector2 TextServerFallback::font_get_glyph_offset(RID p_font_rid, const Vector2i const HashMap &gl = fd->cache[size]->glyph_map; if (fd->msdf) { - return gl[p_glyph].rect.position * (float)p_size.x / (float)fd->msdf_source_size; + return gl[p_glyph].rect.position * (double)p_size.x / (double)fd->msdf_source_size; } else { return gl[p_glyph].rect.position; } } -void TextServerFallback::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) { +void TextServerFallback::font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1578,7 +1638,7 @@ void TextServerFallback::font_set_glyph_offset(RID p_font_rid, const Vector2i &p gl[p_glyph].found = true; } -Vector2 TextServerFallback::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerFallback::font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -1593,13 +1653,13 @@ Vector2 TextServerFallback::font_get_glyph_size(RID p_font_rid, const Vector2i & const HashMap &gl = fd->cache[size]->glyph_map; if (fd->msdf) { - return gl[p_glyph].rect.size * (float)p_size.x / (float)fd->msdf_source_size; + return gl[p_glyph].rect.size * (double)p_size.x / (double)fd->msdf_source_size; } else { return gl[p_glyph].rect.size; } } -void TextServerFallback::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) { +void TextServerFallback::font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1614,7 +1674,7 @@ void TextServerFallback::font_set_glyph_size(RID p_font_rid, const Vector2i &p_s gl[p_glyph].found = true; } -Rect2 TextServerFallback::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Rect2 TextServerFallback::font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Rect2()); @@ -1630,7 +1690,7 @@ Rect2 TextServerFallback::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i return gl[p_glyph].uv_rect; } -void TextServerFallback::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) { +void TextServerFallback::font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1645,7 +1705,7 @@ void TextServerFallback::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i & gl[p_glyph].found = true; } -int TextServerFallback::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +int64_t TextServerFallback::font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, -1); @@ -1661,7 +1721,7 @@ int TextServerFallback::font_get_glyph_texture_idx(RID p_font_rid, const Vector2 return gl[p_glyph].texture_idx; } -void TextServerFallback::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) { +void TextServerFallback::font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1676,7 +1736,7 @@ void TextServerFallback::font_set_glyph_texture_idx(RID p_font_rid, const Vector gl[p_glyph].found = true; } -Dictionary TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index) const { +Dictionary TextServerFallback::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -1685,20 +1745,19 @@ Dictionary TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_siz ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Dictionary()); - Vector points; - Vector contours; + PackedVector3Array points; + PackedInt32Array contours; bool orientation; #ifdef MODULE_FREETYPE_ENABLED - int error = FT_Load_Glyph(fd->cache[size]->face, FT_Get_Char_Index(fd->cache[size]->face, p_index), FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)); + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. + + int error = FT_Load_Glyph(fd->cache[size]->face, FT_Get_Char_Index(fd->cache[size]->face, index), FT_LOAD_NO_BITMAP | (fd->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)); ERR_FAIL_COND_V(error, Dictionary()); - points.clear(); - contours.clear(); - - float h = fd->cache[size]->ascent; - float scale = (1.0 / 64.0) / fd->cache[size]->oversampling * fd->cache[size]->scale; + double h = fd->cache[size]->ascent; + double scale = (1.0 / 64.0) / fd->cache[size]->oversampling * fd->cache[size]->scale; if (fd->msdf) { - scale = scale * (float)p_size / (float)fd->msdf_source_size; + scale = scale * (double)p_size / (double)fd->msdf_source_size; } for (short i = 0; i < fd->cache[size]->face->glyph->outline.n_points; i++) { points.push_back(Vector3(fd->cache[size]->face->glyph->outline.points[i].x * scale, h - fd->cache[size]->face->glyph->outline.points[i].y * scale, FT_CURVE_TAG(fd->cache[size]->face->glyph->outline.tags[i]))); @@ -1718,7 +1777,7 @@ Dictionary TextServerFallback::font_get_glyph_contours(RID p_font_rid, int p_siz return out; } -Array TextServerFallback::font_get_kerning_list(RID p_font_rid, int p_size) const { +Array TextServerFallback::font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Array()); @@ -1734,7 +1793,7 @@ Array TextServerFallback::font_get_kerning_list(RID p_font_rid, int p_size) cons return ret; } -void TextServerFallback::font_clear_kerning_map(RID p_font_rid, int p_size) { +void TextServerFallback::font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1745,7 +1804,7 @@ void TextServerFallback::font_clear_kerning_map(RID p_font_rid, int p_size) { fd->cache[size]->kerning_map.clear(); } -void TextServerFallback::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) { +void TextServerFallback::font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1756,7 +1815,7 @@ void TextServerFallback::font_remove_kerning(RID p_font_rid, int p_size, const V fd->cache[size]->kerning_map.erase(p_glyph_pair); } -void TextServerFallback::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { +void TextServerFallback::font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1767,7 +1826,7 @@ void TextServerFallback::font_set_kerning(RID p_font_rid, int p_size, const Vect fd->cache[size]->kerning_map[p_glyph_pair] = p_kerning; } -Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const { +Vector2 TextServerFallback::font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Vector2()); @@ -1780,7 +1839,7 @@ Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const V if (kern.has(p_glyph_pair)) { if (fd->msdf) { - return kern[p_glyph_pair] * (float)p_size / (float)fd->msdf_source_size; + return kern[p_glyph_pair] * (double)p_size / (double)fd->msdf_source_size; } else { return kern[p_glyph_pair]; } @@ -1792,7 +1851,7 @@ Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const V int32_t glyph_b = FT_Get_Char_Index(fd->cache[size]->face, p_glyph_pair.y); FT_Get_Kerning(fd->cache[size]->face, glyph_a, glyph_b, FT_KERNING_DEFAULT, &delta); if (fd->msdf) { - return Vector2(delta.x, delta.y) * (float)p_size / (float)fd->msdf_source_size; + return Vector2(delta.x, delta.y) * (double)p_size / (double)fd->msdf_source_size; } else { return Vector2(delta.x, delta.y); } @@ -1802,12 +1861,12 @@ Vector2 TextServerFallback::font_get_kerning(RID p_font_rid, int p_size, const V return Vector2(); } -int32_t TextServerFallback::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const { +int64_t TextServerFallback::font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const { ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); - return (int32_t)p_char; + return (int64_t)p_char; } -bool TextServerFallback::font_has_char(RID p_font_rid, char32_t p_char) const { +bool TextServerFallback::font_has_char(const RID &p_font_rid, int64_t p_char) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), false, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); @@ -1826,7 +1885,7 @@ bool TextServerFallback::font_has_char(RID p_font_rid, char32_t p_char) const { return (at_size) ? at_size->glyph_map.has((int32_t)p_char) : false; } -String TextServerFallback::font_get_supported_chars(RID p_font_rid) const { +String TextServerFallback::font_get_supported_chars(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, String()); @@ -1843,7 +1902,7 @@ String TextServerFallback::font_get_supported_chars(RID p_font_rid) const { FT_ULong charcode = FT_Get_First_Char(at_size->face, &gindex); while (gindex != 0) { if (charcode != 0) { - chars += char32_t(charcode); + chars = chars + String::chr(charcode); } charcode = FT_Get_Next_Char(at_size->face, charcode, &gindex); } @@ -1854,13 +1913,13 @@ String TextServerFallback::font_get_supported_chars(RID p_font_rid) const { const HashMap &gl = at_size->glyph_map; const int32_t *E = nullptr; while ((E = gl.next(E))) { - chars += char32_t(*E); + chars = chars + String::chr(*E); } } return chars; } -void TextServerFallback::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) { +void TextServerFallback::font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); ERR_FAIL_COND_MSG((p_start >= 0xd800 && p_start <= 0xdfff) || (p_start > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_start, 16) + "."); @@ -1869,7 +1928,7 @@ void TextServerFallback::font_render_range(RID p_font_rid, const Vector2i &p_siz MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - for (char32_t i = p_start; i <= p_end; i++) { + for (int64_t i = p_start; i <= p_end; i++) { #ifdef MODULE_FREETYPE_ENABLED int32_t idx = i; if (fd->cache[size]->face) { @@ -1893,7 +1952,7 @@ void TextServerFallback::font_render_range(RID p_font_rid, const Vector2i &p_siz } } -void TextServerFallback::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) { +void TextServerFallback::font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1901,7 +1960,7 @@ void TextServerFallback::font_render_glyph(RID p_font_rid, const Vector2i &p_siz Vector2i size = _get_size_outline(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); #ifdef MODULE_FREETYPE_ENABLED - int32_t idx = p_index; + int32_t idx = p_index & 0xffffff; // Remove subpixel shifts. if (fd->cache[size]->face) { if (fd->msdf) { _ensure_glyph(fd, size, (int32_t)idx); @@ -1922,7 +1981,7 @@ void TextServerFallback::font_render_glyph(RID p_font_rid, const Vector2i &p_siz #endif } -void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { +void TextServerFallback::font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1930,7 +1989,7 @@ void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz Vector2i size = _get_size(fd, p_size); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - int32_t index = p_index; + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. #ifdef MODULE_FREETYPE_ENABLED if (!fd->msdf && fd->cache[size]->face) { @@ -1963,8 +2022,8 @@ void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz RID texture = fd->cache[size]->textures[gl.texture_idx].texture->get_rid(); if (fd->msdf) { Point2 cpos = p_pos; - cpos += gl.rect.position * (float)p_size / (float)fd->msdf_source_size; - Size2 csize = gl.rect.size * (float)p_size / (float)fd->msdf_source_size; + cpos += gl.rect.position * (double)p_size / (double)fd->msdf_source_size; + Size2 csize = gl.rect.size * (double)p_size / (double)fd->msdf_source_size; RenderingServer::get_singleton()->canvas_item_add_msdf_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate, 0, fd->msdf_range); } else { Point2 cpos = p_pos; @@ -1985,7 +2044,7 @@ void TextServerFallback::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_siz } } -void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { +void TextServerFallback::font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -1993,7 +2052,7 @@ void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i Vector2i size = _get_size_outline(fd, Vector2i(p_size, p_outline_size)); ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); - int32_t index = p_index; + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. #ifdef MODULE_FREETYPE_ENABLED if (!fd->msdf && fd->cache[size]->face) { @@ -2026,8 +2085,8 @@ void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i RID texture = fd->cache[size]->textures[gl.texture_idx].texture->get_rid(); if (fd->msdf) { Point2 cpos = p_pos; - cpos += gl.rect.position * (float)p_size / (float)fd->msdf_source_size; - Size2 csize = gl.rect.size * (float)p_size / (float)fd->msdf_source_size; + cpos += gl.rect.position * (double)p_size / (double)fd->msdf_source_size; + Size2 csize = gl.rect.size * (double)p_size / (double)fd->msdf_source_size; RenderingServer::get_singleton()->canvas_item_add_msdf_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate, p_outline_size * 2, fd->msdf_range); } else { Point2 cpos = p_pos; @@ -2048,7 +2107,7 @@ void TextServerFallback::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, i } } -bool TextServerFallback::font_is_language_supported(RID p_font_rid, const String &p_language) const { +bool TextServerFallback::font_is_language_supported(const RID &p_font_rid, const String &p_language) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2060,7 +2119,7 @@ bool TextServerFallback::font_is_language_supported(RID p_font_rid, const String } } -void TextServerFallback::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) { +void TextServerFallback::font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2068,7 +2127,7 @@ void TextServerFallback::font_set_language_support_override(RID p_font_rid, cons fd->language_support_overrides[p_language] = p_supported; } -bool TextServerFallback::font_get_language_support_override(RID p_font_rid, const String &p_language) { +bool TextServerFallback::font_get_language_support_override(const RID &p_font_rid, const String &p_language) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2076,7 +2135,7 @@ bool TextServerFallback::font_get_language_support_override(RID p_font_rid, cons return fd->language_support_overrides[p_language]; } -void TextServerFallback::font_remove_language_support_override(RID p_font_rid, const String &p_language) { +void TextServerFallback::font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2084,19 +2143,19 @@ void TextServerFallback::font_remove_language_support_override(RID p_font_rid, c fd->language_support_overrides.erase(p_language); } -Vector TextServerFallback::font_get_language_support_overrides(RID p_font_rid) { +PackedStringArray TextServerFallback::font_get_language_support_overrides(const RID &p_font_rid) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector out; + PackedStringArray out; for (const KeyValue &E : fd->language_support_overrides) { out.push_back(E.key); } return out; } -bool TextServerFallback::font_is_script_supported(RID p_font_rid, const String &p_script) const { +bool TextServerFallback::font_is_script_supported(const RID &p_font_rid, const String &p_script) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2108,7 +2167,7 @@ bool TextServerFallback::font_is_script_supported(RID p_font_rid, const String & } } -void TextServerFallback::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) { +void TextServerFallback::font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2116,7 +2175,7 @@ void TextServerFallback::font_set_script_support_override(RID p_font_rid, const fd->script_support_overrides[p_script] = p_supported; } -bool TextServerFallback::font_get_script_support_override(RID p_font_rid, const String &p_script) { +bool TextServerFallback::font_get_script_support_override(const RID &p_font_rid, const String &p_script) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, false); @@ -2124,7 +2183,7 @@ bool TextServerFallback::font_get_script_support_override(RID p_font_rid, const return fd->script_support_overrides[p_script]; } -void TextServerFallback::font_remove_script_support_override(RID p_font_rid, const String &p_script) { +void TextServerFallback::font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2134,19 +2193,19 @@ void TextServerFallback::font_remove_script_support_override(RID p_font_rid, con fd->script_support_overrides.erase(p_script); } -Vector TextServerFallback::font_get_script_support_overrides(RID p_font_rid) { +PackedStringArray TextServerFallback::font_get_script_support_overrides(const RID &p_font_rid) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector out; + PackedStringArray out; for (const KeyValue &E : fd->script_support_overrides) { out.push_back(E.key); } return out; } -void TextServerFallback::font_set_opentype_feature_overrides(RID p_font_rid, const Dictionary &p_overrides) { +void TextServerFallback::font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); @@ -2156,7 +2215,7 @@ void TextServerFallback::font_set_opentype_feature_overrides(RID p_font_rid, con fd->feature_overrides = p_overrides; } -Dictionary TextServerFallback::font_get_opentype_feature_overrides(RID p_font_rid) const { +Dictionary TextServerFallback::font_get_opentype_feature_overrides(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -2164,11 +2223,11 @@ Dictionary TextServerFallback::font_get_opentype_feature_overrides(RID p_font_ri return fd->feature_overrides; } -Dictionary TextServerFallback::font_supported_feature_list(RID p_font_rid) const { +Dictionary TextServerFallback::font_supported_feature_list(const RID &p_font_rid) const { return Dictionary(); } -Dictionary TextServerFallback::font_supported_variation_list(RID p_font_rid) const { +Dictionary TextServerFallback::font_supported_variation_list(const RID &p_font_rid) const { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND_V(!fd, Dictionary()); @@ -2178,11 +2237,11 @@ Dictionary TextServerFallback::font_supported_variation_list(RID p_font_rid) con return fd->supported_varaitions; } -float TextServerFallback::font_get_global_oversampling() const { +double TextServerFallback::font_get_global_oversampling() const { return oversampling; } -void TextServerFallback::font_set_global_oversampling(float p_oversampling) { +void TextServerFallback::font_set_global_oversampling(double p_oversampling) { _THREAD_SAFE_METHOD_ if (oversampling != p_oversampling) { oversampling = p_oversampling; @@ -2215,11 +2274,11 @@ void TextServerFallback::invalidate(ShapedTextDataFallback *p_shaped) { p_shaped->sort_valid = false; p_shaped->line_breaks_valid = false; p_shaped->justification_ops_valid = false; - p_shaped->ascent = 0.f; - p_shaped->descent = 0.f; - p_shaped->width = 0.f; - p_shaped->upos = 0.f; - p_shaped->uthk = 0.f; + p_shaped->ascent = 0.0; + p_shaped->descent = 0.0; + p_shaped->width = 0.0; + p_shaped->upos = 0.0; + p_shaped->uthk = 0.0; p_shaped->glyphs.clear(); p_shaped->glyphs_logical.clear(); } @@ -2255,7 +2314,7 @@ RID TextServerFallback::create_shaped_text(TextServer::Direction p_direction, Te return shaped_owner.make_rid(sd); } -void TextServerFallback::shaped_text_clear(RID p_shaped) { +void TextServerFallback::shaped_text_clear(const RID &p_shaped) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -2269,21 +2328,21 @@ void TextServerFallback::shaped_text_clear(RID p_shaped) { invalidate(sd); } -void TextServerFallback::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) { +void TextServerFallback::shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) { if (p_direction == DIRECTION_RTL) { ERR_PRINT_ONCE("Right-to-left layout is not supported by this text server."); } } -TextServer::Direction TextServerFallback::shaped_text_get_direction(RID p_shaped) const { +TextServer::Direction TextServerFallback::shaped_text_get_direction(const RID &p_shaped) const { return TextServer::DIRECTION_LTR; } -TextServer::Direction TextServerFallback::shaped_text_get_inferred_direction(RID p_shaped) const { +TextServer::Direction TextServerFallback::shaped_text_get_inferred_direction(const RID &p_shaped) const { return TextServer::DIRECTION_LTR; } -void TextServerFallback::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { +void TextServerFallback::shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) { _THREAD_SAFE_METHOD_ ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -2297,14 +2356,14 @@ void TextServerFallback::shaped_text_set_custom_punctuation(RID p_shaped, const } } -String TextServerFallback::shaped_text_get_custom_punctuation(RID p_shaped) const { +String TextServerFallback::shaped_text_get_custom_punctuation(const RID &p_shaped) const { _THREAD_SAFE_METHOD_ const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, String()); return sd->custom_punct; } -void TextServerFallback::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) { +void TextServerFallback::shaped_text_set_orientation(const RID &p_shaped, TextServer::Orientation p_orientation) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -2318,11 +2377,11 @@ void TextServerFallback::shaped_text_set_orientation(RID p_shaped, TextServer::O } } -void TextServerFallback::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) { +void TextServerFallback::shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) { // No BiDi support, ignore. } -TextServer::Orientation TextServerFallback::shaped_text_get_orientation(RID p_shaped) const { +TextServer::Orientation TextServerFallback::shaped_text_get_orientation(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, TextServer::ORIENTATION_HORIZONTAL); @@ -2330,7 +2389,7 @@ TextServer::Orientation TextServerFallback::shaped_text_get_orientation(RID p_sh return sd->orientation; } -void TextServerFallback::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) { +void TextServerFallback::shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); MutexLock lock(sd->mutex); @@ -2344,7 +2403,7 @@ void TextServerFallback::shaped_text_set_preserve_invalid(RID p_shaped, bool p_e } } -bool TextServerFallback::shaped_text_get_preserve_invalid(RID p_shaped) const { +bool TextServerFallback::shaped_text_get_preserve_invalid(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -2352,7 +2411,7 @@ bool TextServerFallback::shaped_text_get_preserve_invalid(RID p_shaped) const { return sd->preserve_invalid; } -void TextServerFallback::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) { +void TextServerFallback::shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); @@ -2366,7 +2425,7 @@ void TextServerFallback::shaped_text_set_preserve_control(RID p_shaped, bool p_e } } -bool TextServerFallback::shaped_text_get_preserve_control(RID p_shaped) const { +bool TextServerFallback::shaped_text_get_preserve_control(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -2374,28 +2433,28 @@ bool TextServerFallback::shaped_text_get_preserve_control(RID p_shaped) const { return sd->preserve_control; } -int TextServerFallback::shaped_get_span_count(RID p_shaped) const { +int64_t TextServerFallback::shaped_get_span_count(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, 0); return sd->spans.size(); } -Variant TextServerFallback::shaped_get_span_meta(RID p_shaped, int p_index) const { +Variant TextServerFallback::shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Variant()); ERR_FAIL_INDEX_V(p_index, sd->spans.size(), Variant()); return sd->spans[p_index].meta; } -void TextServerFallback::shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features) { +void TextServerFallback::shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND(!sd); ERR_FAIL_INDEX(p_index, sd->spans.size()); - ShapedTextDataFallback::Span &span = sd->spans.write[p_index]; + ShapedTextDataFallback::Span &span = sd->spans.ptrw()[p_index]; span.fonts.clear(); // Pre-sort fonts, push fonts with the language support first. - Vector fonts_no_match; + Array fonts_no_match; int font_count = p_fonts.size(); for (int i = 0; i < font_count; i++) { if (font_is_language_supported(p_fonts[i], span.language)) { @@ -2411,7 +2470,7 @@ void TextServerFallback::shaped_set_span_update_font(RID p_shaped, int p_index, sd->valid = false; } -bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { +bool TextServerFallback::shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -2435,7 +2494,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te span.end = span.start + p_text.length(); // Pre-sort fonts, push fonts with the language support first. - Vector fonts_no_match; + Array fonts_no_match; int font_count = p_fonts.size(); for (int i = 0; i < font_count; i++) { if (font_is_language_supported(p_fonts[i], p_language)) { @@ -2452,14 +2511,14 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te span.meta = p_meta; sd->spans.push_back(span); - sd->text += p_text; + sd->text = sd->text + p_text; sd->end += p_text.length(); invalidate(sd); return true; } -bool TextServerFallback::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align, int p_length) { +bool TextServerFallback::shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, int64_t p_length) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -2482,7 +2541,7 @@ bool TextServerFallback::shaped_text_add_object(RID p_shaped, Variant p_key, con obj.pos = span.start; sd->spans.push_back(span); - sd->text += String::chr(0xfffc).repeat(p_length); + sd->text = sd->text + String::chr(0xfffc).repeat(p_length); sd->end += p_length; sd->objects[p_key] = obj; invalidate(sd); @@ -2490,7 +2549,7 @@ bool TextServerFallback::shaped_text_add_object(RID p_shaped, Variant p_key, con return true; } -bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align) { +bool TextServerFallback::shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -2544,8 +2603,8 @@ bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, if (sd->orientation == ORIENTATION_HORIZONTAL) { sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y); } else { - sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); - sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); + sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); + sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); } } sd->width += gl.advance * gl.repeat; @@ -2558,8 +2617,8 @@ bool TextServerFallback::shaped_text_resize_object(RID p_shaped, Variant p_key, void TextServerFallback::_realign(ShapedTextDataFallback *p_sd) const { // Align embedded objects to baseline. - float full_ascent = p_sd->ascent; - float full_descent = p_sd->descent; + double full_ascent = p_sd->ascent; + double full_descent = p_sd->descent; for (KeyValue &E : p_sd->objects) { if ((E.value.pos >= p_sd->start) && (E.value.pos < p_sd->end)) { if (p_sd->orientation == ORIENTATION_HORIZONTAL) { @@ -2625,7 +2684,7 @@ void TextServerFallback::_realign(ShapedTextDataFallback *p_sd) const { p_sd->descent = full_descent; } -RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_length) const { +RID TextServerFallback::shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, RID()); @@ -2697,8 +2756,8 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng if (new_sd->orientation == ORIENTATION_HORIZONTAL) { new_sd->ascent = MAX(new_sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y); } else { - new_sd->ascent = MAX(new_sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); - new_sd->descent = MAX(new_sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); + new_sd->ascent = MAX(new_sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); + new_sd->descent = MAX(new_sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); } } new_sd->width += gl.advance * gl.repeat; @@ -2707,79 +2766,14 @@ RID TextServerFallback::shaped_text_substr(RID p_shaped, int p_start, int p_leng } } - // Align embedded objects to baseline. - float full_ascent = new_sd->ascent; - float full_descent = new_sd->descent; - for (KeyValue &E : new_sd->objects) { - if ((E.value.pos >= new_sd->start) && (E.value.pos < new_sd->end)) { - if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E.value.inline_align & INLINE_ALIGNMENT_TEXT_MASK) { - case INLINE_ALIGNMENT_TO_TOP: { - E.value.rect.position.y = -new_sd->ascent; - } break; - case INLINE_ALIGNMENT_TO_CENTER: { - E.value.rect.position.y = (-new_sd->ascent + new_sd->descent) / 2; - } break; - case INLINE_ALIGNMENT_TO_BASELINE: { - E.value.rect.position.y = 0; - } break; - case INLINE_ALIGNMENT_TO_BOTTOM: { - E.value.rect.position.y = new_sd->descent; - } break; - } - switch (E.value.inline_align & INLINE_ALIGNMENT_IMAGE_MASK) { - case INLINE_ALIGNMENT_BOTTOM_TO: { - E.value.rect.position.y -= E.value.rect.size.y; - } break; - case INLINE_ALIGNMENT_CENTER_TO: { - E.value.rect.position.y -= E.value.rect.size.y / 2; - } break; - case INLINE_ALIGNMENT_TOP_TO: { - // NOP - } break; - } - full_ascent = MAX(full_ascent, -E.value.rect.position.y); - full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); - } else { - switch (E.value.inline_align & INLINE_ALIGNMENT_TEXT_MASK) { - case INLINE_ALIGNMENT_TO_TOP: { - E.value.rect.position.x = -new_sd->ascent; - } break; - case INLINE_ALIGNMENT_TO_CENTER: { - E.value.rect.position.x = (-new_sd->ascent + new_sd->descent) / 2; - } break; - case INLINE_ALIGNMENT_TO_BASELINE: { - E.value.rect.position.x = 0; - } break; - case INLINE_ALIGNMENT_TO_BOTTOM: { - E.value.rect.position.x = new_sd->descent; - } break; - } - switch (E.value.inline_align & INLINE_ALIGNMENT_IMAGE_MASK) { - case INLINE_ALIGNMENT_BOTTOM_TO: { - E.value.rect.position.x -= E.value.rect.size.x; - } break; - case INLINE_ALIGNMENT_CENTER_TO: { - E.value.rect.position.x -= E.value.rect.size.x / 2; - } break; - case INLINE_ALIGNMENT_TOP_TO: { - // NOP - } break; - } - full_ascent = MAX(full_ascent, -E.value.rect.position.x); - full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); - } - } - } - new_sd->ascent = full_ascent; - new_sd->descent = full_descent; + _realign(new_sd); } new_sd->valid = true; return shaped_owner.make_rid(new_sd); } -RID TextServerFallback::shaped_text_get_parent(RID p_shaped) const { +RID TextServerFallback::shaped_text_get_parent(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, RID()); @@ -2787,9 +2781,9 @@ RID TextServerFallback::shaped_text_get_parent(RID p_shaped) const { return sd->parent; } -float TextServerFallback::shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags) { +double TextServerFallback::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -2827,7 +2821,7 @@ float TextServerFallback::shaped_text_fit_to_width(RID p_shaped, float p_width, } } - float justification_width; + double justification_width; if ((p_jst_flags & JUSTIFICATION_CONSTRAIN_ELLIPSIS) == JUSTIFICATION_CONSTRAIN_ELLIPSIS) { if (sd->overrun_trim_data.trim_pos >= 0) { end_pos = sd->overrun_trim_data.trim_pos; @@ -2872,12 +2866,12 @@ float TextServerFallback::shaped_text_fit_to_width(RID p_shaped, float p_width, } if ((space_count > 0) && ((p_jst_flags & JUSTIFICATION_WORD_BOUND) == JUSTIFICATION_WORD_BOUND)) { - float delta_width_per_space = (p_width - justification_width) / space_count; + double delta_width_per_space = (p_width - justification_width) / space_count; for (int i = start_pos; i <= end_pos; i++) { Glyph &gl = sd->glyphs.write[i]; if (gl.count > 0) { if ((gl.flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE) { - float old_adv = gl.advance; + double old_adv = gl.advance; gl.advance = MAX(gl.advance + delta_width_per_space, Math::round(0.1 * gl.font_size)); justification_width += (gl.advance - old_adv); } @@ -2896,9 +2890,9 @@ float TextServerFallback::shaped_text_fit_to_width(RID p_shaped, float p_width, return Math::ceil(justification_width); } -float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) { +double TextServerFallback::shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -2910,12 +2904,12 @@ float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat3 for (int i = 0; i < p_tab_stops.size(); i++) { if (p_tab_stops[i] <= 0) { - return 0.f; + return 0.0; } } int tab_index = 0; - float off = 0.f; + double off = 0.0; int start, end, delta; if (sd->para_direction == DIRECTION_LTR) { @@ -2932,7 +2926,7 @@ float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat3 for (int i = start; i != end; i += delta) { if ((gl[i].flags & GRAPHEME_IS_TAB) == GRAPHEME_IS_TAB) { - float tab_off = 0.f; + double tab_off = 0.0; while (tab_off <= off) { tab_off += p_tab_stops[tab_index]; tab_index++; @@ -2940,7 +2934,7 @@ float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat3 tab_index = 0; } } - float old_adv = gl[i].advance; + double old_adv = gl[i].advance; gl[i].advance = tab_off - off; sd->width += gl[i].advance - old_adv; off = 0; @@ -2949,10 +2943,10 @@ float TextServerFallback::shaped_text_tab_align(RID p_shaped, const PackedFloat3 off += gl[i].advance * gl[i].repeat; } - return 0.f; + return 0.0; } -bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) { +bool TextServerFallback::shaped_text_update_breaks(const RID &p_shaped) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3008,7 +3002,7 @@ bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) { return sd->line_breaks_valid; } -bool TextServerFallback::shaped_text_update_justification_ops(RID p_shaped) { +bool TextServerFallback::shaped_text_update_justification_ops(const RID &p_shaped) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3024,7 +3018,7 @@ bool TextServerFallback::shaped_text_update_justification_ops(RID p_shaped) { return true; } -void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, float p_width, uint16_t p_trim_flags) { +void TextServerFallback::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped_line); ERR_FAIL_COND_MSG(!sd, "ShapedTextDataFallback invalid."); @@ -3070,20 +3064,20 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl // Find usable fonts, if fonts from the last glyph do not have required chars. RID dot_gl_font_rid = sd_glyphs[sd_size - 1].font_rid; if (!font_has_char(dot_gl_font_rid, '.')) { - const Vector &fonts = spans[spans.size() - 1].fonts; - for (const RID &font : fonts) { - if (font_has_char(font, '.')) { - dot_gl_font_rid = font; + const Array &fonts = spans[spans.size() - 1].fonts; + for (int i = 0; i < fonts.size(); i++) { + if (font_has_char(fonts[i], '.')) { + dot_gl_font_rid = fonts[i]; break; } } } RID whitespace_gl_font_rid = sd_glyphs[sd_size - 1].font_rid; if (!font_has_char(whitespace_gl_font_rid, '.')) { - const Vector &fonts = spans[spans.size() - 1].fonts; - for (const RID &font : fonts) { - if (font_has_char(font, ' ')) { - whitespace_gl_font_rid = font; + const Array &fonts = spans[spans.size() - 1].fonts; + for (int i = 0; i < fonts.size(); i++) { + if (font_has_char(fonts[i], ' ')) { + whitespace_gl_font_rid = fonts[i]; break; } } @@ -3100,7 +3094,7 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl } int ell_min_characters = 6; - float width = sd->width; + double width = sd->width; int trim_pos = 0; int ellipsis_pos = (enforce_ellipsis) ? 0 : -1; @@ -3176,7 +3170,7 @@ void TextServerFallback::shaped_text_overrun_trim_to_width(RID p_shaped_line, fl } } -int TextServerFallback::shaped_text_get_trim_pos(RID p_shaped) const { +int64_t TextServerFallback::shaped_text_get_trim_pos(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataFallback invalid."); @@ -3184,7 +3178,7 @@ int TextServerFallback::shaped_text_get_trim_pos(RID p_shaped) const { return sd->overrun_trim_data.trim_pos; } -int TextServerFallback::shaped_text_get_ellipsis_pos(RID p_shaped) const { +int64_t TextServerFallback::shaped_text_get_ellipsis_pos(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataFallback invalid."); @@ -3192,7 +3186,7 @@ int TextServerFallback::shaped_text_get_ellipsis_pos(RID p_shaped) const { return sd->overrun_trim_data.ellipsis_pos; } -const Glyph *TextServerFallback::shaped_text_get_ellipsis_glyphs(RID p_shaped) const { +const Glyph *TextServerFallback::shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, nullptr, "ShapedTextDataFallback invalid."); @@ -3200,7 +3194,7 @@ const Glyph *TextServerFallback::shaped_text_get_ellipsis_glyphs(RID p_shaped) c return sd->overrun_trim_data.ellipsis_glyph_buf.ptr(); } -int TextServerFallback::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const { +int64_t TextServerFallback::shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V_MSG(!sd, 0, "ShapedTextDataFallback invalid."); @@ -3208,7 +3202,7 @@ int TextServerFallback::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const return sd->overrun_trim_data.ellipsis_glyph_buf.size(); } -bool TextServerFallback::shaped_text_shape(RID p_shaped) { +bool TextServerFallback::shaped_text_shape(const RID &p_shaped) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3224,9 +3218,9 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) { // Cleanup. sd->justification_ops_valid = false; sd->line_breaks_valid = false; - sd->ascent = 0.f; - sd->descent = 0.f; - sd->width = 0.f; + sd->ascent = 0.0; + sd->descent = 0.0; + sd->width = 0.0; sd->glyphs.clear(); if (sd->text.length() == 0) { @@ -3327,8 +3321,8 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) { sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y); } else { gl.advance = get_hex_code_box_size(gl.font_size, gl.index).y; - sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); - sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5f)); + sd->ascent = MAX(sd->ascent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); + sd->descent = MAX(sd->descent, Math::round(get_hex_code_box_size(gl.font_size, gl.index).x * 0.5)); } } sd->width += gl.advance; @@ -3338,74 +3332,13 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) { } // Align embedded objects to baseline. - float full_ascent = sd->ascent; - float full_descent = sd->descent; - for (KeyValue &E : sd->objects) { - if (sd->orientation == ORIENTATION_HORIZONTAL) { - switch (E.value.inline_align & INLINE_ALIGNMENT_TEXT_MASK) { - case INLINE_ALIGNMENT_TO_TOP: { - E.value.rect.position.y = -sd->ascent; - } break; - case INLINE_ALIGNMENT_TO_CENTER: { - E.value.rect.position.y = (-sd->ascent + sd->descent) / 2; - } break; - case INLINE_ALIGNMENT_TO_BASELINE: { - E.value.rect.position.y = 0; - } break; - case INLINE_ALIGNMENT_TO_BOTTOM: { - E.value.rect.position.y = sd->descent; - } break; - } - switch (E.value.inline_align & INLINE_ALIGNMENT_IMAGE_MASK) { - case INLINE_ALIGNMENT_BOTTOM_TO: { - E.value.rect.position.y -= E.value.rect.size.y; - } break; - case INLINE_ALIGNMENT_CENTER_TO: { - E.value.rect.position.y -= E.value.rect.size.y / 2; - } break; - case INLINE_ALIGNMENT_TOP_TO: { - // NOP - } break; - } - full_ascent = MAX(full_ascent, -E.value.rect.position.y); - full_descent = MAX(full_descent, E.value.rect.position.y + E.value.rect.size.y); - } else { - switch (E.value.inline_align & INLINE_ALIGNMENT_TEXT_MASK) { - case INLINE_ALIGNMENT_TO_TOP: { - E.value.rect.position.x = -sd->ascent; - } break; - case INLINE_ALIGNMENT_TO_CENTER: { - E.value.rect.position.x = (-sd->ascent + sd->descent) / 2; - } break; - case INLINE_ALIGNMENT_TO_BASELINE: { - E.value.rect.position.x = 0; - } break; - case INLINE_ALIGNMENT_TO_BOTTOM: { - E.value.rect.position.x = sd->descent; - } break; - } - switch (E.value.inline_align & INLINE_ALIGNMENT_IMAGE_MASK) { - case INLINE_ALIGNMENT_BOTTOM_TO: { - E.value.rect.position.x -= E.value.rect.size.x; - } break; - case INLINE_ALIGNMENT_CENTER_TO: { - E.value.rect.position.x -= E.value.rect.size.x / 2; - } break; - case INLINE_ALIGNMENT_TOP_TO: { - // NOP - } break; - } - full_ascent = MAX(full_ascent, -E.value.rect.position.x); - full_descent = MAX(full_descent, E.value.rect.position.x + E.value.rect.size.x); - } - } - sd->ascent = full_ascent; - sd->descent = full_descent; + _realign(sd); + sd->valid = true; return sd->valid; } -bool TextServerFallback::shaped_text_is_ready(RID p_shaped) const { +bool TextServerFallback::shaped_text_is_ready(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, false); @@ -3413,7 +3346,7 @@ bool TextServerFallback::shaped_text_is_ready(RID p_shaped) const { return sd->valid; } -const Glyph *TextServerFallback::shaped_text_get_glyphs(RID p_shaped) const { +const Glyph *TextServerFallback::shaped_text_get_glyphs(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, nullptr); @@ -3424,7 +3357,7 @@ const Glyph *TextServerFallback::shaped_text_get_glyphs(RID p_shaped) const { return sd->glyphs.ptr(); } -int TextServerFallback::shaped_text_get_glyph_count(RID p_shaped) const { +int64_t TextServerFallback::shaped_text_get_glyph_count(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, 0); @@ -3435,7 +3368,7 @@ int TextServerFallback::shaped_text_get_glyph_count(RID p_shaped) const { return sd->glyphs.size(); } -const Glyph *TextServerFallback::shaped_text_sort_logical(RID p_shaped) { +const Glyph *TextServerFallback::shaped_text_sort_logical(const RID &p_shaped) { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, nullptr); @@ -3447,7 +3380,7 @@ const Glyph *TextServerFallback::shaped_text_sort_logical(RID p_shaped) { return sd->glyphs.ptr(); // Already in the logical order, return as is. } -Vector2i TextServerFallback::shaped_text_get_range(RID p_shaped) const { +Vector2i TextServerFallback::shaped_text_get_range(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Vector2i()); @@ -3455,7 +3388,7 @@ Vector2i TextServerFallback::shaped_text_get_range(RID p_shaped) const { return Vector2(sd->start, sd->end); } -Array TextServerFallback::shaped_text_get_objects(RID p_shaped) const { +Array TextServerFallback::shaped_text_get_objects(const RID &p_shaped) const { Array ret; const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, ret); @@ -3468,7 +3401,7 @@ Array TextServerFallback::shaped_text_get_objects(RID p_shaped) const { return ret; } -Rect2 TextServerFallback::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const { +Rect2 TextServerFallback::shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Rect2()); @@ -3480,7 +3413,7 @@ Rect2 TextServerFallback::shaped_text_get_object_rect(RID p_shaped, Variant p_ke return sd->objects[p_key].rect; } -Size2 TextServerFallback::shaped_text_get_size(RID p_shaped) const { +Size2 TextServerFallback::shaped_text_get_size(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_V(!sd, Size2()); @@ -3495,9 +3428,9 @@ Size2 TextServerFallback::shaped_text_get_size(RID p_shaped) const { } } -float TextServerFallback::shaped_text_get_ascent(RID p_shaped) const { +double TextServerFallback::shaped_text_get_ascent(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3506,9 +3439,9 @@ float TextServerFallback::shaped_text_get_ascent(RID p_shaped) const { return sd->ascent; } -float TextServerFallback::shaped_text_get_descent(RID p_shaped) const { +double TextServerFallback::shaped_text_get_descent(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3517,9 +3450,9 @@ float TextServerFallback::shaped_text_get_descent(RID p_shaped) const { return sd->descent; } -float TextServerFallback::shaped_text_get_width(RID p_shaped) const { +double TextServerFallback::shaped_text_get_width(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3528,9 +3461,9 @@ float TextServerFallback::shaped_text_get_width(RID p_shaped) const { return Math::ceil(sd->width); } -float TextServerFallback::shaped_text_get_underline_position(RID p_shaped) const { +double TextServerFallback::shaped_text_get_underline_position(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3540,9 +3473,9 @@ float TextServerFallback::shaped_text_get_underline_position(RID p_shaped) const return sd->upos; } -float TextServerFallback::shaped_text_get_underline_thickness(RID p_shaped) const { +double TextServerFallback::shaped_text_get_underline_thickness(const RID &p_shaped) const { const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.f); + ERR_FAIL_COND_V(!sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -3555,7 +3488,7 @@ float TextServerFallback::shaped_text_get_underline_thickness(RID p_shaped) cons String TextServerFallback::string_to_upper(const String &p_string, const String &p_language) const { String upper = p_string; - for (int i = 0; i < upper.size(); i++) { + for (int i = 0; i <= upper.length(); i++) { const char32_t s = upper[i]; const char32_t t = _find_upper(s); if (s != t) { // avoid copy on write @@ -3569,7 +3502,7 @@ String TextServerFallback::string_to_upper(const String &p_string, const String String TextServerFallback::string_to_lower(const String &p_string, const String &p_language) const { String lower = p_string; - for (int i = 0; i < lower.size(); i++) { + for (int i = 0; i <= lower.length(); i++) { const char32_t s = lower[i]; const char32_t t = _find_lower(s); if (s != t) { // avoid copy on write @@ -3586,8 +3519,8 @@ TextServerFallback::TextServerFallback() { TextServerFallback::~TextServerFallback() { #ifdef MODULE_FREETYPE_ENABLED - if (library != nullptr) { - FT_Done_FreeType(library); + if (ft_library != nullptr) { + FT_Done_FreeType(ft_library); } #endif }; diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index d4c7b5666e4..3944c371b7e 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -36,7 +36,49 @@ /* BiDi, shaping and advanced font features support. */ /*************************************************************************/ -#include "servers/text_server.h" +#ifdef GDEXTENSION +// Headers for building as GDExtension plug-in. + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace godot; + +#else +// Headers for building as built-in module. + +#include "servers/text/text_server_extension.h" #include "core/templates/rid_owner.h" #include "core/templates/thread_work_pool.h" @@ -44,6 +86,10 @@ #include "modules/modules_enabled.gen.h" // For freetype, msdfgen. +#endif + +// Thirdparty headers. + #ifdef MODULE_FREETYPE_ENABLED #include #include FT_FREETYPE_H @@ -54,26 +100,25 @@ #include FT_BBOX_H #endif -#define OT_TAG(c1, c2, c3, c4) ((int32_t)((((uint32_t)(c1)&0xFF) << 24) | (((uint32_t)(c2)&0xFF) << 16) | (((uint32_t)(c3)&0xFF) << 8) | ((uint32_t)(c4)&0xFF))) +/*************************************************************************/ -class TextServerFallback : public TextServer { - GDCLASS(TextServerFallback, TextServer); +class TextServerFallback : public TextServerExtension { + GDCLASS(TextServerFallback, TextServerExtension); _THREAD_SAFE_CLASS_ - static String interface_name; - static uint32_t interface_features; - Map feature_sets; + Map feature_sets_inv; void _insert_feature_sets(); + _FORCE_INLINE_ void _insert_feature(const StringName &p_name, int32_t p_tag); // Font cache data. #ifdef MODULE_FREETYPE_ENABLED - mutable FT_Library library = nullptr; + mutable FT_Library ft_library = nullptr; #endif - const int rect_range = 2; + const int rect_range = 1; struct FontTexture { Image::Format format; @@ -99,12 +144,12 @@ class TextServerFallback : public TextServer { }; struct FontDataForSizeFallback { - float ascent = 0.f; - float descent = 0.f; - float underline_position = 0.f; - float underline_thickness = 0.f; - float scale = 1.f; - float oversampling = 1.f; + double ascent = 0.0; + double descent = 0.0; + double underline_position = 0.0; + double underline_thickness = 0.0; + double scale = 1.0; + double oversampling = 1.0; int spacing_glyph = 0; int spacing_space = 0; @@ -141,8 +186,8 @@ class TextServerFallback : public TextServer { TextServer::Hinting hinting = TextServer::HINTING_LIGHT; TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO; Dictionary variation_coordinates; - float oversampling = 0.f; - float embolden = 0.f; + double oversampling = 0.0; + double embolden = 0.0; Transform2D transform; uint32_t style_flags = 0; @@ -167,8 +212,8 @@ class TextServerFallback : public TextServer { ~FontDataFallback() { work_pool.finish(); - for (const Map::Element *E = cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue &E : cache) { + memdelete(E.value); } cache.clear(); } @@ -207,13 +252,31 @@ class TextServerFallback : public TextServer { } // Shaped text cache data. + struct TrimData { + int trim_pos = -1; + int ellipsis_pos = -1; + Vector ellipsis_glyph_buf; + }; + + struct ShapedTextDataFallback { + Mutex mutex; + + /* Source data */ + RID parent; // Substring parent ShapedTextData. + + int start = 0; // Substring start offset in the parent string. + int end = 0; // Substring end offset in the parent string. + + String text; + String custom_punct; + TextServer::Direction direction = DIRECTION_LTR; // Desired text direction. + TextServer::Orientation orientation = ORIENTATION_HORIZONTAL; - struct ShapedTextDataFallback : public ShapedTextData { struct Span { int start = -1; int end = -1; - Vector fonts; + Array fonts; int font_size = 0; Variant embedded_key; @@ -223,11 +286,43 @@ class TextServerFallback : public TextServer { Variant meta; }; Vector spans; + + struct EmbeddedObject { + int pos = 0; + InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER; + Rect2 rect; + }; + Map objects; + + /* Shaped data */ + TextServer::Direction para_direction = DIRECTION_LTR; // Detected text direction. + bool valid = false; // String is shaped. + bool line_breaks_valid = false; // Line and word break flags are populated (and virtual zero width spaces inserted). + bool justification_ops_valid = false; // Virtual elongation glyphs are added to the string. + bool sort_valid = false; + bool text_trimmed = false; + + bool preserve_invalid = true; // Draw hex code box instead of missing characters. + bool preserve_control = false; // Draw control characters. + + double ascent = 0.0; // Ascent for horizontal layout, 1/2 of width for vertical. + double descent = 0.0; // Descent for horizontal layout, 1/2 of width for vertical. + double width = 0.0; // Width for horizontal layout, height for vertical. + double width_trimmed = 0.0; + + double upos = 0.0; + double uthk = 0.0; + + TrimData overrun_trim_data; + bool fit_width_minimum_reached = false; + + Vector glyphs; + Vector glyphs_logical; }; // Common data. - float oversampling = 1.f; + double oversampling = 1.0; mutable RID_PtrOwner font_owner; mutable RID_PtrOwner shaped_owner; @@ -242,10 +337,10 @@ protected: public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual uint32_t get_features() const override; + virtual int64_t get_features() const override; - virtual void free(RID p_rid) override; - virtual bool has(RID p_rid) override; + virtual void free_rid(const RID &p_rid) override; + virtual bool has(const RID &p_rid) override; virtual bool load_support_data(const String &p_filename) override; virtual String get_support_data_filename() const override { return ""; }; @@ -254,218 +349,218 @@ public: virtual bool is_locale_right_to_left(const String &p_locale) const override; - virtual int32_t name_to_tag(const String &p_name) const override; - virtual String tag_to_name(int32_t p_tag) const override; + virtual int64_t name_to_tag(const String &p_name) const override; + virtual String tag_to_name(int64_t p_tag) const override; /* Font interface */ virtual RID create_font() override; - virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; - virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; + virtual void font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) override; + virtual void font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) override; - virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; - virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; + virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override; + virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override; - virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_style_name(RID p_font_rid) const override; + virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_style_name(const RID &p_font_rid) const override; - virtual void font_set_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_name(RID p_font_rid) const override; + virtual void font_set_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_name(const RID &p_font_rid) const override; - virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; - virtual bool font_is_antialiased(RID p_font_rid) const override; + virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) override; + virtual bool font_is_antialiased(const RID &p_font_rid) const override; - virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) override; - virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const override; + virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override; + virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override; - virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) override; - virtual int font_get_msdf_pixel_range(RID p_font_rid) const override; + virtual void font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) override; + virtual int64_t font_get_msdf_pixel_range(const RID &p_font_rid) const override; - virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) override; - virtual int font_get_msdf_size(RID p_font_rid) const override; + virtual void font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) override; + virtual int64_t font_get_msdf_size(const RID &p_font_rid) const override; - virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) override; - virtual int font_get_fixed_size(RID p_font_rid) const override; + virtual void font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) override; + virtual int64_t font_get_fixed_size(const RID &p_font_rid) const override; - virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) override; - virtual bool font_is_force_autohinter(RID p_font_rid) const override; + virtual void font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) override; + virtual bool font_is_force_autohinter(const RID &p_font_rid) const override; - virtual void font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) override; - virtual TextServer::Hinting font_get_hinting(RID p_font_rid) const override; + virtual void font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) override; + virtual TextServer::Hinting font_get_hinting(const RID &p_font_rid) const override; - virtual void font_set_subpixel_positioning(RID p_font_rid, SubpixelPositioning p_subpixel) override; - virtual SubpixelPositioning font_get_subpixel_positioning(RID p_font_rid) const override; + virtual void font_set_subpixel_positioning(const RID &p_font_rid, SubpixelPositioning p_subpixel) override; + virtual SubpixelPositioning font_get_subpixel_positioning(const RID &p_font_rid) const override; - virtual void font_set_embolden(RID p_font_rid, float p_strength) override; - virtual float font_get_embolden(RID p_font_rid) const override; + virtual void font_set_embolden(const RID &p_font_rid, double p_strength) override; + virtual double font_get_embolden(const RID &p_font_rid) const override; - virtual void font_set_transform(RID p_font_rid, Transform2D p_transform) override; - virtual Transform2D font_get_transform(RID p_font_rid) const override; + virtual void font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) override; + virtual Transform2D font_get_transform(const RID &p_font_rid) const override; - virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) override; - virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const override; + virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) override; + virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const override; - virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) override; - virtual float font_get_oversampling(RID p_font_rid) const override; + virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) override; + virtual double font_get_oversampling(const RID &p_font_rid) const override; - virtual Array font_get_size_cache_list(RID p_font_rid) const override; - virtual void font_clear_size_cache(RID p_font_rid) override; - virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) override; + virtual Array font_get_size_cache_list(const RID &p_font_rid) const override; + virtual void font_clear_size_cache(const RID &p_font_rid) override; + virtual void font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) override; - virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) override; - virtual float font_get_ascent(RID p_font_rid, int p_size) const override; + virtual void font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) override; + virtual double font_get_ascent(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) override; - virtual float font_get_descent(RID p_font_rid, int p_size) const override; + virtual void font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) override; + virtual double font_get_descent(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) override; - virtual float font_get_underline_position(RID p_font_rid, int p_size) const override; + virtual void font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) override; + virtual double font_get_underline_position(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) override; - virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const override; + virtual void font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) override; + virtual double font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) override; - virtual float font_get_scale(RID p_font_rid, int p_size) const override; + virtual void font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) override; + virtual double font_get_scale(const RID &p_font_rid, int64_t p_size) const override; - virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) override; - virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const override; + virtual void font_set_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing, int64_t p_value) override; + virtual int64_t font_get_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing) const override; - virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) override; + virtual int64_t font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) override; - virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) override; - virtual Ref font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; + virtual void font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) override; + virtual Ref font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; - virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) override; - virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; + virtual void font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) override; + virtual PackedInt32Array font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; - virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) override; + virtual Array font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) override; - virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) override; + virtual Vector2 font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) override; - virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) override; + virtual Vector2 font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) override; - virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) override; + virtual Vector2 font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) override; - virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) override; + virtual Rect2 font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) override; - virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) override; + virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override; - virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const override; + virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override; - virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const override; - virtual void font_clear_kerning_map(RID p_font_rid, int p_size) override; - virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) override; + virtual Array font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const override; + virtual void font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) override; + virtual void font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) override; - virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; - virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const override; + virtual void font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; + virtual Vector2 font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const override; - virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector = 0) const override; + virtual int64_t font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector = 0) const override; - virtual bool font_has_char(RID p_font_rid, char32_t p_char) const override; - virtual String font_get_supported_chars(RID p_font_rid) const override; + virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const override; + virtual String font_get_supported_chars(const RID &p_font_rid) const override; - virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) override; - virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) override; + virtual void font_render_range(const RID &p_font, const Vector2i &p_size, int64_t p_start, int64_t p_end) override; + virtual void font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) override; - virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + virtual void font_draw_glyph(const RID &p_font, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + virtual void font_draw_glyph_outline(const RID &p_font, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const override; - virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) override; - virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) override; - virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) override; - virtual Vector font_get_language_support_overrides(RID p_font_rid) override; + virtual bool font_is_language_supported(const RID &p_font_rid, const String &p_language) const override; + virtual void font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) override; + virtual bool font_get_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual void font_remove_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual PackedStringArray font_get_language_support_overrides(const RID &p_font_rid) override; - virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const override; - virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) override; - virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) override; - virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; - virtual Vector font_get_script_support_overrides(RID p_font_rid) override; + virtual bool font_is_script_supported(const RID &p_font_rid, const String &p_script) const override; + virtual void font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) override; + virtual bool font_get_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual void font_remove_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual PackedStringArray font_get_script_support_overrides(const 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 void font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(const 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; + virtual Dictionary font_supported_feature_list(const RID &p_font_rid) const override; + virtual Dictionary font_supported_variation_list(const RID &p_font_rid) const override; - virtual float font_get_global_oversampling() const override; - virtual void font_set_global_oversampling(float p_oversampling) override; + virtual double font_get_global_oversampling() const override; + virtual void font_set_global_oversampling(double p_oversampling) override; /* Shaped text buffer interface */ virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual void shaped_text_clear(RID p_shaped) override; + virtual void shaped_text_clear(const RID &p_shaped) override; - virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override; - virtual Direction shaped_text_get_direction(RID p_shaped) const override; - virtual Direction shaped_text_get_inferred_direction(RID p_shaped) const override; + virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) override; + virtual Direction shaped_text_get_direction(const RID &p_shaped) const override; + virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const override; - virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; + virtual void shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) override; - virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; - virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; + virtual void shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(const RID &p_shaped) const override; - virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; + virtual void shaped_text_set_orientation(const RID &p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; + virtual Orientation shaped_text_get_orientation(const RID &p_shaped) const override; - virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override; + virtual void shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_invalid(const RID &p_shaped) const override; - virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_control(RID p_shaped) const override; + virtual void shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_control(const RID &p_shaped) const override; - virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; - virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int p_length = 1) override; - virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; + virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) override; + virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; - virtual int shaped_get_span_count(RID p_shaped) const override; - virtual Variant shaped_get_span_meta(RID p_shaped, int p_index) const override; - virtual void shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary()) override; + virtual int64_t shaped_get_span_count(const RID &p_shaped) const override; + virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override; - virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override; - virtual RID shaped_text_get_parent(RID p_shaped) const override; + virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override; + virtual RID shaped_text_get_parent(const RID &p_shaped) const override; - virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; - virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) override; + virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; + virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override; - virtual bool shaped_text_shape(RID p_shaped) override; - virtual bool shaped_text_update_breaks(RID p_shaped) override; - virtual bool shaped_text_update_justification_ops(RID p_shaped) override; + virtual bool shaped_text_shape(const RID &p_shaped) override; + virtual bool shaped_text_update_breaks(const RID &p_shaped) override; + virtual bool shaped_text_update_justification_ops(const RID &p_shaped) override; - virtual int shaped_text_get_trim_pos(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const override; - virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const override; + virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override; - virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) override; + virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override; - virtual bool shaped_text_is_ready(RID p_shaped) const override; + virtual bool shaped_text_is_ready(const RID &p_shaped) const override; - virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const override; - virtual const Glyph *shaped_text_sort_logical(RID p_shaped) override; - virtual int shaped_text_get_glyph_count(RID p_shaped) const override; + virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) override; + virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const override; - virtual Vector2i shaped_text_get_range(RID p_shaped) const override; + virtual Vector2i shaped_text_get_range(const RID &p_shaped) const override; - virtual Array shaped_text_get_objects(RID p_shaped) const override; - virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override; + virtual Array shaped_text_get_objects(const RID &p_shaped) const override; + virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const override; - virtual Size2 shaped_text_get_size(RID p_shaped) const override; - virtual float shaped_text_get_ascent(RID p_shaped) const override; - virtual float shaped_text_get_descent(RID p_shaped) const override; - virtual float shaped_text_get_width(RID p_shaped) const override; - virtual float shaped_text_get_underline_position(RID p_shaped) const override; - virtual float shaped_text_get_underline_thickness(RID p_shaped) const override; + virtual Size2 shaped_text_get_size(const RID &p_shaped) const override; + virtual double shaped_text_get_ascent(const RID &p_shaped) const override; + virtual double shaped_text_get_descent(const RID &p_shaped) const override; + virtual double shaped_text_get_width(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_position(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const override; virtual String string_to_upper(const String &p_string, const String &p_language = "") const override; virtual String string_to_lower(const String &p_string, const String &p_language = "") const override; diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 419901d5ea5..cd6fc168c23 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -115,7 +115,7 @@ void Label::_shape() { if (lines_dirty) { for (int i = 0; i < lines_rid.size(); i++) { - TS->free(lines_rid[i]); + TS->free_rid(lines_rid[i]); } lines_rid.clear(); @@ -960,8 +960,8 @@ Label::Label(const String &p_text) { Label::~Label() { for (int i = 0; i < lines_rid.size(); i++) { - TS->free(lines_rid[i]); + TS->free_rid(lines_rid[i]); } lines_rid.clear(); - TS->free(text_rid); + TS->free_rid(text_rid); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da39a3d3873..e063d3aeba6 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -2458,5 +2458,5 @@ LineEdit::LineEdit(const String &p_placeholder) { } LineEdit::~LineEdit() { - TS->free(text_rid); + TS->free_rid(text_rid); } diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index ce2a675854e..15594109e93 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -40,7 +40,7 @@ _FORCE_INLINE_ void FontData::_clear_cache() { for (int i = 0; i < cache.size(); i++) { if (cache[i].is_valid()) { - TS->free(cache[i]); + TS->free_rid(cache[i]); cache.write[i] = RID(); } } @@ -1499,7 +1499,7 @@ void FontData::clear_cache() { void FontData::remove_cache(int p_cache_index) { ERR_FAIL_INDEX(p_cache_index, cache.size()); if (cache[p_cache_index].is_valid()) { - TS->free(cache.write[p_cache_index]); + TS->free_rid(cache.write[p_cache_index]); } cache.remove_at(p_cache_index); emit_changed(); @@ -1924,6 +1924,8 @@ void Font::_bind_methods() { ClassDB::bind_method(D_METHOD("get_supported_chars"), &Font::get_supported_chars); ClassDB::bind_method(D_METHOD("update_changes"), &Font::update_changes); + + ClassDB::bind_method(D_METHOD("get_rids"), &Font::get_rids); } bool Font::_set(const StringName &p_name, const Variant &p_value) { @@ -2427,11 +2429,15 @@ String Font::get_supported_chars() const { return chars; } -Vector Font::get_rids() const { +Array Font::get_rids() const { + Array _rids; for (int i = 0; i < data.size(); i++) { _ensure_rid(i); + if (rids[i].is_valid()) { + _rids.push_back(rids[i]); + } } - return rids; + return _rids; } void Font::update_changes() { diff --git a/scene/resources/font.h b/scene/resources/font.h index 0185b019f17..2aa12dd2de9 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -311,7 +311,7 @@ public: virtual Size2 get_char_size(char32_t p_char, char32_t p_next = 0, int p_size = DEFAULT_FONT_SIZE) const; virtual real_t draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_char, char32_t p_next = 0, int p_size = DEFAULT_FONT_SIZE, const Color &p_modulate = Color(1, 1, 1), int p_outline_size = 0, const Color &p_outline_modulate = Color(1, 1, 1, 0)) const; - Vector get_rids() const; + Array get_rids() const; void update_changes(); diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp index c3b5bd3564d..db5f1338db6 100644 --- a/scene/resources/text_line.cpp +++ b/scene/resources/text_line.cpp @@ -411,5 +411,5 @@ TextLine::TextLine() { } TextLine::~TextLine() { - TS->free(rid); + TS->free_rid(rid); } diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index 4d75874199f..d74d7c88c68 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -140,7 +140,7 @@ void TextParagraph::_bind_methods() { void TextParagraph::_shape_lines() { if (lines_dirty) { for (int i = 0; i < lines_rid.size(); i++) { - TS->free(lines_rid[i]); + TS->free_rid(lines_rid[i]); } lines_rid.clear(); @@ -168,7 +168,7 @@ void TextParagraph::_shape_lines() { RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]); float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x; if (v_offset < h) { - TS->free(line); + TS->free_rid(line); break; } if (!tab_stops.is_empty()) { @@ -271,7 +271,7 @@ void TextParagraph::clear() { spacing_top = 0; spacing_bottom = 0; for (int i = 0; i < lines_rid.size(); i++) { - TS->free(lines_rid[i]); + TS->free_rid(lines_rid[i]); } lines_rid.clear(); TS->shaped_text_clear(rid); @@ -847,9 +847,9 @@ TextParagraph::TextParagraph() { TextParagraph::~TextParagraph() { for (int i = 0; i < lines_rid.size(); i++) { - TS->free(lines_rid[i]); + TS->free_rid(lines_rid[i]); } lines_rid.clear(); - TS->free(rid); - TS->free(dropcap_rid); + TS->free_rid(rid); + TS->free_rid(dropcap_rid); } diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index f73407ad34c..98434923169 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -72,6 +72,7 @@ #include "rendering_server.h" #include "servers/extensions/physics_server_3d_extension.h" #include "servers/rendering/shader_types.h" +#include "text/text_server_dummy.h" #include "text/text_server_extension.h" #include "text_server.h" #include "xr/xr_interface.h" @@ -113,6 +114,7 @@ void preregister_server_types() { GDREGISTER_CLASS(TextServerManager); GDREGISTER_ABSTRACT_CLASS(TextServer); GDREGISTER_CLASS(TextServerExtension); + GDREGISTER_CLASS(TextServerDummy); GDREGISTER_NATIVE_STRUCT(Glyph, "int start = -1;int end = -1;uint8_t count = 0;uint8_t repeat = 1;uint16_t flags = 0;float x_off = 0.f;float y_off = 0.f;float advance = 0.f;RID font_rid;int font_size = 0;int32_t index = 0"); GDREGISTER_NATIVE_STRUCT(CaretInfo, "Rect2 leading_caret;Rect2 trailing_caret;TextServer::Direction leading_direction;TextServer::Direction trailing_direction"); diff --git a/servers/text/text_server_dummy.h b/servers/text/text_server_dummy.h new file mode 100644 index 00000000000..c603881b7c0 --- /dev/null +++ b/servers/text/text_server_dummy.h @@ -0,0 +1,48 @@ +/*************************************************************************/ +/* text_server_dummy.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TEXT_SERVER_DUMMY_H +#define TEXT_SERVER_DUMMY_H + +#include "servers/text/text_server_extension.h" + +/*************************************************************************/ + +class TextServerDummy : public TextServerExtension { + GDCLASS(TextServerDummy, TextServerExtension); + _THREAD_SAFE_CLASS_ + +public: + virtual String get_name() const override { + return "Dummy"; + } +}; + +#endif // TEXT_SERVER_DUMMY_H diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp index 1a10161a5b9..c8efacc9c59 100644 --- a/servers/text/text_server_extension.cpp +++ b/servers/text/text_server_extension.cpp @@ -31,267 +31,269 @@ #include "text_server_extension.h" void TextServerExtension::_bind_methods() { - GDVIRTUAL_BIND(_has_feature, "feature"); - GDVIRTUAL_BIND(_get_name); - GDVIRTUAL_BIND(_get_features); + GDVIRTUAL_BIND(has_feature, "feature"); + GDVIRTUAL_BIND(get_name); + GDVIRTUAL_BIND(get_features); - GDVIRTUAL_BIND(_free, "rid"); - GDVIRTUAL_BIND(_has, "rid"); - GDVIRTUAL_BIND(_load_support_data, "filename"); + GDVIRTUAL_BIND(free_rid, "rid"); + GDVIRTUAL_BIND(has, "rid"); + GDVIRTUAL_BIND(load_support_data, "filename"); - GDVIRTUAL_BIND(_get_support_data_filename); - GDVIRTUAL_BIND(_get_support_data_info); - GDVIRTUAL_BIND(_save_support_data, "filename"); + GDVIRTUAL_BIND(get_support_data_filename); + GDVIRTUAL_BIND(get_support_data_info); + GDVIRTUAL_BIND(save_support_data, "filename"); - GDVIRTUAL_BIND(_is_locale_right_to_left, "locale"); + GDVIRTUAL_BIND(is_locale_right_to_left, "locale"); - GDVIRTUAL_BIND(_name_to_tag, "name"); - GDVIRTUAL_BIND(_tag_to_name, "tag"); + GDVIRTUAL_BIND(name_to_tag, "name"); + GDVIRTUAL_BIND(tag_to_name, "tag"); /* Font interface */ - GDVIRTUAL_BIND(_create_font); + GDVIRTUAL_BIND(create_font); - GDVIRTUAL_BIND(_font_set_data, "font_rid", "data"); - GDVIRTUAL_BIND(_font_set_data_ptr, "font_rid", "data_ptr", "data_size"); + GDVIRTUAL_BIND(font_set_data, "font_rid", "data"); + GDVIRTUAL_BIND(font_set_data_ptr, "font_rid", "data_ptr", "data_size"); - GDVIRTUAL_BIND(_font_set_style, "font_rid", "style"); - GDVIRTUAL_BIND(_font_get_style, "font_rid"); + GDVIRTUAL_BIND(font_set_style, "font_rid", "style"); + GDVIRTUAL_BIND(font_get_style, "font_rid"); - GDVIRTUAL_BIND(_font_set_name, "font_rid", "name"); - GDVIRTUAL_BIND(_font_get_name, "font_rid"); + GDVIRTUAL_BIND(font_set_name, "font_rid", "name"); + GDVIRTUAL_BIND(font_get_name, "font_rid"); - GDVIRTUAL_BIND(_font_set_style_name, "font_rid", "name_style"); - GDVIRTUAL_BIND(_font_get_style_name, "font_rid"); + GDVIRTUAL_BIND(font_set_style_name, "font_rid", "name_style"); + GDVIRTUAL_BIND(font_get_style_name, "font_rid"); - GDVIRTUAL_BIND(_font_set_antialiased, "font_rid", "antialiased"); - GDVIRTUAL_BIND(_font_is_antialiased, "font_rid"); + GDVIRTUAL_BIND(font_set_antialiased, "font_rid", "antialiased"); + GDVIRTUAL_BIND(font_is_antialiased, "font_rid"); - GDVIRTUAL_BIND(_font_set_multichannel_signed_distance_field, "font_rid", "msdf"); - GDVIRTUAL_BIND(_font_is_multichannel_signed_distance_field, "font_rid"); + GDVIRTUAL_BIND(font_set_multichannel_signed_distance_field, "font_rid", "msdf"); + GDVIRTUAL_BIND(font_is_multichannel_signed_distance_field, "font_rid"); - GDVIRTUAL_BIND(_font_set_msdf_pixel_range, "font_rid", "msdf_pixel_range"); - GDVIRTUAL_BIND(_font_get_msdf_pixel_range, "font_rid"); + GDVIRTUAL_BIND(font_set_msdf_pixel_range, "font_rid", "msdf_pixel_range"); + GDVIRTUAL_BIND(font_get_msdf_pixel_range, "font_rid"); - GDVIRTUAL_BIND(_font_set_msdf_size, "font_rid", "msdf_size"); - GDVIRTUAL_BIND(_font_get_msdf_size, "font_rid"); + GDVIRTUAL_BIND(font_set_msdf_size, "font_rid", "msdf_size"); + GDVIRTUAL_BIND(font_get_msdf_size, "font_rid"); - GDVIRTUAL_BIND(_font_set_fixed_size, "font_rid", "fixed_size"); - GDVIRTUAL_BIND(_font_get_fixed_size, "font_rid"); + GDVIRTUAL_BIND(font_set_fixed_size, "font_rid", "fixed_size"); + GDVIRTUAL_BIND(font_get_fixed_size, "font_rid"); - GDVIRTUAL_BIND(_font_set_force_autohinter, "font_rid", "force_autohinter"); - GDVIRTUAL_BIND(_font_is_force_autohinter, "font_rid"); + GDVIRTUAL_BIND(font_set_force_autohinter, "font_rid", "force_autohinter"); + GDVIRTUAL_BIND(font_is_force_autohinter, "font_rid"); - GDVIRTUAL_BIND(_font_set_hinting, "font_rid", "hinting"); - GDVIRTUAL_BIND(_font_get_hinting, "font_rid"); + GDVIRTUAL_BIND(font_set_hinting, "font_rid", "hinting"); + GDVIRTUAL_BIND(font_get_hinting, "font_rid"); - GDVIRTUAL_BIND(_font_set_subpixel_positioning, "font_rid", "subpixel_positioning"); - GDVIRTUAL_BIND(_font_get_subpixel_positioning, "font_rid"); + GDVIRTUAL_BIND(font_set_subpixel_positioning, "font_rid", "subpixel_positioning"); + GDVIRTUAL_BIND(font_get_subpixel_positioning, "font_rid"); - GDVIRTUAL_BIND(_font_set_embolden, "font_rid", "strength"); - GDVIRTUAL_BIND(_font_get_embolden, "font_rid"); + GDVIRTUAL_BIND(font_set_embolden, "font_rid", "strength"); + GDVIRTUAL_BIND(font_get_embolden, "font_rid"); - GDVIRTUAL_BIND(_font_set_transform, "font_rid", "transform"); - GDVIRTUAL_BIND(_font_get_transform, "font_rid"); + GDVIRTUAL_BIND(font_set_transform, "font_rid", "transform"); + GDVIRTUAL_BIND(font_get_transform, "font_rid"); - GDVIRTUAL_BIND(_font_set_variation_coordinates, "font_rid", "variation_coordinates"); - GDVIRTUAL_BIND(_font_get_variation_coordinates, "font_rid"); + GDVIRTUAL_BIND(font_set_variation_coordinates, "font_rid", "variation_coordinates"); + GDVIRTUAL_BIND(font_get_variation_coordinates, "font_rid"); - GDVIRTUAL_BIND(_font_set_oversampling, "font_rid", "oversampling"); - GDVIRTUAL_BIND(_font_get_oversampling, "font_rid"); + GDVIRTUAL_BIND(font_set_oversampling, "font_rid", "oversampling"); + GDVIRTUAL_BIND(font_get_oversampling, "font_rid"); - GDVIRTUAL_BIND(_font_get_size_cache_list, "font_rid"); - GDVIRTUAL_BIND(_font_clear_size_cache, "font_rid"); - GDVIRTUAL_BIND(_font_remove_size_cache, "font_rid", "size"); + GDVIRTUAL_BIND(font_get_size_cache_list, "font_rid"); + GDVIRTUAL_BIND(font_clear_size_cache, "font_rid"); + GDVIRTUAL_BIND(font_remove_size_cache, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_ascent, "font_rid", "size", "ascent"); - GDVIRTUAL_BIND(_font_get_ascent, "font_rid", "size"); + GDVIRTUAL_BIND(font_set_ascent, "font_rid", "size", "ascent"); + GDVIRTUAL_BIND(font_get_ascent, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_descent, "font_rid", "size", "descent"); - GDVIRTUAL_BIND(_font_get_descent, "font_rid", "size"); + GDVIRTUAL_BIND(font_set_descent, "font_rid", "size", "descent"); + GDVIRTUAL_BIND(font_get_descent, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_underline_position, "font_rid", "size", "underline_position"); - GDVIRTUAL_BIND(_font_get_underline_position, "font_rid", "size"); + GDVIRTUAL_BIND(font_set_underline_position, "font_rid", "size", "underline_position"); + GDVIRTUAL_BIND(font_get_underline_position, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_underline_thickness, "font_rid", "size", "underline_thickness"); - GDVIRTUAL_BIND(_font_get_underline_thickness, "font_rid", "size"); + GDVIRTUAL_BIND(font_set_underline_thickness, "font_rid", "size", "underline_thickness"); + GDVIRTUAL_BIND(font_get_underline_thickness, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_scale, "font_rid", "size", "scale"); - GDVIRTUAL_BIND(_font_get_scale, "font_rid", "size"); + GDVIRTUAL_BIND(font_set_scale, "font_rid", "size", "scale"); + GDVIRTUAL_BIND(font_get_scale, "font_rid", "size"); - GDVIRTUAL_BIND(_font_set_spacing, "font_rid", "size", "spacing", "value"); - GDVIRTUAL_BIND(_font_get_spacing, "font_rid", "size", "spacing"); + GDVIRTUAL_BIND(font_set_spacing, "font_rid", "size", "spacing", "value"); + GDVIRTUAL_BIND(font_get_spacing, "font_rid", "size", "spacing"); - GDVIRTUAL_BIND(_font_get_texture_count, "font_rid", "size"); - GDVIRTUAL_BIND(_font_clear_textures, "font_rid", "size"); - GDVIRTUAL_BIND(_font_remove_texture, "font_rid", "size", "texture_index"); + GDVIRTUAL_BIND(font_get_texture_count, "font_rid", "size"); + GDVIRTUAL_BIND(font_clear_textures, "font_rid", "size"); + GDVIRTUAL_BIND(font_remove_texture, "font_rid", "size", "texture_index"); - GDVIRTUAL_BIND(_font_set_texture_image, "font_rid", "size", "texture_index", "image"); - GDVIRTUAL_BIND(_font_get_texture_image, "font_rid", "size", "texture_index"); + GDVIRTUAL_BIND(font_set_texture_image, "font_rid", "size", "texture_index", "image"); + GDVIRTUAL_BIND(font_get_texture_image, "font_rid", "size", "texture_index"); - GDVIRTUAL_BIND(_font_set_texture_offsets, "font_rid", "size", "texture_index", "offset"); - GDVIRTUAL_BIND(_font_get_texture_offsets, "font_rid", "size", "texture_index"); + GDVIRTUAL_BIND(font_set_texture_offsets, "font_rid", "size", "texture_index", "offset"); + GDVIRTUAL_BIND(font_get_texture_offsets, "font_rid", "size", "texture_index"); - GDVIRTUAL_BIND(_font_get_glyph_list, "font_rid", "size"); - GDVIRTUAL_BIND(_font_clear_glyphs, "font_rid", "size"); - GDVIRTUAL_BIND(_font_remove_glyph, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_get_glyph_list, "font_rid", "size"); + GDVIRTUAL_BIND(font_clear_glyphs, "font_rid", "size"); + GDVIRTUAL_BIND(font_remove_glyph, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_get_glyph_advance, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_set_glyph_advance, "font_rid", "size", "glyph", "advance"); + GDVIRTUAL_BIND(font_get_glyph_advance, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_set_glyph_advance, "font_rid", "size", "glyph", "advance"); - GDVIRTUAL_BIND(_font_get_glyph_offset, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_set_glyph_offset, "font_rid", "size", "glyph", "offset"); + GDVIRTUAL_BIND(font_get_glyph_offset, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_set_glyph_offset, "font_rid", "size", "glyph", "offset"); - GDVIRTUAL_BIND(_font_get_glyph_size, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_set_glyph_size, "font_rid", "size", "glyph", "gl_size"); + GDVIRTUAL_BIND(font_get_glyph_size, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_set_glyph_size, "font_rid", "size", "glyph", "gl_size"); - GDVIRTUAL_BIND(_font_get_glyph_uv_rect, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_set_glyph_uv_rect, "font_rid", "size", "glyph", "uv_rect"); + GDVIRTUAL_BIND(font_get_glyph_uv_rect, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_set_glyph_uv_rect, "font_rid", "size", "glyph", "uv_rect"); - GDVIRTUAL_BIND(_font_get_glyph_texture_idx, "font_rid", "size", "glyph"); - GDVIRTUAL_BIND(_font_set_glyph_texture_idx, "font_rid", "size", "glyph", "texture_idx"); + GDVIRTUAL_BIND(font_get_glyph_texture_idx, "font_rid", "size", "glyph"); + GDVIRTUAL_BIND(font_set_glyph_texture_idx, "font_rid", "size", "glyph", "texture_idx"); - GDVIRTUAL_BIND(_font_get_glyph_contours, "font_rid", "size", "index"); + GDVIRTUAL_BIND(font_get_glyph_contours, "font_rid", "size", "index"); - GDVIRTUAL_BIND(_font_get_kerning_list, "font_rid", "size"); - GDVIRTUAL_BIND(_font_clear_kerning_map, "font_rid", "size"); - GDVIRTUAL_BIND(_font_remove_kerning, "font_rid", "size", "glyph_pair"); + GDVIRTUAL_BIND(font_get_kerning_list, "font_rid", "size"); + GDVIRTUAL_BIND(font_clear_kerning_map, "font_rid", "size"); + GDVIRTUAL_BIND(font_remove_kerning, "font_rid", "size", "glyph_pair"); - GDVIRTUAL_BIND(_font_set_kerning, "font_rid", "size", "glyph_pair", "kerning"); - GDVIRTUAL_BIND(_font_get_kerning, "font_rid", "size", "glyph_pair"); + GDVIRTUAL_BIND(font_set_kerning, "font_rid", "size", "glyph_pair", "kerning"); + GDVIRTUAL_BIND(font_get_kerning, "font_rid", "size", "glyph_pair"); - GDVIRTUAL_BIND(_font_get_glyph_index, "font_rid", "size", "char", "variation_selector"); + GDVIRTUAL_BIND(font_get_glyph_index, "font_rid", "size", "char", "variation_selector"); - GDVIRTUAL_BIND(_font_has_char, "font_rid", "char"); - GDVIRTUAL_BIND(_font_get_supported_chars, "font_rid"); + GDVIRTUAL_BIND(font_has_char, "font_rid", "char"); + GDVIRTUAL_BIND(font_get_supported_chars, "font_rid"); - GDVIRTUAL_BIND(_font_render_range, "font_rid", "size", "start", "end"); - GDVIRTUAL_BIND(_font_render_glyph, "font_rid", "size", "index"); + GDVIRTUAL_BIND(font_render_range, "font_rid", "size", "start", "end"); + GDVIRTUAL_BIND(font_render_glyph, "font_rid", "size", "index"); - GDVIRTUAL_BIND(_font_draw_glyph, "font_rid", "canvas", "size", "pos", "index", "color"); - GDVIRTUAL_BIND(_font_draw_glyph_outline, "font_rid", "canvas", "size", "outline_size", "pos", "index", "color"); + GDVIRTUAL_BIND(font_draw_glyph, "font_rid", "canvas", "size", "pos", "index", "color"); + GDVIRTUAL_BIND(font_draw_glyph_outline, "font_rid", "canvas", "size", "outline_size", "pos", "index", "color"); - GDVIRTUAL_BIND(_font_is_language_supported, "font_rid", "language"); - GDVIRTUAL_BIND(_font_set_language_support_override, "font_rid", "language", "supported"); - GDVIRTUAL_BIND(_font_get_language_support_override, "font_rid", "language"); - GDVIRTUAL_BIND(_font_remove_language_support_override, "font_rid", "language"); - GDVIRTUAL_BIND(_font_get_language_support_overrides, "font_rid"); + GDVIRTUAL_BIND(font_is_language_supported, "font_rid", "language"); + GDVIRTUAL_BIND(font_set_language_support_override, "font_rid", "language", "supported"); + GDVIRTUAL_BIND(font_get_language_support_override, "font_rid", "language"); + GDVIRTUAL_BIND(font_remove_language_support_override, "font_rid", "language"); + GDVIRTUAL_BIND(font_get_language_support_overrides, "font_rid"); - GDVIRTUAL_BIND(_font_is_script_supported, "font_rid", "script"); - GDVIRTUAL_BIND(_font_set_script_support_override, "font_rid", "script", "supported"); - GDVIRTUAL_BIND(_font_get_script_support_override, "font_rid", "script"); - GDVIRTUAL_BIND(_font_remove_script_support_override, "font_rid", "script"); - GDVIRTUAL_BIND(_font_get_script_support_overrides, "font_rid"); + GDVIRTUAL_BIND(font_is_script_supported, "font_rid", "script"); + GDVIRTUAL_BIND(font_set_script_support_override, "font_rid", "script", "supported"); + GDVIRTUAL_BIND(font_get_script_support_override, "font_rid", "script"); + 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_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"); + GDVIRTUAL_BIND(font_supported_feature_list, "font_rid"); + GDVIRTUAL_BIND(font_supported_variation_list, "font_rid"); - GDVIRTUAL_BIND(_font_get_global_oversampling); - GDVIRTUAL_BIND(_font_set_global_oversampling, "oversampling"); + GDVIRTUAL_BIND(font_get_global_oversampling); + GDVIRTUAL_BIND(font_set_global_oversampling, "oversampling"); - GDVIRTUAL_BIND(_get_hex_code_box_size, "size", "index"); - GDVIRTUAL_BIND(_draw_hex_code_box, "canvas", "size", "pos", "index", "color"); + GDVIRTUAL_BIND(get_hex_code_box_size, "size", "index"); + GDVIRTUAL_BIND(draw_hex_code_box, "canvas", "size", "pos", "index", "color"); /* Shaped text buffer interface */ - GDVIRTUAL_BIND(_create_shaped_text, "direction", "orientation"); + GDVIRTUAL_BIND(create_shaped_text, "direction", "orientation"); - GDVIRTUAL_BIND(_shaped_text_clear, "shaped"); + GDVIRTUAL_BIND(shaped_text_clear, "shaped"); - GDVIRTUAL_BIND(_shaped_text_set_direction, "shaped", "direction"); - GDVIRTUAL_BIND(_shaped_text_get_direction, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_inferred_direction, "shaped"); + GDVIRTUAL_BIND(shaped_text_set_direction, "shaped", "direction"); + GDVIRTUAL_BIND(shaped_text_get_direction, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_inferred_direction, "shaped"); - GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override"); + GDVIRTUAL_BIND(shaped_text_set_bidi_override, "shaped", "override"); - GDVIRTUAL_BIND(_shaped_text_set_custom_punctuation, "shaped", "punct"); - GDVIRTUAL_BIND(_shaped_text_get_custom_punctuation, "shaped"); + GDVIRTUAL_BIND(shaped_text_set_custom_punctuation, "shaped", "punct"); + GDVIRTUAL_BIND(shaped_text_get_custom_punctuation, "shaped"); - GDVIRTUAL_BIND(_shaped_text_set_orientation, "shaped", "orientation"); - GDVIRTUAL_BIND(_shaped_text_get_orientation, "shaped"); + GDVIRTUAL_BIND(shaped_text_set_orientation, "shaped", "orientation"); + GDVIRTUAL_BIND(shaped_text_get_orientation, "shaped"); - GDVIRTUAL_BIND(_shaped_text_set_preserve_invalid, "shaped", "enabled"); - GDVIRTUAL_BIND(_shaped_text_get_preserve_invalid, "shaped"); + GDVIRTUAL_BIND(shaped_text_set_preserve_invalid, "shaped", "enabled"); + GDVIRTUAL_BIND(shaped_text_get_preserve_invalid, "shaped"); - GDVIRTUAL_BIND(_shaped_text_set_preserve_control, "shaped", "enabled"); - GDVIRTUAL_BIND(_shaped_text_get_preserve_control, "shaped"); + GDVIRTUAL_BIND(shaped_text_set_preserve_control, "shaped", "enabled"); + GDVIRTUAL_BIND(shaped_text_get_preserve_control, "shaped"); - GDVIRTUAL_BIND(_shaped_text_add_string, "shaped", "text", "fonts", "size", "opentype_features", "language", "meta"); - GDVIRTUAL_BIND(_shaped_text_add_object, "shaped", "key", "size", "inline_align", "length"); - GDVIRTUAL_BIND(_shaped_text_resize_object, "shaped", "key", "size", "inline_align"); + GDVIRTUAL_BIND(shaped_text_add_string, "shaped", "text", "fonts", "size", "opentype_features", "language", "meta"); + GDVIRTUAL_BIND(shaped_text_add_object, "shaped", "key", "size", "inline_align", "length"); + GDVIRTUAL_BIND(shaped_text_resize_object, "shaped", "key", "size", "inline_align"); - GDVIRTUAL_BIND(_shaped_get_span_count, "shaped"); - GDVIRTUAL_BIND(_shaped_get_span_meta, "shaped", "index"); - GDVIRTUAL_BIND(_shaped_set_span_update_font, "shaped", "index", "fonts", "size", "opentype_features"); + GDVIRTUAL_BIND(shaped_get_span_count, "shaped"); + GDVIRTUAL_BIND(shaped_get_span_meta, "shaped", "index"); + GDVIRTUAL_BIND(shaped_set_span_update_font, "shaped", "index", "fonts", "size", "opentype_features"); - GDVIRTUAL_BIND(_shaped_text_substr, "shaped", "start", "length"); - GDVIRTUAL_BIND(_shaped_text_get_parent, "shaped"); + GDVIRTUAL_BIND(shaped_text_substr, "shaped", "start", "length"); + GDVIRTUAL_BIND(shaped_text_get_parent, "shaped"); - GDVIRTUAL_BIND(_shaped_text_fit_to_width, "shaped", "width", "jst_flags"); - GDVIRTUAL_BIND(_shaped_text_tab_align, "shaped", "tab_stops"); + GDVIRTUAL_BIND(shaped_text_fit_to_width, "shaped", "width", "jst_flags"); + GDVIRTUAL_BIND(shaped_text_tab_align, "shaped", "tab_stops"); - GDVIRTUAL_BIND(_shaped_text_shape, "shaped"); - GDVIRTUAL_BIND(_shaped_text_update_breaks, "shaped"); - GDVIRTUAL_BIND(_shaped_text_update_justification_ops, "shaped"); + GDVIRTUAL_BIND(shaped_text_shape, "shaped"); + GDVIRTUAL_BIND(shaped_text_update_breaks, "shaped"); + GDVIRTUAL_BIND(shaped_text_update_justification_ops, "shaped"); - GDVIRTUAL_BIND(_shaped_text_is_ready, "shaped"); + GDVIRTUAL_BIND(shaped_text_is_ready, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_glyphs, "shaped"); - GDVIRTUAL_BIND(_shaped_text_sort_logical, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_glyph_count, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_glyphs, "shaped"); + GDVIRTUAL_BIND(shaped_text_sort_logical, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_glyph_count, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_range, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_range, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_line_breaks_adv, "shaped", "width", "start", "once", "break_flags"); - GDVIRTUAL_BIND(_shaped_text_get_line_breaks, "shaped", "width", "start", "break_flags"); - GDVIRTUAL_BIND(_shaped_text_get_word_breaks, "shaped", "grapheme_flags"); + GDVIRTUAL_BIND(shaped_text_get_line_breaks_adv, "shaped", "width", "start", "once", "break_flags"); + GDVIRTUAL_BIND(shaped_text_get_line_breaks, "shaped", "width", "start", "break_flags"); + GDVIRTUAL_BIND(shaped_text_get_word_breaks, "shaped", "grapheme_flags"); - GDVIRTUAL_BIND(_shaped_text_get_trim_pos, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_ellipsis_pos, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyph_count, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyphs, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_trim_pos, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_ellipsis_pos, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_ellipsis_glyph_count, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_ellipsis_glyphs, "shaped"); - GDVIRTUAL_BIND(_shaped_text_overrun_trim_to_width, "shaped", "width", "trim_flags"); + GDVIRTUAL_BIND(shaped_text_overrun_trim_to_width, "shaped", "width", "trim_flags"); - GDVIRTUAL_BIND(_shaped_text_get_objects, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_object_rect, "shaped", "key"); + GDVIRTUAL_BIND(shaped_text_get_objects, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_object_rect, "shaped", "key"); - GDVIRTUAL_BIND(_shaped_text_get_size, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_ascent, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_descent, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_width, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_underline_position, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_underline_thickness, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_size, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_ascent, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_descent, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_width, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_underline_position, "shaped"); + GDVIRTUAL_BIND(shaped_text_get_underline_thickness, "shaped"); - GDVIRTUAL_BIND(_shaped_text_get_dominant_direction_in_range, "shaped", "start", "end"); + GDVIRTUAL_BIND(shaped_text_get_dominant_direction_in_range, "shaped", "start", "end"); - GDVIRTUAL_BIND(_shaped_text_get_carets, "shaped", "position", "caret"); - GDVIRTUAL_BIND(_shaped_text_get_selection, "shaped", "start", "end"); + GDVIRTUAL_BIND(shaped_text_get_carets, "shaped", "position", "caret"); + GDVIRTUAL_BIND(shaped_text_get_selection, "shaped", "start", "end"); - GDVIRTUAL_BIND(_shaped_text_hit_test_grapheme, "shaped", "coord"); - GDVIRTUAL_BIND(_shaped_text_hit_test_position, "shaped", "coord"); + GDVIRTUAL_BIND(shaped_text_hit_test_grapheme, "shaped", "coord"); + GDVIRTUAL_BIND(shaped_text_hit_test_position, "shaped", "coord"); - GDVIRTUAL_BIND(_shaped_text_draw, "shaped", "canvas", "pos", "clip_l", "clip_r", "color"); - GDVIRTUAL_BIND(_shaped_text_draw_outline, "shaped", "canvas", "pos", "clip_l", "clip_r", "outline_size", "color"); + GDVIRTUAL_BIND(shaped_text_draw, "shaped", "canvas", "pos", "clip_l", "clip_r", "color"); + GDVIRTUAL_BIND(shaped_text_draw_outline, "shaped", "canvas", "pos", "clip_l", "clip_r", "outline_size", "color"); - GDVIRTUAL_BIND(_shaped_text_get_grapheme_bounds, "shaped", "pos"); - GDVIRTUAL_BIND(_shaped_text_next_grapheme_pos, "shaped", "pos"); - GDVIRTUAL_BIND(_shaped_text_prev_grapheme_pos, "shaped", "pos"); + GDVIRTUAL_BIND(shaped_text_get_grapheme_bounds, "shaped", "pos"); + GDVIRTUAL_BIND(shaped_text_next_grapheme_pos, "shaped", "pos"); + GDVIRTUAL_BIND(shaped_text_prev_grapheme_pos, "shaped", "pos"); - GDVIRTUAL_BIND(_format_number, "string", "language"); - GDVIRTUAL_BIND(_parse_number, "string", "language"); - GDVIRTUAL_BIND(_percent_sign, "language"); + GDVIRTUAL_BIND(format_number, "string", "language"); + GDVIRTUAL_BIND(parse_number, "string", "language"); + GDVIRTUAL_BIND(percent_sign, "language"); - GDVIRTUAL_BIND(_string_to_upper, "string", "language"); - GDVIRTUAL_BIND(_string_to_lower, "string", "language"); + GDVIRTUAL_BIND(strip_diacritics, "string"); + + GDVIRTUAL_BIND(string_to_upper, "string", "language"); + GDVIRTUAL_BIND(string_to_lower, "string", "language"); } bool TextServerExtension::has_feature(Feature p_feature) const { bool ret; - if (GDVIRTUAL_CALL(_has_feature, p_feature, ret)) { + if (GDVIRTUAL_CALL(has_feature, p_feature, ret)) { return ret; } return false; @@ -299,27 +301,27 @@ bool TextServerExtension::has_feature(Feature p_feature) const { String TextServerExtension::get_name() const { String ret; - if (GDVIRTUAL_CALL(_get_name, ret)) { + if (GDVIRTUAL_CALL(get_name, ret)) { return ret; } return "Unknown"; } -uint32_t TextServerExtension::get_features() const { - uint32_t ret; - if (GDVIRTUAL_CALL(_get_features, ret)) { +int64_t TextServerExtension::get_features() const { + int64_t ret; + if (GDVIRTUAL_CALL(get_features, ret)) { return ret; } return 0; } -void TextServerExtension::free(RID p_rid) { - GDVIRTUAL_CALL(_free, p_rid); +void TextServerExtension::free_rid(const RID &p_rid) { + GDVIRTUAL_CALL(free_rid, p_rid); } -bool TextServerExtension::has(RID p_rid) { +bool TextServerExtension::has(const RID &p_rid) { bool ret; - if (GDVIRTUAL_CALL(_has, p_rid, ret)) { + if (GDVIRTUAL_CALL(has, p_rid, ret)) { return ret; } return false; @@ -327,7 +329,7 @@ bool TextServerExtension::has(RID p_rid) { bool TextServerExtension::load_support_data(const String &p_filename) { bool ret; - if (GDVIRTUAL_CALL(_load_support_data, p_filename, ret)) { + if (GDVIRTUAL_CALL(load_support_data, p_filename, ret)) { return ret; } return false; @@ -335,7 +337,7 @@ bool TextServerExtension::load_support_data(const String &p_filename) { String TextServerExtension::get_support_data_filename() const { String ret; - if (GDVIRTUAL_CALL(_get_support_data_filename, ret)) { + if (GDVIRTUAL_CALL(get_support_data_filename, ret)) { return ret; } return String(); @@ -343,7 +345,7 @@ String TextServerExtension::get_support_data_filename() const { String TextServerExtension::get_support_data_info() const { String ret; - if (GDVIRTUAL_CALL(_get_support_data_info, ret)) { + if (GDVIRTUAL_CALL(get_support_data_info, ret)) { return ret; } return String(); @@ -351,7 +353,7 @@ String TextServerExtension::get_support_data_info() const { bool TextServerExtension::save_support_data(const String &p_filename) const { bool ret; - if (GDVIRTUAL_CALL(_save_support_data, p_filename, ret)) { + if (GDVIRTUAL_CALL(save_support_data, p_filename, ret)) { return ret; } return false; @@ -359,23 +361,23 @@ bool TextServerExtension::save_support_data(const String &p_filename) const { bool TextServerExtension::is_locale_right_to_left(const String &p_locale) const { bool ret; - if (GDVIRTUAL_CALL(_is_locale_right_to_left, p_locale, ret)) { + if (GDVIRTUAL_CALL(is_locale_right_to_left, p_locale, ret)) { return ret; } return false; } -int32_t TextServerExtension::name_to_tag(const String &p_name) const { - int32_t ret; - if (GDVIRTUAL_CALL(_name_to_tag, p_name, ret)) { +int64_t TextServerExtension::name_to_tag(const String &p_name) const { + int64_t ret; + if (GDVIRTUAL_CALL(name_to_tag, p_name, ret)) { return ret; } return 0; } -String TextServerExtension::tag_to_name(int32_t p_tag) const { +String TextServerExtension::tag_to_name(int64_t p_tag) const { String ret; - if (GDVIRTUAL_CALL(_tag_to_name, p_tag, ret)) { + if (GDVIRTUAL_CALL(tag_to_name, p_tag, ret)) { return ret; } return ""; @@ -387,594 +389,594 @@ String TextServerExtension::tag_to_name(int32_t p_tag) const { RID TextServerExtension::create_font() { RID ret; - if (GDVIRTUAL_CALL(_create_font, ret)) { + if (GDVIRTUAL_CALL(create_font, ret)) { return ret; } return RID(); } -void TextServerExtension::font_set_data(RID p_font_rid, const PackedByteArray &p_data) { - GDVIRTUAL_CALL(_font_set_data, p_font_rid, p_data); +void TextServerExtension::font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { + GDVIRTUAL_CALL(font_set_data, p_font_rid, p_data); } -void TextServerExtension::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) { - GDVIRTUAL_CALL(_font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size); +void TextServerExtension::font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { + GDVIRTUAL_CALL(font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size); } -void TextServerExtension::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) { - GDVIRTUAL_CALL(_font_set_style, p_font_rid, p_style); +void TextServerExtension::font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) { + GDVIRTUAL_CALL(font_set_style, p_font_rid, p_style); } -uint32_t /*FontStyle*/ TextServerExtension::font_get_style(RID p_font_rid) const { - uint32_t ret; - if (GDVIRTUAL_CALL(_font_get_style, p_font_rid, ret)) { +int64_t /*FontStyle*/ TextServerExtension::font_get_style(const RID &p_font_rid) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_style, p_font_rid, ret)) { return ret; } return 0; } -void TextServerExtension::font_set_style_name(RID p_font_rid, const String &p_name) { - GDVIRTUAL_CALL(_font_set_style_name, p_font_rid, p_name); +void TextServerExtension::font_set_style_name(const RID &p_font_rid, const String &p_name) { + GDVIRTUAL_CALL(font_set_style_name, p_font_rid, p_name); } -String TextServerExtension::font_get_style_name(RID p_font_rid) const { +String TextServerExtension::font_get_style_name(const RID &p_font_rid) const { String ret; - if (GDVIRTUAL_CALL(_font_get_style_name, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_style_name, p_font_rid, ret)) { return ret; } return String(); } -void TextServerExtension::font_set_name(RID p_font_rid, const String &p_name) { - GDVIRTUAL_CALL(_font_set_name, p_font_rid, p_name); +void TextServerExtension::font_set_name(const RID &p_font_rid, const String &p_name) { + GDVIRTUAL_CALL(font_set_name, p_font_rid, p_name); } -String TextServerExtension::font_get_name(RID p_font_rid) const { +String TextServerExtension::font_get_name(const RID &p_font_rid) const { String ret; - if (GDVIRTUAL_CALL(_font_get_name, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_name, p_font_rid, ret)) { return ret; } return String(); } -void TextServerExtension::font_set_antialiased(RID p_font_rid, bool p_antialiased) { - GDVIRTUAL_CALL(_font_set_antialiased, p_font_rid, p_antialiased); +void TextServerExtension::font_set_antialiased(const RID &p_font_rid, bool p_antialiased) { + GDVIRTUAL_CALL(font_set_antialiased, p_font_rid, p_antialiased); } -bool TextServerExtension::font_is_antialiased(RID p_font_rid) const { +bool TextServerExtension::font_is_antialiased(const RID &p_font_rid) const { bool ret; - if (GDVIRTUAL_CALL(_font_is_antialiased, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_is_antialiased, p_font_rid, ret)) { return ret; } return false; } -void TextServerExtension::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) { - GDVIRTUAL_CALL(_font_set_multichannel_signed_distance_field, p_font_rid, p_msdf); +void TextServerExtension::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { + GDVIRTUAL_CALL(font_set_multichannel_signed_distance_field, p_font_rid, p_msdf); } -bool TextServerExtension::font_is_multichannel_signed_distance_field(RID p_font_rid) const { +bool TextServerExtension::font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { bool ret; - if (GDVIRTUAL_CALL(_font_is_multichannel_signed_distance_field, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_is_multichannel_signed_distance_field, p_font_rid, ret)) { return ret; } return false; } -void TextServerExtension::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) { - GDVIRTUAL_CALL(_font_set_msdf_pixel_range, p_font_rid, p_msdf_pixel_range); +void TextServerExtension::font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { + GDVIRTUAL_CALL(font_set_msdf_pixel_range, p_font_rid, p_msdf_pixel_range); } -int TextServerExtension::font_get_msdf_pixel_range(RID p_font_rid) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_msdf_pixel_range, p_font_rid, ret)) { +int64_t TextServerExtension::font_get_msdf_pixel_range(const RID &p_font_rid) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_msdf_pixel_range, p_font_rid, ret)) { return ret; } return 0; } -void TextServerExtension::font_set_msdf_size(RID p_font_rid, int p_msdf_size) { - GDVIRTUAL_CALL(_font_set_msdf_size, p_font_rid, p_msdf_size); +void TextServerExtension::font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { + GDVIRTUAL_CALL(font_set_msdf_size, p_font_rid, p_msdf_size); } -int TextServerExtension::font_get_msdf_size(RID p_font_rid) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_msdf_size, p_font_rid, ret)) { +int64_t TextServerExtension::font_get_msdf_size(const RID &p_font_rid) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_msdf_size, p_font_rid, ret)) { return ret; } return 0; } -void TextServerExtension::font_set_fixed_size(RID p_font_rid, int p_fixed_size) { - GDVIRTUAL_CALL(_font_set_fixed_size, p_font_rid, p_fixed_size); +void TextServerExtension::font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { + GDVIRTUAL_CALL(font_set_fixed_size, p_font_rid, p_fixed_size); } -int TextServerExtension::font_get_fixed_size(RID p_font_rid) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_fixed_size, p_font_rid, ret)) { +int64_t TextServerExtension::font_get_fixed_size(const RID &p_font_rid) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_fixed_size, p_font_rid, ret)) { return ret; } return 0; } -void TextServerExtension::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) { - GDVIRTUAL_CALL(_font_set_force_autohinter, p_font_rid, p_force_autohinter); +void TextServerExtension::font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { + GDVIRTUAL_CALL(font_set_force_autohinter, p_font_rid, p_force_autohinter); } -bool TextServerExtension::font_is_force_autohinter(RID p_font_rid) const { +bool TextServerExtension::font_is_force_autohinter(const RID &p_font_rid) const { bool ret; - if (GDVIRTUAL_CALL(_font_is_force_autohinter, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_is_force_autohinter, p_font_rid, ret)) { return ret; } return false; } -void TextServerExtension::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) { - GDVIRTUAL_CALL(_font_set_hinting, p_font_rid, p_hinting); +void TextServerExtension::font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { + GDVIRTUAL_CALL(font_set_hinting, p_font_rid, p_hinting); } -TextServer::Hinting TextServerExtension::font_get_hinting(RID p_font_rid) const { +TextServer::Hinting TextServerExtension::font_get_hinting(const RID &p_font_rid) const { TextServer::Hinting ret; - if (GDVIRTUAL_CALL(_font_get_hinting, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_hinting, p_font_rid, ret)) { return (TextServer::Hinting)ret; } return TextServer::Hinting::HINTING_NONE; } -void TextServerExtension::font_set_subpixel_positioning(RID p_font_rid, TextServer::SubpixelPositioning p_subpixel) { - GDVIRTUAL_CALL(_font_set_subpixel_positioning, p_font_rid, p_subpixel); +void TextServerExtension::font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { + GDVIRTUAL_CALL(font_set_subpixel_positioning, p_font_rid, p_subpixel); } -TextServer::SubpixelPositioning TextServerExtension::font_get_subpixel_positioning(RID p_font_rid) const { +TextServer::SubpixelPositioning TextServerExtension::font_get_subpixel_positioning(const RID &p_font_rid) const { TextServer::SubpixelPositioning ret; - if (GDVIRTUAL_CALL(_font_get_subpixel_positioning, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_subpixel_positioning, p_font_rid, ret)) { return (TextServer::SubpixelPositioning)ret; } return TextServer::SubpixelPositioning::SUBPIXEL_POSITIONING_DISABLED; } -void TextServerExtension::font_set_embolden(RID p_font_rid, float p_strength) { - GDVIRTUAL_CALL(_font_set_embolden, p_font_rid, p_strength); +void TextServerExtension::font_set_embolden(const RID &p_font_rid, double p_strength) { + GDVIRTUAL_CALL(font_set_embolden, p_font_rid, p_strength); } -float TextServerExtension::font_get_embolden(RID p_font_rid) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_embolden, p_font_rid, ret)) { +double TextServerExtension::font_get_embolden(const RID &p_font_rid) const { + double ret; + if (GDVIRTUAL_CALL(font_get_embolden, p_font_rid, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_transform(RID p_font_rid, Transform2D p_transform) { - GDVIRTUAL_CALL(_font_set_transform, p_font_rid, p_transform); +void TextServerExtension::font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { + GDVIRTUAL_CALL(font_set_transform, p_font_rid, p_transform); } -Transform2D TextServerExtension::font_get_transform(RID p_font_rid) const { +Transform2D TextServerExtension::font_get_transform(const RID &p_font_rid) const { Transform2D ret; - if (GDVIRTUAL_CALL(_font_get_transform, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_transform, p_font_rid, ret)) { return ret; } return Transform2D(); } -void TextServerExtension::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) { - GDVIRTUAL_CALL(_font_set_variation_coordinates, p_font_rid, p_variation_coordinates); +void TextServerExtension::font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { + GDVIRTUAL_CALL(font_set_variation_coordinates, p_font_rid, p_variation_coordinates); } -Dictionary TextServerExtension::font_get_variation_coordinates(RID p_font_rid) const { +Dictionary TextServerExtension::font_get_variation_coordinates(const RID &p_font_rid) const { Dictionary ret; - if (GDVIRTUAL_CALL(_font_get_variation_coordinates, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_variation_coordinates, p_font_rid, ret)) { return ret; } return Dictionary(); } -void TextServerExtension::font_set_oversampling(RID p_font_rid, float p_oversampling) { - GDVIRTUAL_CALL(_font_set_oversampling, p_font_rid, p_oversampling); +void TextServerExtension::font_set_oversampling(const RID &p_font_rid, double p_oversampling) { + GDVIRTUAL_CALL(font_set_oversampling, p_font_rid, p_oversampling); } -float TextServerExtension::font_get_oversampling(RID p_font_rid) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_oversampling, p_font_rid, ret)) { +double TextServerExtension::font_get_oversampling(const RID &p_font_rid) const { + double ret; + if (GDVIRTUAL_CALL(font_get_oversampling, p_font_rid, ret)) { return ret; } - return 0.f; + return 0.0; } -Array TextServerExtension::font_get_size_cache_list(RID p_font_rid) const { +Array TextServerExtension::font_get_size_cache_list(const RID &p_font_rid) const { Array ret; - if (GDVIRTUAL_CALL(_font_get_size_cache_list, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_size_cache_list, p_font_rid, ret)) { return ret; } return Array(); } -void TextServerExtension::font_clear_size_cache(RID p_font_rid) { - GDVIRTUAL_CALL(_font_clear_size_cache, p_font_rid); +void TextServerExtension::font_clear_size_cache(const RID &p_font_rid) { + GDVIRTUAL_CALL(font_clear_size_cache, p_font_rid); } -void TextServerExtension::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) { - GDVIRTUAL_CALL(_font_remove_size_cache, p_font_rid, p_size); +void TextServerExtension::font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { + GDVIRTUAL_CALL(font_remove_size_cache, p_font_rid, p_size); } -void TextServerExtension::font_set_ascent(RID p_font_rid, int p_size, float p_ascent) { - GDVIRTUAL_CALL(_font_set_ascent, p_font_rid, p_size, p_ascent); +void TextServerExtension::font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { + GDVIRTUAL_CALL(font_set_ascent, p_font_rid, p_size, p_ascent); } -float TextServerExtension::font_get_ascent(RID p_font_rid, int p_size) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_ascent, p_font_rid, p_size, ret)) { +double TextServerExtension::font_get_ascent(const RID &p_font_rid, int64_t p_size) const { + double ret; + if (GDVIRTUAL_CALL(font_get_ascent, p_font_rid, p_size, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_descent(RID p_font_rid, int p_size, float p_descent) { - GDVIRTUAL_CALL(_font_set_descent, p_font_rid, p_size, p_descent); +void TextServerExtension::font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { + GDVIRTUAL_CALL(font_set_descent, p_font_rid, p_size, p_descent); } -float TextServerExtension::font_get_descent(RID p_font_rid, int p_size) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_descent, p_font_rid, p_size, ret)) { +double TextServerExtension::font_get_descent(const RID &p_font_rid, int64_t p_size) const { + double ret; + if (GDVIRTUAL_CALL(font_get_descent, p_font_rid, p_size, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) { - GDVIRTUAL_CALL(_font_set_underline_position, p_font_rid, p_size, p_underline_position); +void TextServerExtension::font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { + GDVIRTUAL_CALL(font_set_underline_position, p_font_rid, p_size, p_underline_position); } -float TextServerExtension::font_get_underline_position(RID p_font_rid, int p_size) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_underline_position, p_font_rid, p_size, ret)) { +double TextServerExtension::font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { + double ret; + if (GDVIRTUAL_CALL(font_get_underline_position, p_font_rid, p_size, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) { - GDVIRTUAL_CALL(_font_set_underline_thickness, p_font_rid, p_size, p_underline_thickness); +void TextServerExtension::font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { + GDVIRTUAL_CALL(font_set_underline_thickness, p_font_rid, p_size, p_underline_thickness); } -float TextServerExtension::font_get_underline_thickness(RID p_font_rid, int p_size) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_underline_thickness, p_font_rid, p_size, ret)) { +double TextServerExtension::font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { + double ret; + if (GDVIRTUAL_CALL(font_get_underline_thickness, p_font_rid, p_size, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_scale(RID p_font_rid, int p_size, float p_scale) { - GDVIRTUAL_CALL(_font_set_scale, p_font_rid, p_size, p_scale); +void TextServerExtension::font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { + GDVIRTUAL_CALL(font_set_scale, p_font_rid, p_size, p_scale); } -float TextServerExtension::font_get_scale(RID p_font_rid, int p_size) const { - float ret; - if (GDVIRTUAL_CALL(_font_get_scale, p_font_rid, p_size, ret)) { +double TextServerExtension::font_get_scale(const RID &p_font_rid, int64_t p_size) const { + double ret; + if (GDVIRTUAL_CALL(font_get_scale, p_font_rid, p_size, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) { - GDVIRTUAL_CALL(_font_set_spacing, p_font_rid, p_size, p_spacing, p_value); +void TextServerExtension::font_set_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing, int64_t p_value) { + GDVIRTUAL_CALL(font_set_spacing, p_font_rid, p_size, p_spacing, p_value); } -int TextServerExtension::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_spacing, p_font_rid, p_size, p_spacing, ret)) { +int64_t TextServerExtension::font_get_spacing(const RID &p_font_rid, int64_t p_size, TextServer::SpacingType p_spacing) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_spacing, p_font_rid, p_size, p_spacing, ret)) { return ret; } return 0; } -int TextServerExtension::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_texture_count, p_font_rid, p_size, ret)) { +int64_t TextServerExtension::font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_texture_count, p_font_rid, p_size, ret)) { return ret; } return 0; } -void TextServerExtension::font_clear_textures(RID p_font_rid, const Vector2i &p_size) { - GDVIRTUAL_CALL(_font_clear_textures, p_font_rid, p_size); +void TextServerExtension::font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { + GDVIRTUAL_CALL(font_clear_textures, p_font_rid, p_size); } -void TextServerExtension::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) { - GDVIRTUAL_CALL(_font_remove_texture, p_font_rid, p_size, p_texture_index); +void TextServerExtension::font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { + GDVIRTUAL_CALL(font_remove_texture, p_font_rid, p_size, p_texture_index); } -void TextServerExtension::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) { - GDVIRTUAL_CALL(_font_set_texture_image, p_font_rid, p_size, p_texture_index, p_image); +void TextServerExtension::font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) { + GDVIRTUAL_CALL(font_set_texture_image, p_font_rid, p_size, p_texture_index, p_image); } -Ref TextServerExtension::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +Ref TextServerExtension::font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { Ref ret; - if (GDVIRTUAL_CALL(_font_get_texture_image, p_font_rid, p_size, p_texture_index, ret)) { + if (GDVIRTUAL_CALL(font_get_texture_image, p_font_rid, p_size, p_texture_index, ret)) { return ret; } return Ref(); } -void TextServerExtension::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) { - GDVIRTUAL_CALL(_font_set_texture_offsets, p_font_rid, p_size, p_texture_index, p_offset); +void TextServerExtension::font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) { + GDVIRTUAL_CALL(font_set_texture_offsets, p_font_rid, p_size, p_texture_index, p_offset); } -PackedInt32Array TextServerExtension::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +PackedInt32Array TextServerExtension::font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { PackedInt32Array ret; - if (GDVIRTUAL_CALL(_font_get_texture_offsets, p_font_rid, p_size, p_texture_index, ret)) { + if (GDVIRTUAL_CALL(font_get_texture_offsets, p_font_rid, p_size, p_texture_index, ret)) { return ret; } return PackedInt32Array(); } -Array TextServerExtension::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const { +Array TextServerExtension::font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { Array ret; - if (GDVIRTUAL_CALL(_font_get_glyph_list, p_font_rid, p_size, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_list, p_font_rid, p_size, ret)) { return ret; } return Array(); } -void TextServerExtension::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) { - GDVIRTUAL_CALL(_font_clear_glyphs, p_font_rid, p_size); +void TextServerExtension::font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { + GDVIRTUAL_CALL(font_clear_glyphs, p_font_rid, p_size); } -void TextServerExtension::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) { - GDVIRTUAL_CALL(_font_remove_glyph, p_font_rid, p_size, p_glyph); +void TextServerExtension::font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { + GDVIRTUAL_CALL(font_remove_glyph, p_font_rid, p_size, p_glyph); } -Vector2 TextServerExtension::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const { +Vector2 TextServerExtension::font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { Vector2 ret; - if (GDVIRTUAL_CALL(_font_get_glyph_advance, p_font_rid, p_size, p_glyph, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_advance, p_font_rid, p_size, p_glyph, ret)) { return ret; } return Vector2(); } -void TextServerExtension::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) { - GDVIRTUAL_CALL(_font_set_glyph_advance, p_font_rid, p_size, p_glyph, p_advance); +void TextServerExtension::font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { + GDVIRTUAL_CALL(font_set_glyph_advance, p_font_rid, p_size, p_glyph, p_advance); } -Vector2 TextServerExtension::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerExtension::font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { Vector2 ret; - if (GDVIRTUAL_CALL(_font_get_glyph_offset, p_font_rid, p_size, p_glyph, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_offset, p_font_rid, p_size, p_glyph, ret)) { return ret; } return Vector2(); } -void TextServerExtension::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) { - GDVIRTUAL_CALL(_font_set_glyph_offset, p_font_rid, p_size, p_glyph, p_offset); +void TextServerExtension::font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { + GDVIRTUAL_CALL(font_set_glyph_offset, p_font_rid, p_size, p_glyph, p_offset); } -Vector2 TextServerExtension::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Vector2 TextServerExtension::font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { Vector2 ret; - if (GDVIRTUAL_CALL(_font_get_glyph_size, p_font_rid, p_size, p_glyph, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_size, p_font_rid, p_size, p_glyph, ret)) { return ret; } return Vector2(); } -void TextServerExtension::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) { - GDVIRTUAL_CALL(_font_set_glyph_size, p_font_rid, p_size, p_glyph, p_gl_size); +void TextServerExtension::font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { + GDVIRTUAL_CALL(font_set_glyph_size, p_font_rid, p_size, p_glyph, p_gl_size); } -Rect2 TextServerExtension::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { +Rect2 TextServerExtension::font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { Rect2 ret; - if (GDVIRTUAL_CALL(_font_get_glyph_uv_rect, p_font_rid, p_size, p_glyph, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_uv_rect, p_font_rid, p_size, p_glyph, ret)) { return ret; } return Rect2(); } -void TextServerExtension::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) { - GDVIRTUAL_CALL(_font_set_glyph_uv_rect, p_font_rid, p_size, p_glyph, p_uv_rect); +void TextServerExtension::font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { + GDVIRTUAL_CALL(font_set_glyph_uv_rect, p_font_rid, p_size, p_glyph, p_uv_rect); } -int TextServerExtension::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const { - int ret; - if (GDVIRTUAL_CALL(_font_get_glyph_texture_idx, p_font_rid, p_size, p_glyph, ret)) { +int64_t TextServerExtension::font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_glyph_texture_idx, p_font_rid, p_size, p_glyph, ret)) { return ret; } return 0; } -void TextServerExtension::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) { - GDVIRTUAL_CALL(_font_set_glyph_texture_idx, p_font_rid, p_size, p_glyph, p_texture_idx); +void TextServerExtension::font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { + GDVIRTUAL_CALL(font_set_glyph_texture_idx, p_font_rid, p_size, p_glyph, p_texture_idx); } -Dictionary TextServerExtension::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index) const { +Dictionary TextServerExtension::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { Dictionary ret; - if (GDVIRTUAL_CALL(_font_get_glyph_contours, p_font_rid, p_size, p_index, ret)) { + if (GDVIRTUAL_CALL(font_get_glyph_contours, p_font_rid, p_size, p_index, ret)) { return ret; } return Dictionary(); } -Array TextServerExtension::font_get_kerning_list(RID p_font_rid, int p_size) const { +Array TextServerExtension::font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { Array ret; - if (GDVIRTUAL_CALL(_font_get_kerning_list, p_font_rid, p_size, ret)) { + if (GDVIRTUAL_CALL(font_get_kerning_list, p_font_rid, p_size, ret)) { return ret; } return Array(); } -void TextServerExtension::font_clear_kerning_map(RID p_font_rid, int p_size) { - GDVIRTUAL_CALL(_font_clear_kerning_map, p_font_rid, p_size); +void TextServerExtension::font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { + GDVIRTUAL_CALL(font_clear_kerning_map, p_font_rid, p_size); } -void TextServerExtension::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) { - GDVIRTUAL_CALL(_font_remove_kerning, p_font_rid, p_size, p_glyph_pair); +void TextServerExtension::font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { + GDVIRTUAL_CALL(font_remove_kerning, p_font_rid, p_size, p_glyph_pair); } -void TextServerExtension::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { - GDVIRTUAL_CALL(_font_set_kerning, p_font_rid, p_size, p_glyph_pair, p_kerning); +void TextServerExtension::font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { + GDVIRTUAL_CALL(font_set_kerning, p_font_rid, p_size, p_glyph_pair, p_kerning); } -Vector2 TextServerExtension::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const { +Vector2 TextServerExtension::font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { Vector2 ret; - if (GDVIRTUAL_CALL(_font_get_kerning, p_font_rid, p_size, p_glyph_pair, ret)) { + if (GDVIRTUAL_CALL(font_get_kerning, p_font_rid, p_size, p_glyph_pair, ret)) { return ret; } return Vector2(); } -int32_t TextServerExtension::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const { - int32_t ret; - if (GDVIRTUAL_CALL(_font_get_glyph_index, p_font_rid, p_size, p_char, p_variation_selector, ret)) { +int64_t TextServerExtension::font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const { + int64_t ret; + if (GDVIRTUAL_CALL(font_get_glyph_index, p_font_rid, p_size, p_char, p_variation_selector, ret)) { return ret; } return 0; } -bool TextServerExtension::font_has_char(RID p_font_rid, char32_t p_char) const { +bool TextServerExtension::font_has_char(const RID &p_font_rid, int64_t p_char) const { bool ret; - if (GDVIRTUAL_CALL(_font_has_char, p_font_rid, p_char, ret)) { + if (GDVIRTUAL_CALL(font_has_char, p_font_rid, p_char, ret)) { return ret; } return false; } -String TextServerExtension::font_get_supported_chars(RID p_font_rid) const { +String TextServerExtension::font_get_supported_chars(const RID &p_font_rid) const { String ret; - if (GDVIRTUAL_CALL(_font_get_supported_chars, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_get_supported_chars, p_font_rid, ret)) { return ret; } return String(); } -void TextServerExtension::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) { - GDVIRTUAL_CALL(_font_render_range, p_font_rid, p_size, p_start, p_end); +void TextServerExtension::font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { + GDVIRTUAL_CALL(font_render_range, p_font_rid, p_size, p_start, p_end); } -void TextServerExtension::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) { - GDVIRTUAL_CALL(_font_render_glyph, p_font_rid, p_size, p_index); +void TextServerExtension::font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { + GDVIRTUAL_CALL(font_render_glyph, p_font_rid, p_size, p_index); } -void TextServerExtension::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { - GDVIRTUAL_CALL(_font_draw_glyph, p_font_rid, p_canvas, p_size, p_pos, p_index, p_color); +void TextServerExtension::font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { + GDVIRTUAL_CALL(font_draw_glyph, p_font_rid, p_canvas, p_size, p_pos, p_index, p_color); } -void TextServerExtension::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const { - GDVIRTUAL_CALL(_font_draw_glyph_outline, p_font_rid, p_canvas, p_size, p_outline_size, p_pos, p_index, p_color); +void TextServerExtension::font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { + GDVIRTUAL_CALL(font_draw_glyph_outline, p_font_rid, p_canvas, p_size, p_outline_size, p_pos, p_index, p_color); } -bool TextServerExtension::font_is_language_supported(RID p_font_rid, const String &p_language) const { +bool TextServerExtension::font_is_language_supported(const RID &p_font_rid, const String &p_language) const { bool ret; - if (GDVIRTUAL_CALL(_font_is_language_supported, p_font_rid, p_language, ret)) { + if (GDVIRTUAL_CALL(font_is_language_supported, p_font_rid, p_language, ret)) { return ret; } return false; } -void TextServerExtension::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) { - GDVIRTUAL_CALL(_font_set_language_support_override, p_font_rid, p_language, p_supported); +void TextServerExtension::font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { + GDVIRTUAL_CALL(font_set_language_support_override, p_font_rid, p_language, p_supported); } -bool TextServerExtension::font_get_language_support_override(RID p_font_rid, const String &p_language) { +bool TextServerExtension::font_get_language_support_override(const RID &p_font_rid, const String &p_language) { bool ret; - if (GDVIRTUAL_CALL(_font_get_language_support_override, p_font_rid, p_language, ret)) { + if (GDVIRTUAL_CALL(font_get_language_support_override, p_font_rid, p_language, ret)) { return ret; } return false; } -void TextServerExtension::font_remove_language_support_override(RID p_font_rid, const String &p_language) { - GDVIRTUAL_CALL(_font_remove_language_support_override, p_font_rid, p_language); +void TextServerExtension::font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { + GDVIRTUAL_CALL(font_remove_language_support_override, p_font_rid, p_language); } -Vector TextServerExtension::font_get_language_support_overrides(RID p_font_rid) { - Vector ret; - if (GDVIRTUAL_CALL(_font_get_language_support_overrides, p_font_rid, ret)) { +PackedStringArray TextServerExtension::font_get_language_support_overrides(const RID &p_font_rid) { + PackedStringArray ret; + if (GDVIRTUAL_CALL(font_get_language_support_overrides, p_font_rid, ret)) { return ret; } - return Vector(); + return PackedStringArray(); } -bool TextServerExtension::font_is_script_supported(RID p_font_rid, const String &p_script) const { +bool TextServerExtension::font_is_script_supported(const RID &p_font_rid, const String &p_script) const { bool ret; - if (GDVIRTUAL_CALL(_font_is_script_supported, p_font_rid, p_script, ret)) { + if (GDVIRTUAL_CALL(font_is_script_supported, p_font_rid, p_script, ret)) { return ret; } return false; } -void TextServerExtension::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) { - GDVIRTUAL_CALL(_font_set_script_support_override, p_font_rid, p_script, p_supported); +void TextServerExtension::font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { + GDVIRTUAL_CALL(font_set_script_support_override, p_font_rid, p_script, p_supported); } -bool TextServerExtension::font_get_script_support_override(RID p_font_rid, const String &p_script) { +bool TextServerExtension::font_get_script_support_override(const RID &p_font_rid, const String &p_script) { bool ret; - if (GDVIRTUAL_CALL(_font_get_script_support_override, p_font_rid, p_script, ret)) { + if (GDVIRTUAL_CALL(font_get_script_support_override, p_font_rid, p_script, ret)) { return ret; } return false; } -void TextServerExtension::font_remove_script_support_override(RID p_font_rid, const String &p_script) { - GDVIRTUAL_CALL(_font_remove_script_support_override, p_font_rid, p_script); +void TextServerExtension::font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { + GDVIRTUAL_CALL(font_remove_script_support_override, p_font_rid, p_script); } -Vector TextServerExtension::font_get_script_support_overrides(RID p_font_rid) { - Vector ret; - if (GDVIRTUAL_CALL(_font_get_script_support_overrides, p_font_rid, ret)) { +PackedStringArray TextServerExtension::font_get_script_support_overrides(const RID &p_font_rid) { + PackedStringArray ret; + if (GDVIRTUAL_CALL(font_get_script_support_overrides, p_font_rid, ret)) { return ret; } - return Vector(); + return PackedStringArray(); } -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); +void TextServerExtension::font_set_opentype_feature_overrides(const 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 TextServerExtension::font_get_opentype_feature_overrides(const RID &p_font_rid) const { Dictionary ret; - if (GDVIRTUAL_CALL(_font_get_opentype_feature_overrides, p_font_rid, 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 TextServerExtension::font_supported_feature_list(const RID &p_font_rid) const { Dictionary ret; - if (GDVIRTUAL_CALL(_font_supported_feature_list, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_supported_feature_list, p_font_rid, ret)) { return ret; } return Dictionary(); } -Dictionary TextServerExtension::font_supported_variation_list(RID p_font_rid) const { +Dictionary TextServerExtension::font_supported_variation_list(const RID &p_font_rid) const { Dictionary ret; - if (GDVIRTUAL_CALL(_font_supported_variation_list, p_font_rid, ret)) { + if (GDVIRTUAL_CALL(font_supported_variation_list, p_font_rid, ret)) { return ret; } return Dictionary(); } -float TextServerExtension::font_get_global_oversampling() const { - float ret; - if (GDVIRTUAL_CALL(_font_get_global_oversampling, ret)) { +double TextServerExtension::font_get_global_oversampling() const { + double ret; + if (GDVIRTUAL_CALL(font_get_global_oversampling, ret)) { return ret; } - return 0.f; + return 0.0; } -void TextServerExtension::font_set_global_oversampling(float p_oversampling) { - GDVIRTUAL_CALL(_font_set_global_oversampling, p_oversampling); +void TextServerExtension::font_set_global_oversampling(double p_oversampling) { + GDVIRTUAL_CALL(font_set_global_oversampling, p_oversampling); } -Vector2 TextServerExtension::get_hex_code_box_size(int p_size, char32_t p_index) const { +Vector2 TextServerExtension::get_hex_code_box_size(int64_t p_size, int64_t p_index) const { Vector2 ret; - if (GDVIRTUAL_CALL(_get_hex_code_box_size, p_size, p_index, ret)) { + if (GDVIRTUAL_CALL(get_hex_code_box_size, p_size, p_index, ret)) { return ret; } return TextServer::get_hex_code_box_size(p_size, p_index); } -void TextServerExtension::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const { - if (!GDVIRTUAL_CALL(_draw_hex_code_box, p_canvas, p_size, p_pos, p_index, p_color)) { +void TextServerExtension::draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { + if (!GDVIRTUAL_CALL(draw_hex_code_box, p_canvas, p_size, p_pos, p_index, p_color)) { TextServer::draw_hex_code_box(p_canvas, p_size, p_pos, p_index, p_color); } } @@ -985,433 +987,425 @@ void TextServerExtension::draw_hex_code_box(RID p_canvas, int p_size, const Vect RID TextServerExtension::create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) { RID ret; - if (GDVIRTUAL_CALL(_create_shaped_text, p_direction, p_orientation, ret)) { + if (GDVIRTUAL_CALL(create_shaped_text, p_direction, p_orientation, ret)) { return ret; } return RID(); } -void TextServerExtension::shaped_text_clear(RID p_shaped) { - GDVIRTUAL_CALL(_shaped_text_clear, p_shaped); +void TextServerExtension::shaped_text_clear(const RID &p_shaped) { + GDVIRTUAL_CALL(shaped_text_clear, p_shaped); } -void TextServerExtension::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) { - GDVIRTUAL_CALL(_shaped_text_set_direction, p_shaped, p_direction); +void TextServerExtension::shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) { + GDVIRTUAL_CALL(shaped_text_set_direction, p_shaped, p_direction); } -TextServer::Direction TextServerExtension::shaped_text_get_direction(RID p_shaped) const { +TextServer::Direction TextServerExtension::shaped_text_get_direction(const RID &p_shaped) const { TextServer::Direction ret; - if (GDVIRTUAL_CALL(_shaped_text_get_direction, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_direction, p_shaped, ret)) { return (TextServer::Direction)ret; } return TextServer::Direction::DIRECTION_AUTO; } -TextServer::Direction TextServerExtension::shaped_text_get_inferred_direction(RID p_shaped) const { +TextServer::Direction TextServerExtension::shaped_text_get_inferred_direction(const RID &p_shaped) const { TextServer::Direction ret; - if (GDVIRTUAL_CALL(_shaped_text_get_inferred_direction, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_inferred_direction, p_shaped, ret)) { return (TextServer::Direction)ret; } return TextServer::Direction::DIRECTION_LTR; } -void TextServerExtension::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) { - GDVIRTUAL_CALL(_shaped_text_set_orientation, p_shaped, p_orientation); +void TextServerExtension::shaped_text_set_orientation(const RID &p_shaped, TextServer::Orientation p_orientation) { + GDVIRTUAL_CALL(shaped_text_set_orientation, p_shaped, p_orientation); } -TextServer::Orientation TextServerExtension::shaped_text_get_orientation(RID p_shaped) const { +TextServer::Orientation TextServerExtension::shaped_text_get_orientation(const RID &p_shaped) const { TextServer::Orientation ret; - if (GDVIRTUAL_CALL(_shaped_text_get_orientation, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_orientation, p_shaped, ret)) { return (TextServer::Orientation)ret; } return TextServer::Orientation::ORIENTATION_HORIZONTAL; } -void TextServerExtension::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) { - GDVIRTUAL_CALL(_shaped_text_set_bidi_override, p_shaped, p_override); +void TextServerExtension::shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) { + GDVIRTUAL_CALL(shaped_text_set_bidi_override, p_shaped, p_override); } -void TextServerExtension::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) { - GDVIRTUAL_CALL(_shaped_text_set_custom_punctuation, p_shaped, p_punct); +void TextServerExtension::shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) { + GDVIRTUAL_CALL(shaped_text_set_custom_punctuation, p_shaped, p_punct); } -String TextServerExtension::shaped_text_get_custom_punctuation(RID p_shaped) const { +String TextServerExtension::shaped_text_get_custom_punctuation(const RID &p_shaped) const { String ret; - if (GDVIRTUAL_CALL(_shaped_text_get_custom_punctuation, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_custom_punctuation, p_shaped, ret)) { return ret; } return String(); } -void TextServerExtension::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) { - GDVIRTUAL_CALL(_shaped_text_set_preserve_invalid, p_shaped, p_enabled); +void TextServerExtension::shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) { + GDVIRTUAL_CALL(shaped_text_set_preserve_invalid, p_shaped, p_enabled); } -bool TextServerExtension::shaped_text_get_preserve_invalid(RID p_shaped) const { +bool TextServerExtension::shaped_text_get_preserve_invalid(const RID &p_shaped) const { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_get_preserve_invalid, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_preserve_invalid, p_shaped, ret)) { return ret; } return false; } -void TextServerExtension::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) { - GDVIRTUAL_CALL(_shaped_text_set_preserve_control, p_shaped, p_enabled); +void TextServerExtension::shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) { + GDVIRTUAL_CALL(shaped_text_set_preserve_control, p_shaped, p_enabled); } -bool TextServerExtension::shaped_text_get_preserve_control(RID p_shaped) const { +bool TextServerExtension::shaped_text_get_preserve_control(const RID &p_shaped) const { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_get_preserve_control, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_preserve_control, p_shaped, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { +bool TextServerExtension::shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { bool ret; - Array fonts; - for (int i = 0; i < p_fonts.size(); i++) { - fonts.push_back(p_fonts[i]); - } - if (GDVIRTUAL_CALL(_shaped_text_add_string, p_shaped, p_text, fonts, p_size, p_opentype_features, p_language, p_meta, ret)) { + if (GDVIRTUAL_CALL(shaped_text_add_string, p_shaped, p_text, p_fonts, p_size, p_opentype_features, p_language, p_meta, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align, int p_length) { +bool TextServerExtension::shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, int64_t p_length) { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_add_object, p_shaped, p_key, p_size, p_inline_align, p_length, ret)) { + if (GDVIRTUAL_CALL(shaped_text_add_object, p_shaped, p_key, p_size, p_inline_align, p_length, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align) { +bool TextServerExtension::shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align) { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_resize_object, p_shaped, p_key, p_size, p_inline_align, ret)) { + if (GDVIRTUAL_CALL(shaped_text_resize_object, p_shaped, p_key, p_size, p_inline_align, ret)) { return ret; } return false; } -int TextServerExtension::shaped_get_span_count(RID p_shaped) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_get_span_count, p_shaped, ret)) { +int64_t TextServerExtension::shaped_get_span_count(const RID &p_shaped) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_get_span_count, p_shaped, ret)) { return ret; } return 0; } -Variant TextServerExtension::shaped_get_span_meta(RID p_shaped, int p_index) const { +Variant TextServerExtension::shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const { Variant ret; - if (GDVIRTUAL_CALL(_shaped_get_span_meta, p_shaped, p_index, ret)) { + if (GDVIRTUAL_CALL(shaped_get_span_meta, p_shaped, p_index, ret)) { return ret; } return false; } -void TextServerExtension::shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features) { - Array fonts; - for (int i = 0; i < p_fonts.size(); i++) { - fonts.push_back(p_fonts[i]); - } - GDVIRTUAL_CALL(_shaped_set_span_update_font, p_shaped, p_index, fonts, p_size, p_opentype_features); +void TextServerExtension::shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { + GDVIRTUAL_CALL(shaped_set_span_update_font, p_shaped, p_index, p_fonts, p_size, p_opentype_features); } -RID TextServerExtension::shaped_text_substr(RID p_shaped, int p_start, int p_length) const { +RID TextServerExtension::shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const { RID ret; - if (GDVIRTUAL_CALL(_shaped_text_substr, p_shaped, p_start, p_length, ret)) { + if (GDVIRTUAL_CALL(shaped_text_substr, p_shaped, p_start, p_length, ret)) { return ret; } return RID(); } -RID TextServerExtension::shaped_text_get_parent(RID p_shaped) const { +RID TextServerExtension::shaped_text_get_parent(const RID &p_shaped) const { RID ret; - if (GDVIRTUAL_CALL(_shaped_text_get_parent, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_parent, p_shaped, ret)) { return ret; } return RID(); } -float TextServerExtension::shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t p_jst_flags) { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_fit_to_width, p_shaped, p_width, p_jst_flags, ret)) { +double TextServerExtension::shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t p_jst_flags) { + double ret; + if (GDVIRTUAL_CALL(shaped_text_fit_to_width, p_shaped, p_width, p_jst_flags, ret)) { return ret; } - return 0.f; + return 0.0; } -float TextServerExtension::shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_tab_align, p_shaped, p_tab_stops, ret)) { +double TextServerExtension::shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) { + double ret; + if (GDVIRTUAL_CALL(shaped_text_tab_align, p_shaped, p_tab_stops, ret)) { return ret; } - return 0.f; + return 0.0; } -bool TextServerExtension::shaped_text_shape(RID p_shaped) { +bool TextServerExtension::shaped_text_shape(const RID &p_shaped) { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_shape, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_shape, p_shaped, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_update_breaks(RID p_shaped) { +bool TextServerExtension::shaped_text_update_breaks(const RID &p_shaped) { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_update_breaks, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_update_breaks, p_shaped, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_update_justification_ops(RID p_shaped) { +bool TextServerExtension::shaped_text_update_justification_ops(const RID &p_shaped) { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_update_justification_ops, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_update_justification_ops, p_shaped, ret)) { return ret; } return false; } -bool TextServerExtension::shaped_text_is_ready(RID p_shaped) const { +bool TextServerExtension::shaped_text_is_ready(const RID &p_shaped) const { bool ret; - if (GDVIRTUAL_CALL(_shaped_text_is_ready, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_is_ready, p_shaped, ret)) { return ret; } return false; } -const Glyph *TextServerExtension::shaped_text_get_glyphs(RID p_shaped) const { - GDNativePtr ret; - if (GDVIRTUAL_CALL(_shaped_text_get_glyphs, p_shaped, ret)) { +const Glyph *TextServerExtension::shaped_text_get_glyphs(const RID &p_shaped) const { + GDNativeConstPtr ret; + if (GDVIRTUAL_CALL(shaped_text_get_glyphs, p_shaped, ret)) { return ret; } return nullptr; } -const Glyph *TextServerExtension::shaped_text_sort_logical(RID p_shaped) { - GDNativePtr ret; - if (GDVIRTUAL_CALL(_shaped_text_sort_logical, p_shaped, ret)) { +const Glyph *TextServerExtension::shaped_text_sort_logical(const RID &p_shaped) { + GDNativeConstPtr ret; + if (GDVIRTUAL_CALL(shaped_text_sort_logical, p_shaped, ret)) { return ret; } return nullptr; } -int TextServerExtension::shaped_text_get_glyph_count(RID p_shaped) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_get_glyph_count, p_shaped, ret)) { +int64_t TextServerExtension::shaped_text_get_glyph_count(const RID &p_shaped) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_get_glyph_count, p_shaped, ret)) { return ret; } return 0; } -Vector2i TextServerExtension::shaped_text_get_range(RID p_shaped) const { +Vector2i TextServerExtension::shaped_text_get_range(const RID &p_shaped) const { Vector2i ret; - if (GDVIRTUAL_CALL(_shaped_text_get_range, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_range, p_shaped, ret)) { return ret; } return Vector2i(); } -PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint16_t p_break_flags) const { +PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, int64_t p_break_flags) const { PackedInt32Array ret; - if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks_adv, p_shaped, p_width, p_start, p_once, p_break_flags, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_line_breaks_adv, p_shaped, p_width, p_start, p_once, p_break_flags, ret)) { return ret; } return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_start, p_once, p_break_flags); } -PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint16_t p_break_flags) const { +PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, int64_t p_break_flags) const { PackedInt32Array ret; - if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks, p_shaped, p_width, p_start, p_break_flags, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_line_breaks, p_shaped, p_width, p_start, p_break_flags, ret)) { return ret; } return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_start, p_break_flags); } -PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { +PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags) const { PackedInt32Array ret; - if (GDVIRTUAL_CALL(_shaped_text_get_word_breaks, p_shaped, p_grapheme_flags, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_word_breaks, p_shaped, p_grapheme_flags, ret)) { return ret; } return TextServer::shaped_text_get_word_breaks(p_shaped, p_grapheme_flags); } -int TextServerExtension::shaped_text_get_trim_pos(RID p_shaped) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_get_trim_pos, p_shaped, ret)) { +int64_t TextServerExtension::shaped_text_get_trim_pos(const RID &p_shaped) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_get_trim_pos, p_shaped, ret)) { return ret; } return -1; } -int TextServerExtension::shaped_text_get_ellipsis_pos(RID p_shaped) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_pos, p_shaped, ret)) { +int64_t TextServerExtension::shaped_text_get_ellipsis_pos(const RID &p_shaped) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_get_ellipsis_pos, p_shaped, ret)) { return ret; } return -1; } -const Glyph *TextServerExtension::shaped_text_get_ellipsis_glyphs(RID p_shaped) const { - GDNativePtr ret; - if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyphs, p_shaped, ret)) { +const Glyph *TextServerExtension::shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const { + GDNativeConstPtr ret; + if (GDVIRTUAL_CALL(shaped_text_get_ellipsis_glyphs, p_shaped, ret)) { return ret; } return nullptr; } -int TextServerExtension::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyph_count, p_shaped, ret)) { +int64_t TextServerExtension::shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_get_ellipsis_glyph_count, p_shaped, ret)) { return ret; } return -1; } -void TextServerExtension::shaped_text_overrun_trim_to_width(RID p_shaped_line, float p_width, uint16_t p_trim_flags) { - GDVIRTUAL_CALL(_shaped_text_overrun_trim_to_width, p_shaped_line, p_width, p_trim_flags); +void TextServerExtension::shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, int64_t p_trim_flags) { + GDVIRTUAL_CALL(shaped_text_overrun_trim_to_width, p_shaped_line, p_width, p_trim_flags); } -Array TextServerExtension::shaped_text_get_objects(RID p_shaped) const { +Array TextServerExtension::shaped_text_get_objects(const RID &p_shaped) const { Array ret; - if (GDVIRTUAL_CALL(_shaped_text_get_objects, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_objects, p_shaped, ret)) { return ret; } return Array(); } -Rect2 TextServerExtension::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const { +Rect2 TextServerExtension::shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const { Rect2 ret; - if (GDVIRTUAL_CALL(_shaped_text_get_object_rect, p_shaped, p_key, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_object_rect, p_shaped, p_key, ret)) { return ret; } return Rect2(); } -Size2 TextServerExtension::shaped_text_get_size(RID p_shaped) const { +Size2 TextServerExtension::shaped_text_get_size(const RID &p_shaped) const { Size2 ret; - if (GDVIRTUAL_CALL(_shaped_text_get_size, p_shaped, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_size, p_shaped, ret)) { return ret; } return Size2(); } -float TextServerExtension::shaped_text_get_ascent(RID p_shaped) const { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_get_ascent, p_shaped, ret)) { +double TextServerExtension::shaped_text_get_ascent(const RID &p_shaped) const { + double ret; + if (GDVIRTUAL_CALL(shaped_text_get_ascent, p_shaped, ret)) { return ret; } - return 0.f; + return 0.0; } -float TextServerExtension::shaped_text_get_descent(RID p_shaped) const { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_get_descent, p_shaped, ret)) { +double TextServerExtension::shaped_text_get_descent(const RID &p_shaped) const { + double ret; + if (GDVIRTUAL_CALL(shaped_text_get_descent, p_shaped, ret)) { return ret; } - return 0.f; + return 0.0; } -float TextServerExtension::shaped_text_get_width(RID p_shaped) const { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_get_width, p_shaped, ret)) { +double TextServerExtension::shaped_text_get_width(const RID &p_shaped) const { + double ret; + if (GDVIRTUAL_CALL(shaped_text_get_width, p_shaped, ret)) { return ret; } - return 0.f; + return 0.0; } -float TextServerExtension::shaped_text_get_underline_position(RID p_shaped) const { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_get_underline_position, p_shaped, ret)) { +double TextServerExtension::shaped_text_get_underline_position(const RID &p_shaped) const { + double ret; + if (GDVIRTUAL_CALL(shaped_text_get_underline_position, p_shaped, ret)) { return ret; } - return 0.f; + return 0.0; } -float TextServerExtension::shaped_text_get_underline_thickness(RID p_shaped) const { - float ret; - if (GDVIRTUAL_CALL(_shaped_text_get_underline_thickness, p_shaped, ret)) { +double TextServerExtension::shaped_text_get_underline_thickness(const RID &p_shaped) const { + double ret; + if (GDVIRTUAL_CALL(shaped_text_get_underline_thickness, p_shaped, ret)) { return ret; } - return 0.f; + return 0.0; } -TextServer::Direction TextServerExtension::shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_get_dominant_direction_in_range, p_shaped, p_start, p_end, ret)) { +TextServer::Direction TextServerExtension::shaped_text_get_dominant_direction_in_range(const RID &p_shaped, int64_t p_start, int64_t p_end) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_get_dominant_direction_in_range, p_shaped, p_start, p_end, ret)) { return (TextServer::Direction)ret; } return TextServer::shaped_text_get_dominant_direction_in_range(p_shaped, p_start, p_end); } -CaretInfo TextServerExtension::shaped_text_get_carets(RID p_shaped, int p_position) const { +CaretInfo TextServerExtension::shaped_text_get_carets(const RID &p_shaped, int64_t p_position) const { CaretInfo ret; - if (GDVIRTUAL_CALL(_shaped_text_get_carets, p_shaped, p_position, &ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_carets, p_shaped, p_position, &ret)) { return ret; } return TextServer::shaped_text_get_carets(p_shaped, p_position); } -Vector TextServerExtension::shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const { +Vector TextServerExtension::shaped_text_get_selection(const RID &p_shaped, int64_t p_start, int64_t p_end) const { Vector ret; - if (GDVIRTUAL_CALL(_shaped_text_get_selection, p_shaped, p_start, p_end, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_selection, p_shaped, p_start, p_end, ret)) { return ret; } return TextServer::shaped_text_get_selection(p_shaped, p_start, p_end); } -int TextServerExtension::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_hit_test_grapheme, p_shaped, p_coords, ret)) { +int64_t TextServerExtension::shaped_text_hit_test_grapheme(const RID &p_shaped, double p_coords) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_hit_test_grapheme, p_shaped, p_coords, ret)) { return ret; } return TextServer::shaped_text_hit_test_grapheme(p_shaped, p_coords); } -int TextServerExtension::shaped_text_hit_test_position(RID p_shaped, float p_coords) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_hit_test_position, p_shaped, p_coords, ret)) { +int64_t TextServerExtension::shaped_text_hit_test_position(const RID &p_shaped, double p_coords) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_hit_test_position, p_shaped, p_coords, ret)) { return ret; } return TextServer::shaped_text_hit_test_position(p_shaped, p_coords); } -void TextServerExtension::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, const Color &p_color) const { - if (GDVIRTUAL_CALL(_shaped_text_draw, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color)) { +void TextServerExtension::shaped_text_draw(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l, double p_clip_r, const Color &p_color) const { + if (GDVIRTUAL_CALL(shaped_text_draw, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color)) { return; } TextServer::shaped_text_draw(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color); } -void TextServerExtension::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, int p_outline_size, const Color &p_color) const { - if (GDVIRTUAL_CALL(_shaped_text_draw_outline, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color)) { +void TextServerExtension::shaped_text_draw_outline(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l, double p_clip_r, int64_t p_outline_size, const Color &p_color) const { + if (GDVIRTUAL_CALL(shaped_text_draw_outline, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color)) { return; } - shaped_text_draw_outline(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color); + TextServer::shaped_text_draw_outline(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color); } -Vector2 TextServerExtension::shaped_text_get_grapheme_bounds(RID p_shaped, int p_pos) const { +Vector2 TextServerExtension::shaped_text_get_grapheme_bounds(const RID &p_shaped, int64_t p_pos) const { Vector2 ret; - if (GDVIRTUAL_CALL(_shaped_text_get_grapheme_bounds, p_shaped, p_pos, ret)) { + if (GDVIRTUAL_CALL(shaped_text_get_grapheme_bounds, p_shaped, p_pos, ret)) { return ret; } return TextServer::shaped_text_get_grapheme_bounds(p_shaped, p_pos); } -int TextServerExtension::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_next_grapheme_pos, p_shaped, p_pos, ret)) { +int64_t TextServerExtension::shaped_text_next_grapheme_pos(const RID &p_shaped, int64_t p_pos) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_next_grapheme_pos, p_shaped, p_pos, ret)) { return ret; } return TextServer::shaped_text_next_grapheme_pos(p_shaped, p_pos); } -int TextServerExtension::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const { - int ret; - if (GDVIRTUAL_CALL(_shaped_text_prev_grapheme_pos, p_shaped, p_pos, ret)) { +int64_t TextServerExtension::shaped_text_prev_grapheme_pos(const RID &p_shaped, int64_t p_pos) const { + int64_t ret; + if (GDVIRTUAL_CALL(shaped_text_prev_grapheme_pos, p_shaped, p_pos, ret)) { return ret; } return TextServer::shaped_text_prev_grapheme_pos(p_shaped, p_pos); @@ -1419,31 +1413,39 @@ int TextServerExtension::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) String TextServerExtension::format_number(const String &p_string, const String &p_language) const { String ret; - if (GDVIRTUAL_CALL(_format_number, p_string, p_language, ret)) { + if (GDVIRTUAL_CALL(format_number, p_string, p_language, ret)) { return ret; } - return TextServer::format_number(p_string, p_language); + return p_string; } String TextServerExtension::parse_number(const String &p_string, const String &p_language) const { String ret; - if (GDVIRTUAL_CALL(_parse_number, p_string, p_language, ret)) { + if (GDVIRTUAL_CALL(parse_number, p_string, p_language, ret)) { return ret; } - return TextServer::parse_number(p_string, p_language); + return p_string; } String TextServerExtension::percent_sign(const String &p_language) const { String ret; - if (GDVIRTUAL_CALL(_percent_sign, p_language, ret)) { + if (GDVIRTUAL_CALL(percent_sign, p_language, ret)) { return ret; } - return TextServer::percent_sign(p_language); + return "%"; +} + +String TextServerExtension::strip_diacritics(const String &p_string) const { + String ret; + if (GDVIRTUAL_CALL(strip_diacritics, p_string, ret)) { + return ret; + } + return TextServer::strip_diacritics(p_string); } String TextServerExtension::string_to_upper(const String &p_string, const String &p_language) const { String ret; - if (GDVIRTUAL_CALL(_string_to_upper, p_string, p_language, ret)) { + if (GDVIRTUAL_CALL(string_to_upper, p_string, p_language, ret)) { return ret; } return p_string; @@ -1451,7 +1453,7 @@ String TextServerExtension::string_to_upper(const String &p_string, const String String TextServerExtension::string_to_lower(const String &p_string, const String &p_language) const { String ret; - if (GDVIRTUAL_CALL(_string_to_lower, p_string, p_language, ret)) { + if (GDVIRTUAL_CALL(string_to_lower, p_string, p_language, ret)) { return ret; } return p_string; diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h index 7d804673711..c6e7bef4e8f 100644 --- a/servers/text/text_server_extension.h +++ b/servers/text/text_server_extension.h @@ -48,433 +48,436 @@ protected: public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual uint32_t get_features() const override; - GDVIRTUAL1RC(bool, _has_feature, Feature); - GDVIRTUAL0RC(String, _get_name); - GDVIRTUAL0RC(uint32_t, _get_features); + virtual int64_t get_features() const override; + GDVIRTUAL1RC(bool, has_feature, Feature); + GDVIRTUAL0RC(String, get_name); + GDVIRTUAL0RC(int64_t, get_features); - virtual void free(RID p_rid) override; - virtual bool has(RID p_rid) override; + virtual void free_rid(const RID &p_rid) override; + virtual bool has(const RID &p_rid) override; virtual bool load_support_data(const String &p_filename) override; - GDVIRTUAL1(_free, RID); - GDVIRTUAL1R(bool, _has, RID); - GDVIRTUAL1R(bool, _load_support_data, const String &); + GDVIRTUAL1(free_rid, RID); + GDVIRTUAL1R(bool, has, RID); + GDVIRTUAL1R(bool, load_support_data, const String &); virtual String get_support_data_filename() const override; virtual String get_support_data_info() const override; virtual bool save_support_data(const String &p_filename) const override; - GDVIRTUAL0RC(String, _get_support_data_filename); - GDVIRTUAL0RC(String, _get_support_data_info); - GDVIRTUAL1RC(bool, _save_support_data, const String &); + GDVIRTUAL0RC(String, get_support_data_filename); + GDVIRTUAL0RC(String, get_support_data_info); + GDVIRTUAL1RC(bool, save_support_data, const String &); virtual bool is_locale_right_to_left(const String &p_locale) const override; - GDVIRTUAL1RC(bool, _is_locale_right_to_left, const String &); + GDVIRTUAL1RC(bool, is_locale_right_to_left, const String &); - virtual int32_t name_to_tag(const String &p_name) const override; - virtual String tag_to_name(int32_t p_tag) const override; - GDVIRTUAL1RC(int32_t, _name_to_tag, const String &); - GDVIRTUAL1RC(String, _tag_to_name, int32_t); + virtual int64_t name_to_tag(const String &p_name) const override; + virtual String tag_to_name(int64_t p_tag) const override; + GDVIRTUAL1RC(int64_t, name_to_tag, const String &); + GDVIRTUAL1RC(String, tag_to_name, int64_t); /* Font interface */ virtual RID create_font() override; - GDVIRTUAL0R(RID, _create_font); + GDVIRTUAL0R(RID, create_font); - virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) override; - virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override; - GDVIRTUAL2(_font_set_data, RID, const PackedByteArray &); - GDVIRTUAL3(_font_set_data_ptr, RID, GDNativeConstPtr, uint64_t); + virtual void font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) override; + virtual void font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) override; + GDVIRTUAL2(font_set_data, RID, const PackedByteArray &); + GDVIRTUAL3(font_set_data_ptr, RID, GDNativeConstPtr, int64_t); - virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override; - virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_style, RID, uint32_t); - GDVIRTUAL1RC(uint32_t, _font_get_style, RID); + virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) override; + virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_style, RID, int64_t); + GDVIRTUAL1RC(int64_t, font_get_style, RID); - virtual void font_set_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_name(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_name, RID, const String &); - GDVIRTUAL1RC(String, _font_get_name, RID); + virtual void font_set_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_name(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_name, RID, const String &); + GDVIRTUAL1RC(String, font_get_name, RID); - virtual void font_set_style_name(RID p_font_rid, const String &p_name) override; - virtual String font_get_style_name(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_style_name, RID, const String &); - GDVIRTUAL1RC(String, _font_get_style_name, RID); + virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override; + virtual String font_get_style_name(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_style_name, RID, const String &); + GDVIRTUAL1RC(String, font_get_style_name, RID); - virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override; - virtual bool font_is_antialiased(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_antialiased, RID, bool); - GDVIRTUAL1RC(bool, _font_is_antialiased, RID); + virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) override; + virtual bool font_is_antialiased(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_antialiased, RID, bool); + GDVIRTUAL1RC(bool, font_is_antialiased, RID); - virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) override; - virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_multichannel_signed_distance_field, RID, bool); - GDVIRTUAL1RC(bool, _font_is_multichannel_signed_distance_field, RID); + virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override; + virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_multichannel_signed_distance_field, RID, bool); + GDVIRTUAL1RC(bool, font_is_multichannel_signed_distance_field, RID); - virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) override; - virtual int font_get_msdf_pixel_range(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_msdf_pixel_range, RID, int); - GDVIRTUAL1RC(int, _font_get_msdf_pixel_range, RID); + virtual void font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) override; + virtual int64_t font_get_msdf_pixel_range(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_msdf_pixel_range, RID, int64_t); + GDVIRTUAL1RC(int64_t, font_get_msdf_pixel_range, RID); - virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) override; - virtual int font_get_msdf_size(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_msdf_size, RID, int); - GDVIRTUAL1RC(int, _font_get_msdf_size, RID); + virtual void font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) override; + virtual int64_t font_get_msdf_size(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_msdf_size, RID, int64_t); + GDVIRTUAL1RC(int64_t, font_get_msdf_size, RID); - virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) override; - virtual int font_get_fixed_size(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_fixed_size, RID, int); - GDVIRTUAL1RC(int, _font_get_fixed_size, RID); + virtual void font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) override; + virtual int64_t font_get_fixed_size(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_fixed_size, RID, int64_t); + GDVIRTUAL1RC(int64_t, font_get_fixed_size, RID); - virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) override; - virtual bool font_is_force_autohinter(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_force_autohinter, RID, bool); - GDVIRTUAL1RC(bool, _font_is_force_autohinter, RID); + virtual void font_set_subpixel_positioning(const RID &p_font_rid, SubpixelPositioning p_subpixel) override; + virtual SubpixelPositioning font_get_subpixel_positioning(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_subpixel_positioning, RID, SubpixelPositioning); + GDVIRTUAL1RC(SubpixelPositioning, font_get_subpixel_positioning, RID); - virtual void font_set_hinting(RID p_font_rid, Hinting p_hinting) override; - virtual Hinting font_get_hinting(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_hinting, RID, Hinting); - GDVIRTUAL1RC(Hinting, _font_get_hinting, RID); + virtual void font_set_embolden(const RID &p_font_rid, double p_strength) override; + virtual double font_get_embolden(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_embolden, RID, double); + GDVIRTUAL1RC(double, font_get_embolden, RID); - virtual void font_set_subpixel_positioning(RID p_font_rid, SubpixelPositioning p_subpixel) override; - virtual SubpixelPositioning font_get_subpixel_positioning(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_subpixel_positioning, RID, SubpixelPositioning); - GDVIRTUAL1RC(SubpixelPositioning, _font_get_subpixel_positioning, RID); + virtual void font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) override; + virtual Transform2D font_get_transform(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_transform, RID, Transform2D); + GDVIRTUAL1RC(Transform2D, font_get_transform, RID); - virtual void font_set_embolden(RID p_font_rid, float p_strength) override; - virtual float font_get_embolden(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_embolden, RID, float); - GDVIRTUAL1RC(float, _font_get_embolden, RID); + virtual void font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) override; + virtual bool font_is_force_autohinter(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_force_autohinter, RID, bool); + GDVIRTUAL1RC(bool, font_is_force_autohinter, RID); - virtual void font_set_transform(RID p_font_rid, Transform2D p_transform) override; - virtual Transform2D font_get_transform(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_transform, RID, Transform2D); - GDVIRTUAL1RC(Transform2D, _font_get_transform, RID); + virtual void font_set_hinting(const RID &p_font_rid, Hinting p_hinting) override; + virtual Hinting font_get_hinting(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_hinting, RID, Hinting); + GDVIRTUAL1RC(Hinting, font_get_hinting, RID); - virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) override; - virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_variation_coordinates, RID, Dictionary); - GDVIRTUAL1RC(Dictionary, _font_get_variation_coordinates, RID); + virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) override; + virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_variation_coordinates, RID, Dictionary); + GDVIRTUAL1RC(Dictionary, font_get_variation_coordinates, RID); - virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) override; - virtual float font_get_oversampling(RID p_font_rid) const override; - GDVIRTUAL2(_font_set_oversampling, RID, float); - GDVIRTUAL1RC(float, _font_get_oversampling, RID); + virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) override; + virtual double font_get_oversampling(const RID &p_font_rid) const override; + GDVIRTUAL2(font_set_oversampling, RID, double); + GDVIRTUAL1RC(double, font_get_oversampling, RID); - virtual Array font_get_size_cache_list(RID p_font_rid) const override; - virtual void font_clear_size_cache(RID p_font_rid) override; - virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) override; - GDVIRTUAL1RC(Array, _font_get_size_cache_list, RID); - GDVIRTUAL1(_font_clear_size_cache, RID); - GDVIRTUAL2(_font_remove_size_cache, RID, const Vector2i &); + virtual Array font_get_size_cache_list(const RID &p_font_rid) const override; + virtual void font_clear_size_cache(const RID &p_font_rid) override; + virtual void font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) override; + GDVIRTUAL1RC(Array, font_get_size_cache_list, RID); + GDVIRTUAL1(font_clear_size_cache, RID); + GDVIRTUAL2(font_remove_size_cache, RID, const Vector2i &); - virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) override; - virtual float font_get_ascent(RID p_font_rid, int p_size) const override; - GDVIRTUAL3(_font_set_ascent, RID, int, float); - GDVIRTUAL2RC(float, _font_get_ascent, RID, int); + virtual void font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) override; + virtual double font_get_ascent(const RID &p_font_rid, int64_t p_size) const override; + GDVIRTUAL3(font_set_ascent, RID, int64_t, double); + GDVIRTUAL2RC(double, font_get_ascent, RID, int64_t); - virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) override; - virtual float font_get_descent(RID p_font_rid, int p_size) const override; - GDVIRTUAL3(_font_set_descent, RID, int, float); - GDVIRTUAL2RC(float, _font_get_descent, RID, int); + virtual void font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) override; + virtual double font_get_descent(const RID &p_font_rid, int64_t p_size) const override; + GDVIRTUAL3(font_set_descent, RID, int64_t, double); + GDVIRTUAL2RC(double, font_get_descent, RID, int64_t); - virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) override; - virtual float font_get_underline_position(RID p_font_rid, int p_size) const override; - GDVIRTUAL3(_font_set_underline_position, RID, int, float); - GDVIRTUAL2RC(float, _font_get_underline_position, RID, int); + virtual void font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) override; + virtual double font_get_underline_position(const RID &p_font_rid, int64_t p_size) const override; + GDVIRTUAL3(font_set_underline_position, RID, int64_t, double); + GDVIRTUAL2RC(double, font_get_underline_position, RID, int64_t); - virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) override; - virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const override; - GDVIRTUAL3(_font_set_underline_thickness, RID, int, float); - GDVIRTUAL2RC(float, _font_get_underline_thickness, RID, int); + virtual void font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) override; + virtual double font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const override; + GDVIRTUAL3(font_set_underline_thickness, RID, int64_t, double); + GDVIRTUAL2RC(double, font_get_underline_thickness, RID, int64_t); - virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) override; - virtual float font_get_scale(RID p_font_rid, int p_size) const override; - GDVIRTUAL3(_font_set_scale, RID, int, float); - GDVIRTUAL2RC(float, _font_get_scale, RID, int); + virtual void font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) override; + virtual double font_get_scale(const RID &p_font_rid, int64_t p_size) const override; + GDVIRTUAL3(font_set_scale, RID, int64_t, double); + GDVIRTUAL2RC(double, font_get_scale, RID, int64_t); - virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) override; - virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const override; - GDVIRTUAL4(_font_set_spacing, RID, int, SpacingType, int); - GDVIRTUAL3RC(int, _font_get_spacing, RID, int, SpacingType); + virtual void font_set_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing, int64_t p_value) override; + virtual int64_t font_get_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing) const override; + GDVIRTUAL4(font_set_spacing, RID, int64_t, SpacingType, int64_t); + GDVIRTUAL3RC(int64_t, font_get_spacing, RID, int64_t, SpacingType); - virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) override; - GDVIRTUAL2RC(int, _font_get_texture_count, RID, const Vector2i &); - GDVIRTUAL2(_font_clear_textures, RID, const Vector2i &); - GDVIRTUAL3(_font_remove_texture, RID, const Vector2i &, int); + virtual int64_t font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) override; + GDVIRTUAL2RC(int64_t, font_get_texture_count, RID, const Vector2i &); + GDVIRTUAL2(font_clear_textures, RID, const Vector2i &); + GDVIRTUAL3(font_remove_texture, RID, const Vector2i &, int64_t); - virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) override; - virtual Ref font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; - GDVIRTUAL4(_font_set_texture_image, RID, const Vector2i &, int, const Ref &); - GDVIRTUAL3RC(Ref, _font_get_texture_image, RID, const Vector2i &, int); + virtual void font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) override; + virtual Ref font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; + GDVIRTUAL4(font_set_texture_image, RID, const Vector2i &, int64_t, const Ref &); + GDVIRTUAL3RC(Ref, font_get_texture_image, RID, const Vector2i &, int64_t); - virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) override; - virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const override; - GDVIRTUAL4(_font_set_texture_offsets, RID, const Vector2i &, int, const PackedInt32Array &); - GDVIRTUAL3RC(PackedInt32Array, _font_get_texture_offsets, RID, const Vector2i &, int); + virtual void font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) override; + virtual PackedInt32Array font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override; + GDVIRTUAL4(font_set_texture_offsets, RID, const Vector2i &, int64_t, const PackedInt32Array &); + GDVIRTUAL3RC(PackedInt32Array, font_get_texture_offsets, RID, const Vector2i &, int64_t); - virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const override; - virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) override; - virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) override; - GDVIRTUAL2RC(Array, _font_get_glyph_list, RID, const Vector2i &); - GDVIRTUAL2(_font_clear_glyphs, RID, const Vector2i &); - GDVIRTUAL3(_font_remove_glyph, RID, const Vector2i &, int32_t); + virtual Array font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const override; + virtual void font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) override; + virtual void font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) override; + GDVIRTUAL2RC(Array, font_get_glyph_list, RID, const Vector2i &); + GDVIRTUAL2(font_clear_glyphs, RID, const Vector2i &); + GDVIRTUAL3(font_remove_glyph, RID, const Vector2i &, int64_t); - virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) override; - GDVIRTUAL3RC(Vector2, _font_get_glyph_advance, RID, int, int32_t); - GDVIRTUAL4(_font_set_glyph_advance, RID, int, int32_t, const Vector2 &); + virtual Vector2 font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) override; + GDVIRTUAL3RC(Vector2, font_get_glyph_advance, RID, int64_t, int64_t); + GDVIRTUAL4(font_set_glyph_advance, RID, int64_t, int64_t, const Vector2 &); - virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) override; - GDVIRTUAL3RC(Vector2, _font_get_glyph_offset, RID, const Vector2i &, int32_t); - GDVIRTUAL4(_font_set_glyph_offset, RID, const Vector2i &, int32_t, const Vector2 &); + virtual Vector2 font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) override; + GDVIRTUAL3RC(Vector2, font_get_glyph_offset, RID, const Vector2i &, int64_t); + GDVIRTUAL4(font_set_glyph_offset, RID, const Vector2i &, int64_t, const Vector2 &); - virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) override; - GDVIRTUAL3RC(Vector2, _font_get_glyph_size, RID, const Vector2i &, int32_t); - GDVIRTUAL4(_font_set_glyph_size, RID, const Vector2i &, int32_t, const Vector2 &); + virtual Vector2 font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) override; + GDVIRTUAL3RC(Vector2, font_get_glyph_size, RID, const Vector2i &, int64_t); + GDVIRTUAL4(font_set_glyph_size, RID, const Vector2i &, int64_t, const Vector2 &); - virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) override; - GDVIRTUAL3RC(Rect2, _font_get_glyph_uv_rect, RID, const Vector2i &, int32_t); - GDVIRTUAL4(_font_set_glyph_uv_rect, RID, const Vector2i &, int32_t, const Rect2 &); + virtual Rect2 font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) override; + GDVIRTUAL3RC(Rect2, font_get_glyph_uv_rect, RID, const Vector2i &, int64_t); + GDVIRTUAL4(font_set_glyph_uv_rect, RID, const Vector2i &, int64_t, const Rect2 &); - virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const override; - virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) override; - GDVIRTUAL3RC(int, _font_get_glyph_texture_idx, RID, const Vector2i &, int32_t); - GDVIRTUAL4(_font_set_glyph_texture_idx, RID, const Vector2i &, int32_t, int); + virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override; + virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override; + GDVIRTUAL3RC(int64_t, font_get_glyph_texture_idx, RID, const Vector2i &, int64_t); + GDVIRTUAL4(font_set_glyph_texture_idx, RID, const Vector2i &, int64_t, int64_t); - virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const override; - GDVIRTUAL3RC(Dictionary, _font_get_glyph_contours, RID, int, int32_t); + virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override; + GDVIRTUAL3RC(Dictionary, font_get_glyph_contours, RID, int64_t, int64_t); - virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const override; - virtual void font_clear_kerning_map(RID p_font_rid, int p_size) override; - virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) override; - GDVIRTUAL2RC(Array, _font_get_kerning_list, RID, int); - GDVIRTUAL2(_font_clear_kerning_map, RID, int); - GDVIRTUAL3(_font_remove_kerning, RID, int, const Vector2i &); + virtual Array font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const override; + virtual void font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) override; + virtual void font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) override; + GDVIRTUAL2RC(Array, font_get_kerning_list, RID, int64_t); + GDVIRTUAL2(font_clear_kerning_map, RID, int64_t); + GDVIRTUAL3(font_remove_kerning, RID, int64_t, const Vector2i &); - virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; - virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const override; - GDVIRTUAL4(_font_set_kerning, RID, int, const Vector2i &, const Vector2 &); - GDVIRTUAL3RC(Vector2, _font_get_kerning, RID, int, const Vector2i &); + virtual void font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override; + virtual Vector2 font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const override; + GDVIRTUAL4(font_set_kerning, RID, int64_t, const Vector2i &, const Vector2 &); + GDVIRTUAL3RC(Vector2, font_get_kerning, RID, int64_t, const Vector2i &); - virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector = 0) const override; - GDVIRTUAL4RC(int32_t, _font_get_glyph_index, RID, int, char32_t, char32_t); + virtual int64_t font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector = 0) const override; + GDVIRTUAL4RC(int64_t, font_get_glyph_index, RID, int64_t, int64_t, int64_t); - virtual bool font_has_char(RID p_font_rid, char32_t p_char) const override; - virtual String font_get_supported_chars(RID p_font_rid) const override; - GDVIRTUAL2RC(bool, _font_has_char, RID, char32_t); - GDVIRTUAL1RC(String, _font_get_supported_chars, RID); + virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const override; + virtual String font_get_supported_chars(const RID &p_font_rid) const override; + GDVIRTUAL2RC(bool, font_has_char, RID, int64_t); + GDVIRTUAL1RC(String, font_get_supported_chars, RID); - virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) override; - virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) override; - GDVIRTUAL4(_font_render_range, RID, const Vector2i &, char32_t, char32_t); - GDVIRTUAL3(_font_render_glyph, RID, const Vector2i &, int32_t); + virtual void font_render_range(const RID &p_font, const Vector2i &p_size, int64_t p_start, int64_t p_end) override; + virtual void font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) override; + GDVIRTUAL4(font_render_range, RID, const Vector2i &, int64_t, int64_t); + GDVIRTUAL3(font_render_glyph, RID, const Vector2i &, int64_t); - virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const override; - GDVIRTUAL6C(_font_draw_glyph, RID, RID, int, const Vector2 &, int32_t, const Color &); - GDVIRTUAL7C(_font_draw_glyph_outline, RID, RID, int, int, const Vector2 &, int32_t, const Color &); + virtual void font_draw_glyph(const RID &p_font, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + virtual void font_draw_glyph_outline(const RID &p_font, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override; + GDVIRTUAL6C(font_draw_glyph, RID, RID, int64_t, const Vector2 &, int64_t, const Color &); + GDVIRTUAL7C(font_draw_glyph_outline, RID, RID, int64_t, int64_t, const Vector2 &, int64_t, const Color &); - virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const override; - virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) override; - virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) override; - virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) override; - virtual Vector font_get_language_support_overrides(RID p_font_rid) override; - GDVIRTUAL2RC(bool, _font_is_language_supported, RID, const String &); - GDVIRTUAL3(_font_set_language_support_override, RID, const String &, bool); - GDVIRTUAL2R(bool, _font_get_language_support_override, RID, const String &); - GDVIRTUAL2(_font_remove_language_support_override, RID, const String &); - GDVIRTUAL1R(Vector, _font_get_language_support_overrides, RID); + virtual bool font_is_language_supported(const RID &p_font_rid, const String &p_language) const override; + virtual void font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) override; + virtual bool font_get_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual void font_remove_language_support_override(const RID &p_font_rid, const String &p_language) override; + virtual PackedStringArray font_get_language_support_overrides(const RID &p_font_rid) override; + GDVIRTUAL2RC(bool, font_is_language_supported, RID, const String &); + GDVIRTUAL3(font_set_language_support_override, RID, const String &, bool); + GDVIRTUAL2R(bool, font_get_language_support_override, RID, const String &); + GDVIRTUAL2(font_remove_language_support_override, RID, const String &); + GDVIRTUAL1R(PackedStringArray, font_get_language_support_overrides, RID); - virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const override; - virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) override; - virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) override; - virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) override; - virtual Vector font_get_script_support_overrides(RID p_font_rid) override; - GDVIRTUAL2RC(bool, _font_is_script_supported, RID, const String &); - GDVIRTUAL3(_font_set_script_support_override, RID, const String &, bool); - GDVIRTUAL2R(bool, _font_get_script_support_override, RID, const String &); - GDVIRTUAL2(_font_remove_script_support_override, RID, const String &); - GDVIRTUAL1R(Vector, _font_get_script_support_overrides, RID); + virtual bool font_is_script_supported(const RID &p_font_rid, const String &p_script) const override; + virtual void font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) override; + virtual bool font_get_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual void font_remove_script_support_override(const RID &p_font_rid, const String &p_script) override; + virtual PackedStringArray font_get_script_support_overrides(const RID &p_font_rid) override; + GDVIRTUAL2RC(bool, font_is_script_supported, RID, const String &); + GDVIRTUAL3(font_set_script_support_override, RID, const String &, bool); + GDVIRTUAL2R(bool, font_get_script_support_override, RID, const String &); + GDVIRTUAL2(font_remove_script_support_override, RID, const String &); + GDVIRTUAL1R(PackedStringArray, 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 void font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) override; + virtual Dictionary font_get_opentype_feature_overrides(const 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); - GDVIRTUAL1RC(Dictionary, _font_supported_variation_list, RID); + virtual Dictionary font_supported_feature_list(const RID &p_font_rid) const override; + virtual Dictionary font_supported_variation_list(const RID &p_font_rid) const override; + GDVIRTUAL1RC(Dictionary, font_supported_feature_list, RID); + GDVIRTUAL1RC(Dictionary, font_supported_variation_list, RID); - virtual float font_get_global_oversampling() const override; - virtual void font_set_global_oversampling(float p_oversampling) override; - GDVIRTUAL0RC(float, _font_get_global_oversampling); - GDVIRTUAL1(_font_set_global_oversampling, float); + virtual double font_get_global_oversampling() const override; + virtual void font_set_global_oversampling(double p_oversampling) override; + GDVIRTUAL0RC(double, font_get_global_oversampling); + GDVIRTUAL1(font_set_global_oversampling, double); - virtual Vector2 get_hex_code_box_size(int p_size, char32_t p_index) const override; - virtual void draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const override; - GDVIRTUAL2RC(Vector2, _get_hex_code_box_size, int, char32_t); - GDVIRTUAL5C(_draw_hex_code_box, RID, int, const Vector2 &, char32_t, const Color &); + virtual Vector2 get_hex_code_box_size(int64_t p_size, int64_t p_index) const override; + virtual void draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const override; + GDVIRTUAL2RC(Vector2, get_hex_code_box_size, int64_t, int64_t); + GDVIRTUAL5C(draw_hex_code_box, RID, int64_t, const Vector2 &, int64_t, const Color &); /* Shaped text buffer interface */ virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - GDVIRTUAL2R(RID, _create_shaped_text, Direction, Orientation); + GDVIRTUAL2R(RID, create_shaped_text, Direction, Orientation); - virtual void shaped_text_clear(RID p_shaped) override; - GDVIRTUAL1(_shaped_text_clear, RID); + virtual void shaped_text_clear(const RID &p_shaped) override; + GDVIRTUAL1(shaped_text_clear, RID); - virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override; - virtual Direction shaped_text_get_direction(RID p_shaped) const override; - virtual Direction shaped_text_get_inferred_direction(RID p_shaped) const override; - GDVIRTUAL2(_shaped_text_set_direction, RID, Direction); - GDVIRTUAL1RC(Direction, _shaped_text_get_direction, RID); - GDVIRTUAL1RC(Direction, _shaped_text_get_inferred_direction, RID); + virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) override; + virtual Direction shaped_text_get_direction(const RID &p_shaped) const override; + virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const override; + GDVIRTUAL2(shaped_text_set_direction, RID, Direction); + GDVIRTUAL1RC(Direction, shaped_text_get_direction, RID); + GDVIRTUAL1RC(Direction, shaped_text_get_inferred_direction, RID); - virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override; - GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &); + virtual void shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) override; + GDVIRTUAL2(shaped_text_set_bidi_override, RID, const Array &); - virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override; - virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override; - GDVIRTUAL2(_shaped_text_set_custom_punctuation, RID, String); - GDVIRTUAL1RC(String, _shaped_text_get_custom_punctuation, RID); + virtual void shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) override; + virtual String shaped_text_get_custom_punctuation(const RID &p_shaped) const override; + GDVIRTUAL2(shaped_text_set_custom_punctuation, RID, String); + GDVIRTUAL1RC(String, shaped_text_get_custom_punctuation, RID); - virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; - virtual Orientation shaped_text_get_orientation(RID p_shaped) const override; - GDVIRTUAL2(_shaped_text_set_orientation, RID, Orientation); - GDVIRTUAL1RC(Orientation, _shaped_text_get_orientation, RID); + virtual void shaped_text_set_orientation(const RID &p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override; + virtual Orientation shaped_text_get_orientation(const RID &p_shaped) const override; + GDVIRTUAL2(shaped_text_set_orientation, RID, Orientation); + GDVIRTUAL1RC(Orientation, shaped_text_get_orientation, RID); - virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override; - GDVIRTUAL2(_shaped_text_set_preserve_invalid, RID, bool); - GDVIRTUAL1RC(bool, _shaped_text_get_preserve_invalid, RID); + virtual void shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_invalid(const RID &p_shaped) const override; + GDVIRTUAL2(shaped_text_set_preserve_invalid, RID, bool); + GDVIRTUAL1RC(bool, shaped_text_get_preserve_invalid, RID); - virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override; - virtual bool shaped_text_get_preserve_control(RID p_shaped) const override; - GDVIRTUAL2(_shaped_text_set_preserve_control, RID, bool); - GDVIRTUAL1RC(bool, _shaped_text_get_preserve_control, RID); + virtual void shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) override; + virtual bool shaped_text_get_preserve_control(const RID &p_shaped) const override; + GDVIRTUAL2(shaped_text_set_preserve_control, RID, bool); + GDVIRTUAL1RC(bool, shaped_text_get_preserve_control, RID); - virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; - virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int p_length = 1) override; - virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; - GDVIRTUAL7R(bool, _shaped_text_add_string, RID, const String &, const Array &, int, const Dictionary &, const String &, const Variant &); - GDVIRTUAL5R(bool, _shaped_text_add_object, RID, Variant, const Size2 &, InlineAlignment, int); - GDVIRTUAL4R(bool, _shaped_text_resize_object, RID, Variant, const Size2 &, InlineAlignment); + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override; + virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) override; + virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) override; + GDVIRTUAL7R(bool, shaped_text_add_string, RID, const String &, const Array &, int64_t, const Dictionary &, const String &, const Variant &); + GDVIRTUAL5R(bool, shaped_text_add_object, RID, const Variant &, const Size2 &, InlineAlignment, int64_t); + GDVIRTUAL4R(bool, shaped_text_resize_object, RID, const Variant &, const Size2 &, InlineAlignment); - virtual int shaped_get_span_count(RID p_shaped) const override; - virtual Variant shaped_get_span_meta(RID p_shaped, int p_index) const override; - virtual void shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary()) override; - GDVIRTUAL1RC(int, _shaped_get_span_count, RID); - GDVIRTUAL2RC(Variant, _shaped_get_span_meta, RID, int); - GDVIRTUAL5(_shaped_set_span_update_font, RID, int, const Array &, int, const Dictionary &); + virtual int64_t shaped_get_span_count(const RID &p_shaped) const override; + virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override; + GDVIRTUAL1RC(int64_t, shaped_get_span_count, RID); + GDVIRTUAL2RC(Variant, shaped_get_span_meta, RID, int64_t); + GDVIRTUAL5(shaped_set_span_update_font, RID, int64_t, const Array &, int64_t, const Dictionary &); - virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override; - virtual RID shaped_text_get_parent(RID p_shaped) const override; - GDVIRTUAL3RC(RID, _shaped_text_substr, RID, int, int); - GDVIRTUAL1RC(RID, _shaped_text_get_parent, RID); + virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override; + virtual RID shaped_text_get_parent(const RID &p_shaped) const override; + GDVIRTUAL3RC(RID, shaped_text_substr, RID, int64_t, int64_t); + GDVIRTUAL1RC(RID, shaped_text_get_parent, RID); - virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; - virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) override; - GDVIRTUAL3R(float, _shaped_text_fit_to_width, RID, float, uint16_t); - GDVIRTUAL2R(float, _shaped_text_tab_align, RID, const PackedFloat32Array &); + virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override; + virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override; + GDVIRTUAL3R(double, shaped_text_fit_to_width, RID, double, int64_t); + GDVIRTUAL2R(double, shaped_text_tab_align, RID, const PackedFloat32Array &); - virtual bool shaped_text_shape(RID p_shaped) override; - virtual bool shaped_text_update_breaks(RID p_shaped) override; - virtual bool shaped_text_update_justification_ops(RID p_shaped) override; - GDVIRTUAL1R(bool, _shaped_text_shape, RID); - GDVIRTUAL1R(bool, _shaped_text_update_breaks, RID); - GDVIRTUAL1R(bool, _shaped_text_update_justification_ops, RID); + virtual bool shaped_text_shape(const RID &p_shaped) override; + virtual bool shaped_text_update_breaks(const RID &p_shaped) override; + virtual bool shaped_text_update_justification_ops(const RID &p_shaped) override; + GDVIRTUAL1R(bool, shaped_text_shape, RID); + GDVIRTUAL1R(bool, shaped_text_update_breaks, RID); + GDVIRTUAL1R(bool, shaped_text_update_justification_ops, RID); - virtual bool shaped_text_is_ready(RID p_shaped) const override; - GDVIRTUAL1RC(bool, _shaped_text_is_ready, RID); + virtual bool shaped_text_is_ready(const RID &p_shaped) const override; + GDVIRTUAL1RC(bool, shaped_text_is_ready, RID); - virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const override; - virtual const Glyph *shaped_text_sort_logical(RID p_shaped) override; - virtual int shaped_text_get_glyph_count(RID p_shaped) const override; - GDVIRTUAL1RC(GDNativePtr, _shaped_text_get_glyphs, RID); - GDVIRTUAL1R(GDNativePtr, _shaped_text_sort_logical, RID); - GDVIRTUAL1RC(int, _shaped_text_get_glyph_count, RID); + virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) override; + virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const override; + GDVIRTUAL1RC(GDNativeConstPtr, shaped_text_get_glyphs, RID); + GDVIRTUAL1R(GDNativeConstPtr, shaped_text_sort_logical, RID); + GDVIRTUAL1RC(int64_t, shaped_text_get_glyph_count, RID); - virtual Vector2i shaped_text_get_range(RID p_shaped) const override; - GDVIRTUAL1RC(Vector2i, _shaped_text_get_range, RID); + virtual Vector2i shaped_text_get_range(const RID &p_shaped) const override; + GDVIRTUAL1RC(Vector2i, shaped_text_get_range, RID); - virtual PackedInt32Array shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start = 0, bool p_once = true, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; - virtual PackedInt32Array shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint16_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; - virtual PackedInt32Array shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override; - GDVIRTUAL5RC(PackedInt32Array, _shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int, bool, uint16_t); - GDVIRTUAL4RC(PackedInt32Array, _shaped_text_get_line_breaks, RID, float, int, uint16_t); - GDVIRTUAL2RC(PackedInt32Array, _shaped_text_get_word_breaks, RID, int); + virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; + virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, int64_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; + virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override; + GDVIRTUAL5RC(PackedInt32Array, shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int64_t, bool, int64_t); + GDVIRTUAL4RC(PackedInt32Array, shaped_text_get_line_breaks, RID, double, int64_t, int64_t); + GDVIRTUAL2RC(PackedInt32Array, shaped_text_get_word_breaks, RID, int64_t); - virtual int shaped_text_get_trim_pos(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const override; - virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const override; - virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const override; - GDVIRTUAL1RC(int, _shaped_text_get_trim_pos, RID); - GDVIRTUAL1RC(int, _shaped_text_get_ellipsis_pos, RID); - GDVIRTUAL1RC(GDNativePtr, _shaped_text_get_ellipsis_glyphs, RID); - GDVIRTUAL1RC(int, _shaped_text_get_ellipsis_glyph_count, RID); + virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const override; + virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override; + virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override; + GDVIRTUAL1RC(int64_t, shaped_text_get_trim_pos, RID); + GDVIRTUAL1RC(int64_t, shaped_text_get_ellipsis_pos, RID); + GDVIRTUAL1RC(GDNativeConstPtr, shaped_text_get_ellipsis_glyphs, RID); + GDVIRTUAL1RC(int64_t, shaped_text_get_ellipsis_glyph_count, RID); - virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) override; - GDVIRTUAL3(_shaped_text_overrun_trim_to_width, RID, float, uint16_t); + virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) override; + GDVIRTUAL3(shaped_text_overrun_trim_to_width, RID, double, int64_t); - virtual Array shaped_text_get_objects(RID p_shaped) const override; - virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override; - GDVIRTUAL1RC(Array, _shaped_text_get_objects, RID); - GDVIRTUAL2RC(Rect2, _shaped_text_get_object_rect, RID, Variant); + virtual Array shaped_text_get_objects(const RID &p_shaped) const override; + virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const override; + GDVIRTUAL1RC(Array, shaped_text_get_objects, RID); + GDVIRTUAL2RC(Rect2, shaped_text_get_object_rect, RID, const Variant &); - virtual Size2 shaped_text_get_size(RID p_shaped) const override; - virtual float shaped_text_get_ascent(RID p_shaped) const override; - virtual float shaped_text_get_descent(RID p_shaped) const override; - virtual float shaped_text_get_width(RID p_shaped) const override; - virtual float shaped_text_get_underline_position(RID p_shaped) const override; - virtual float shaped_text_get_underline_thickness(RID p_shaped) const override; - GDVIRTUAL1RC(Size2, _shaped_text_get_size, RID); - GDVIRTUAL1RC(float, _shaped_text_get_ascent, RID); - GDVIRTUAL1RC(float, _shaped_text_get_descent, RID); - GDVIRTUAL1RC(float, _shaped_text_get_width, RID); - GDVIRTUAL1RC(float, _shaped_text_get_underline_position, RID); - GDVIRTUAL1RC(float, _shaped_text_get_underline_thickness, RID); + virtual Size2 shaped_text_get_size(const RID &p_shaped) const override; + virtual double shaped_text_get_ascent(const RID &p_shaped) const override; + virtual double shaped_text_get_descent(const RID &p_shaped) const override; + virtual double shaped_text_get_width(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_position(const RID &p_shaped) const override; + virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const override; + GDVIRTUAL1RC(Size2, shaped_text_get_size, RID); + GDVIRTUAL1RC(double, shaped_text_get_ascent, RID); + GDVIRTUAL1RC(double, shaped_text_get_descent, RID); + GDVIRTUAL1RC(double, shaped_text_get_width, RID); + GDVIRTUAL1RC(double, shaped_text_get_underline_position, RID); + GDVIRTUAL1RC(double, shaped_text_get_underline_thickness, RID); - virtual Direction shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const override; - GDVIRTUAL3RC(int, _shaped_text_get_dominant_direction_in_range, RID, int, int); + virtual Direction shaped_text_get_dominant_direction_in_range(const RID &p_shaped, int64_t p_start, int64_t p_end) const override; + GDVIRTUAL3RC(int64_t, shaped_text_get_dominant_direction_in_range, RID, int64_t, int64_t); - virtual CaretInfo shaped_text_get_carets(RID p_shaped, int p_position) const override; - virtual Vector shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const override; - GDVIRTUAL3C(_shaped_text_get_carets, RID, int, GDNativePtr); - GDVIRTUAL3RC(Vector, _shaped_text_get_selection, RID, int, int); + virtual CaretInfo shaped_text_get_carets(const RID &p_shaped, int64_t p_position) const override; + virtual Vector shaped_text_get_selection(const RID &p_shaped, int64_t p_start, int64_t p_end) const override; + GDVIRTUAL3C(shaped_text_get_carets, RID, int64_t, GDNativePtr); + GDVIRTUAL3RC(Vector, shaped_text_get_selection, RID, int64_t, int64_t); - virtual int shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const override; - virtual int shaped_text_hit_test_position(RID p_shaped, float p_coords) const override; - GDVIRTUAL2RC(int, _shaped_text_hit_test_grapheme, RID, float); - GDVIRTUAL2RC(int, _shaped_text_hit_test_position, RID, float); + virtual int64_t shaped_text_hit_test_grapheme(const RID &p_shaped, double p_coords) const override; + virtual int64_t shaped_text_hit_test_position(const RID &p_shaped, double p_coords) const override; + GDVIRTUAL2RC(int64_t, shaped_text_hit_test_grapheme, RID, double); + GDVIRTUAL2RC(int64_t, shaped_text_hit_test_position, RID, double); - virtual void shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, const Color &p_color = Color(1, 1, 1)) const override; - virtual void shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const override; - GDVIRTUAL6C(_shaped_text_draw, RID, RID, const Vector2 &, float, float, const Color &); - GDVIRTUAL7C(_shaped_text_draw_outline, RID, RID, const Vector2 &, float, float, int, const Color &); + virtual void shaped_text_draw(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, const Color &p_color = Color(1, 1, 1)) const override; + virtual void shaped_text_draw_outline(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, int64_t p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const override; + GDVIRTUAL6C(shaped_text_draw, RID, RID, const Vector2 &, double, double, const Color &); + GDVIRTUAL7C(shaped_text_draw_outline, RID, RID, const Vector2 &, double, double, int64_t, const Color &); - virtual Vector2 shaped_text_get_grapheme_bounds(RID p_shaped, int p_pos) const override; - virtual int shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const override; - virtual int shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const override; - GDVIRTUAL2RC(Vector2, _shaped_text_get_grapheme_bounds, RID, int); - GDVIRTUAL2RC(int, _shaped_text_next_grapheme_pos, RID, int); - GDVIRTUAL2RC(int, _shaped_text_prev_grapheme_pos, RID, int); + virtual Vector2 shaped_text_get_grapheme_bounds(const RID &p_shaped, int64_t p_pos) const override; + virtual int64_t shaped_text_next_grapheme_pos(const RID &p_shaped, int64_t p_pos) const override; + virtual int64_t shaped_text_prev_grapheme_pos(const RID &p_shaped, int64_t p_pos) const override; + GDVIRTUAL2RC(Vector2, shaped_text_get_grapheme_bounds, RID, int64_t); + GDVIRTUAL2RC(int64_t, shaped_text_next_grapheme_pos, RID, int64_t); + GDVIRTUAL2RC(int64_t, shaped_text_prev_grapheme_pos, RID, int64_t); virtual String format_number(const String &p_string, const String &p_language = "") const override; virtual String parse_number(const String &p_string, const String &p_language = "") const override; virtual String percent_sign(const String &p_language = "") const override; - GDVIRTUAL2RC(String, _format_number, const String &, const String &); - GDVIRTUAL2RC(String, _parse_number, const String &, const String &); - GDVIRTUAL1RC(String, _percent_sign, const String &); + GDVIRTUAL2RC(String, format_number, const String &, const String &); + GDVIRTUAL2RC(String, parse_number, const String &, const String &); + GDVIRTUAL1RC(String, percent_sign, const String &); + + virtual String strip_diacritics(const String &p_string) const override; + GDVIRTUAL1RC(String, strip_diacritics, const String &); virtual String string_to_upper(const String &p_string, const String &p_language = "") const override; virtual String string_to_lower(const String &p_string, const String &p_language = "") const override; - GDVIRTUAL2RC(String, _string_to_upper, const String &, const String &); - GDVIRTUAL2RC(String, _string_to_lower, const String &, const String &); + GDVIRTUAL2RC(String, string_to_upper, const String &, const String &); + GDVIRTUAL2RC(String, string_to_lower, const String &, const String &); TextServerExtension(); ~TextServerExtension(); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index aaba79c0496..ec31885cae0 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -200,7 +200,7 @@ void TextServer::_bind_methods() { ClassDB::bind_method(D_METHOD("tag_to_name", "tag"), &TextServer::tag_to_name); ClassDB::bind_method(D_METHOD("has", "rid"), &TextServer::has); - ClassDB::bind_method(D_METHOD("free_rid", "rid"), &TextServer::free); // shouldn't conflict with Object::free() + ClassDB::bind_method(D_METHOD("free_rid", "rid"), &TextServer::free_rid); /* Font Interface */ @@ -493,13 +493,19 @@ void TextServer::_bind_methods() { BIND_ENUM_CONSTANT(SUBPIXEL_POSITIONING_AUTO); BIND_ENUM_CONSTANT(SUBPIXEL_POSITIONING_ONE_HALF); BIND_ENUM_CONSTANT(SUBPIXEL_POSITIONING_ONE_QUARTER); + BIND_ENUM_CONSTANT(SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE); + BIND_ENUM_CONSTANT(SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE); /* Feature */ + BIND_ENUM_CONSTANT(FEATURE_SIMPLE_LAYOUT); BIND_ENUM_CONSTANT(FEATURE_BIDI_LAYOUT); BIND_ENUM_CONSTANT(FEATURE_VERTICAL_LAYOUT); BIND_ENUM_CONSTANT(FEATURE_SHAPING); BIND_ENUM_CONSTANT(FEATURE_KASHIDA_JUSTIFICATION); BIND_ENUM_CONSTANT(FEATURE_BREAK_ITERATORS); + BIND_ENUM_CONSTANT(FEATURE_FONT_BITMAP); + BIND_ENUM_CONSTANT(FEATURE_FONT_DYNAMIC); + BIND_ENUM_CONSTANT(FEATURE_FONT_MSDF); BIND_ENUM_CONSTANT(FEATURE_FONT_SYSTEM); BIND_ENUM_CONSTANT(FEATURE_FONT_VARIABLE); BIND_ENUM_CONSTANT(FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION); @@ -522,7 +528,7 @@ void TextServer::_bind_methods() { BIND_ENUM_CONSTANT(FONT_FIXED_WIDTH); } -Vector2 TextServer::get_hex_code_box_size(int p_size, char32_t p_index) const { +Vector2 TextServer::get_hex_code_box_size(int64_t p_size, int64_t p_index) const { int w = ((p_index <= 0xFF) ? 1 : ((p_index <= 0xFFFF) ? 2 : 3)); int sp = MAX(0, w - 1); int sz = MAX(1, Math::round(p_size / 15.f)); @@ -530,7 +536,7 @@ Vector2 TextServer::get_hex_code_box_size(int p_size, char32_t p_index) const { return Vector2(4 + 3 * w + sp + 1, 15) * sz; } -void TextServer::_draw_hex_code_box_number(RID p_canvas, int p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const { +void TextServer::_draw_hex_code_box_number(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const { static uint8_t chars[] = { 0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B, 0x77, 0x1F, 0x4E, 0x3D, 0x4F, 0x47, 0x00 }; uint8_t x = chars[p_index]; if (x & (1 << 6)) { @@ -556,7 +562,7 @@ void TextServer::_draw_hex_code_box_number(RID p_canvas, int p_size, const Vecto } } -void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const { +void TextServer::draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { if (p_index == 0) { return; } @@ -600,7 +606,7 @@ void TextServer::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_po } } -PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint16_t /*TextBreakFlag*/ p_break_flags) const { +PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start, bool p_once, int64_t /*TextBreakFlag*/ p_break_flags) const { PackedInt32Array lines; ERR_FAIL_COND_V(p_width.is_empty(), lines); @@ -676,13 +682,13 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const return lines; } -PackedInt32Array TextServer::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint16_t /*TextBreakFlag*/ p_break_flags) const { +PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start, int64_t /*TextBreakFlag*/ p_break_flags) const { PackedInt32Array lines; const_cast(this)->shaped_text_update_breaks(p_shaped); const Vector2i &range = shaped_text_get_range(p_shaped); - float width = 0.f; + double width = 0.f; int line_start = MAX(p_start, range.x); int last_safe_break = -1; int word_count = 0; @@ -744,7 +750,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(RID p_shaped, float p_w return lines; } -PackedInt32Array TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { +PackedInt32Array TextServer::shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags) const { PackedInt32Array words; const_cast(this)->shaped_text_update_justification_ops(p_shaped); @@ -776,7 +782,7 @@ PackedInt32Array TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_gra return words; } -CaretInfo TextServer::shaped_text_get_carets(RID p_shaped, int p_position) const { +CaretInfo TextServer::shaped_text_get_carets(const RID &p_shaped, int64_t p_position) const { Vector carets; TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped); @@ -926,7 +932,7 @@ CaretInfo TextServer::shaped_text_get_carets(RID p_shaped, int p_position) const return caret; } -Dictionary TextServer::_shaped_text_get_carets_wrapper(RID p_shaped, int p_position) const { +Dictionary TextServer::_shaped_text_get_carets_wrapper(const RID &p_shaped, int64_t p_position) const { Dictionary ret; CaretInfo caret = shaped_text_get_carets(p_shaped, p_position); @@ -939,7 +945,7 @@ Dictionary TextServer::_shaped_text_get_carets_wrapper(RID p_shaped, int p_posit return ret; } -TextServer::Direction TextServer::shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const { +TextServer::Direction TextServer::shaped_text_get_dominant_direction_in_range(const RID &p_shaped, int64_t p_start, int64_t p_end) const { if (p_start == p_end) { return DIRECTION_AUTO; } @@ -973,7 +979,7 @@ TextServer::Direction TextServer::shaped_text_get_dominant_direction_in_range(RI } } -Vector TextServer::shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const { +Vector TextServer::shaped_text_get_selection(const RID &p_shaped, int64_t p_start, int64_t p_end) const { Vector ranges; if (p_start == p_end) { @@ -1066,9 +1072,9 @@ Vector TextServer::shaped_text_get_selection(RID p_shaped, int p_start, return ranges; } -int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const { +int64_t TextServer::shaped_text_hit_test_grapheme(const RID &p_shaped, double p_coords) const { // Exact grapheme hit test, return -1 if missed. - float off = 0.0f; + double off = 0.0f; int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1084,7 +1090,7 @@ int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) cons return -1; } -int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) const { +int64_t TextServer::shaped_text_hit_test_position(const RID &p_shaped, double p_coords) const { int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1177,7 +1183,7 @@ int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) cons return 0; } -Vector2 TextServer::shaped_text_get_grapheme_bounds(RID p_shaped, int p_pos) const { +Vector2 TextServer::shaped_text_get_grapheme_bounds(const RID &p_shaped, int64_t p_pos) const { int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1198,7 +1204,7 @@ Vector2 TextServer::shaped_text_get_grapheme_bounds(RID p_shaped, int p_pos) con return Vector2(); } -int TextServer::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const { +int64_t TextServer::shaped_text_next_grapheme_pos(const RID &p_shaped, int64_t p_pos) const { int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); for (int i = 0; i < v_size; i++) { @@ -1209,7 +1215,7 @@ int TextServer::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const { return p_pos; } -int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const { +int64_t TextServer::shaped_text_prev_grapheme_pos(const RID &p_shaped, int64_t p_pos) const { int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); for (int i = 0; i < v_size; i++) { @@ -1221,7 +1227,7 @@ int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const { return p_pos; } -void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, const Color &p_color) const { +void TextServer::shaped_text_draw(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l, double p_clip_r, const Color &p_color) const { TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped); bool hex_codes = shaped_text_get_preserve_control(p_shaped) || shaped_text_get_preserve_invalid(p_shaped); @@ -1318,7 +1324,7 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p } } -void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, int p_outline_size, const Color &p_color) const { +void TextServer::shaped_text_draw_outline(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l, double p_clip_r, int64_t p_outline_size, const Color &p_color) const { TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped); bool rtl = (shaped_text_get_inferred_direction(p_shaped) == DIRECTION_RTL); @@ -1538,7 +1544,7 @@ String TextServer::strip_diacritics(const String &p_string) const { return result; } -Array TextServer::_shaped_text_get_glyphs_wrapper(RID p_shaped) const { +Array TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const { Array ret; const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1563,7 +1569,7 @@ Array TextServer::_shaped_text_get_glyphs_wrapper(RID p_shaped) const { return ret; } -Array TextServer::_shaped_text_sort_logical_wrapper(RID p_shaped) { +Array TextServer::_shaped_text_sort_logical_wrapper(const RID &p_shaped) { Array ret; const Glyph *glyphs = shaped_text_sort_logical(p_shaped); @@ -1588,7 +1594,7 @@ Array TextServer::_shaped_text_sort_logical_wrapper(RID p_shaped) { return ret; } -Array TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(RID p_shaped) const { +Array TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const { Array ret; const Glyph *glyphs = shaped_text_get_ellipsis_glyphs(p_shaped); diff --git a/servers/text_server.h b/servers/text_server.h index 83dc3df56de..365b7ff6633 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -102,25 +102,29 @@ public: }; enum SubpixelPositioning { - SUBPIXEL_POSITIONING_DISABLED, - SUBPIXEL_POSITIONING_AUTO, - SUBPIXEL_POSITIONING_ONE_HALF, - SUBPIXEL_POSITIONING_ONE_QUARTER, + SUBPIXEL_POSITIONING_DISABLED = 0, + SUBPIXEL_POSITIONING_AUTO = 1, + SUBPIXEL_POSITIONING_ONE_HALF = 2, + SUBPIXEL_POSITIONING_ONE_QUARTER = 3, + + SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE = 20, + SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE = 16, }; - const int SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE = 20; - const int SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE = 16; - enum Feature { - FEATURE_BIDI_LAYOUT = 1 << 0, - FEATURE_VERTICAL_LAYOUT = 1 << 1, - FEATURE_SHAPING = 1 << 2, - FEATURE_KASHIDA_JUSTIFICATION = 1 << 3, - FEATURE_BREAK_ITERATORS = 1 << 4, - FEATURE_FONT_SYSTEM = 1 << 5, - FEATURE_FONT_VARIABLE = 1 << 6, - FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION = 1 << 7, - FEATURE_USE_SUPPORT_DATA = 1 << 8, + FEATURE_SIMPLE_LAYOUT = 1 << 0, + FEATURE_BIDI_LAYOUT = 1 << 1, + FEATURE_VERTICAL_LAYOUT = 1 << 2, + FEATURE_SHAPING = 1 << 3, + FEATURE_KASHIDA_JUSTIFICATION = 1 << 4, + FEATURE_BREAK_ITERATORS = 1 << 5, + FEATURE_FONT_BITMAP = 1 << 6, + FEATURE_FONT_DYNAMIC = 1 << 7, + FEATURE_FONT_MSDF = 1 << 8, + FEATURE_FONT_SYSTEM = 1 << 9, + FEATURE_FONT_VARIABLE = 1 << 10, + FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION = 1 << 11, + FEATURE_USE_SUPPORT_DATA = 1 << 12, }; enum ContourPointTag { @@ -142,62 +146,9 @@ public: FONT_FIXED_WIDTH = 1 << 2, }; - void _draw_hex_code_box_number(RID p_canvas, int p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const; + void _draw_hex_code_box_number(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const; protected: - struct TrimData { - int trim_pos = -1; - int ellipsis_pos = -1; - Vector ellipsis_glyph_buf; - }; - - struct ShapedTextData { - Mutex mutex; - - /* Source data */ - RID parent; // Substring parent ShapedTextData. - - int start = 0; // Substring start offset in the parent string. - int end = 0; // Substring end offset in the parent string. - - String text; - String custom_punct; - TextServer::Direction direction = DIRECTION_LTR; // Desired text direction. - TextServer::Orientation orientation = ORIENTATION_HORIZONTAL; - - struct EmbeddedObject { - int pos = 0; - InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER; - Rect2 rect; - }; - Map objects; - - /* Shaped data */ - TextServer::Direction para_direction = DIRECTION_LTR; // Detected text direction. - bool valid = false; // String is shaped. - bool line_breaks_valid = false; // Line and word break flags are populated (and virtual zero width spaces inserted). - bool justification_ops_valid = false; // Virtual elongation glyphs are added to the string. - bool sort_valid = false; - bool text_trimmed = false; - - bool preserve_invalid = true; // Draw hex code box instead of missing characters. - bool preserve_control = false; // Draw control characters. - - float ascent = 0.f; // Ascent for horizontal layout, 1/2 of width for vertical. - float descent = 0.f; // Descent for horizontal layout, 1/2 of width for vertical. - float width = 0.f; // Width for horizontal layout, height for vertical. - float width_trimmed = 0.f; - - float upos = 0.f; - float uthk = 0.f; - - TrimData overrun_trim_data; - bool fit_width_minimum_reached = false; - - Vector glyphs; - Vector glyphs_logical; - }; - Map diacritics_map; void _diacritics_map_add(const String &p_from, char32_t p_to); void _init_diacritics_map(); @@ -207,10 +158,10 @@ protected: public: virtual bool has_feature(Feature p_feature) const = 0; virtual String get_name() const = 0; - virtual uint32_t get_features() const = 0; + virtual int64_t get_features() const = 0; - virtual void free(RID p_rid) = 0; - virtual bool has(RID p_rid) = 0; + virtual void free_rid(const RID &p_rid) = 0; + virtual bool has(const RID &p_rid) = 0; virtual bool load_support_data(const String &p_filename) = 0; virtual String get_support_data_filename() const = 0; @@ -219,251 +170,251 @@ public: virtual bool is_locale_right_to_left(const String &p_locale) const = 0; - virtual int32_t name_to_tag(const String &p_name) const { return 0; }; - virtual String tag_to_name(int32_t p_tag) const { return ""; }; + virtual int64_t name_to_tag(const String &p_name) const { return 0; }; + virtual String tag_to_name(int64_t p_tag) const { return ""; }; /* Font interface */ virtual RID create_font() = 0; - virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) = 0; - virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) = 0; + virtual void font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) = 0; + virtual void font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) = 0; - virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) = 0; - virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const = 0; + virtual void font_set_style(const RID &p_font_rid, int64_t /*FontStyle*/ p_style) = 0; + virtual int64_t /*FontStyle*/ font_get_style(const RID &p_font_rid) const = 0; - virtual void font_set_name(RID p_font_rid, const String &p_name) = 0; - virtual String font_get_name(RID p_font_rid) const = 0; + virtual void font_set_name(const RID &p_font_rid, const String &p_name) = 0; + virtual String font_get_name(const RID &p_font_rid) const = 0; - virtual void font_set_style_name(RID p_font_rid, const String &p_name) = 0; - virtual String font_get_style_name(RID p_font_rid) const = 0; + virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) = 0; + virtual String font_get_style_name(const RID &p_font_rid) const = 0; - virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) = 0; - virtual bool font_is_antialiased(RID p_font_rid) const = 0; + virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) = 0; + virtual bool font_is_antialiased(const RID &p_font_rid) const = 0; - virtual void font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) = 0; - virtual bool font_is_multichannel_signed_distance_field(RID p_font_rid) const = 0; + virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) = 0; + virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const = 0; - virtual void font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) = 0; - virtual int font_get_msdf_pixel_range(RID p_font_rid) const = 0; + virtual void font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) = 0; + virtual int64_t font_get_msdf_pixel_range(const RID &p_font_rid) const = 0; - virtual void font_set_msdf_size(RID p_font_rid, int p_msdf_size) = 0; - virtual int font_get_msdf_size(RID p_font_rid) const = 0; + virtual void font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) = 0; + virtual int64_t font_get_msdf_size(const RID &p_font_rid) const = 0; - virtual void font_set_fixed_size(RID p_font_rid, int p_fixed_size) = 0; - virtual int font_get_fixed_size(RID p_font_rid) const = 0; + virtual void font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) = 0; + virtual int64_t font_get_fixed_size(const RID &p_font_rid) const = 0; - virtual void font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) = 0; - virtual bool font_is_force_autohinter(RID p_font_rid) const = 0; + virtual void font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) = 0; + virtual bool font_is_force_autohinter(const RID &p_font_rid) const = 0; - virtual void font_set_hinting(RID p_font_rid, Hinting p_hinting) = 0; - virtual Hinting font_get_hinting(RID p_font_rid) const = 0; + virtual void font_set_hinting(const RID &p_font_rid, Hinting p_hinting) = 0; + virtual Hinting font_get_hinting(const RID &p_font_rid) const = 0; - virtual void font_set_subpixel_positioning(RID p_font_rid, SubpixelPositioning p_subpixel) = 0; - virtual SubpixelPositioning font_get_subpixel_positioning(RID p_font_rid) const = 0; + virtual void font_set_subpixel_positioning(const RID &p_font_rid, SubpixelPositioning p_subpixel) = 0; + virtual SubpixelPositioning font_get_subpixel_positioning(const RID &p_font_rid) const = 0; - virtual void font_set_embolden(RID p_font_rid, float p_strength) = 0; - virtual float font_get_embolden(RID p_font_rid) const = 0; + virtual void font_set_embolden(const RID &p_font_rid, double p_strength) = 0; + virtual double font_get_embolden(const RID &p_font_rid) const = 0; - virtual void font_set_transform(RID p_font_rid, Transform2D p_transform) = 0; - virtual Transform2D font_get_transform(RID p_font_rid) const = 0; + virtual void font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) = 0; + virtual Transform2D font_get_transform(const RID &p_font_rid) const = 0; - virtual void font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) = 0; - virtual Dictionary font_get_variation_coordinates(RID p_font_rid) const = 0; + virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) = 0; + virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const = 0; - virtual void font_set_oversampling(RID p_font_rid, float p_oversampling) = 0; - virtual float font_get_oversampling(RID p_font_rid) const = 0; + virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) = 0; + virtual double font_get_oversampling(const RID &p_font_rid) const = 0; - virtual Array font_get_size_cache_list(RID p_font_rid) const = 0; - virtual void font_clear_size_cache(RID p_font_rid) = 0; - virtual void font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) = 0; + virtual Array font_get_size_cache_list(const RID &p_font_rid) const = 0; + virtual void font_clear_size_cache(const RID &p_font_rid) = 0; + virtual void font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) = 0; - virtual void font_set_ascent(RID p_font_rid, int p_size, float p_ascent) = 0; - virtual float font_get_ascent(RID p_font_rid, int p_size) const = 0; + virtual void font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) = 0; + virtual double font_get_ascent(const RID &p_font_rid, int64_t p_size) const = 0; - virtual void font_set_descent(RID p_font_rid, int p_size, float p_descent) = 0; - virtual float font_get_descent(RID p_font_rid, int p_size) const = 0; + virtual void font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) = 0; + virtual double font_get_descent(const RID &p_font_rid, int64_t p_size) const = 0; - virtual void font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) = 0; - virtual float font_get_underline_position(RID p_font_rid, int p_size) const = 0; + virtual void font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) = 0; + virtual double font_get_underline_position(const RID &p_font_rid, int64_t p_size) const = 0; - virtual void font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) = 0; - virtual float font_get_underline_thickness(RID p_font_rid, int p_size) const = 0; + virtual void font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) = 0; + virtual double font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const = 0; - virtual void font_set_scale(RID p_font_rid, int p_size, float p_scale) = 0; - virtual float font_get_scale(RID p_font_rid, int p_size) const = 0; + virtual void font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) = 0; + virtual double font_get_scale(const RID &p_font_rid, int64_t p_size) const = 0; - virtual void font_set_spacing(RID p_font_rid, int p_size, SpacingType p_spacing, int p_value) = 0; - virtual int font_get_spacing(RID p_font_rid, int p_size, SpacingType p_spacing) const = 0; + virtual void font_set_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing, int64_t p_value) = 0; + virtual int64_t font_get_spacing(const RID &p_font_rid, int64_t p_size, SpacingType p_spacing) const = 0; - virtual int font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const = 0; - virtual void font_clear_textures(RID p_font_rid, const Vector2i &p_size) = 0; - virtual void font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) = 0; + virtual int64_t font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const = 0; + virtual void font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) = 0; + virtual void font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) = 0; - virtual void font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref &p_image) = 0; - virtual Ref font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const = 0; + virtual void font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref &p_image) = 0; + virtual Ref font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const = 0; - virtual void font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) = 0; - virtual PackedInt32Array font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const = 0; + virtual void font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) = 0; + virtual PackedInt32Array font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const = 0; - virtual Array font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const = 0; - virtual void font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) = 0; - virtual void font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) = 0; + virtual Array font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const = 0; + virtual void font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) = 0; + virtual void font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) = 0; - virtual Vector2 font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const = 0; - virtual void font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) = 0; + virtual Vector2 font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const = 0; + virtual void font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) = 0; - virtual Vector2 font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const = 0; - virtual void font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) = 0; + virtual Vector2 font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0; + virtual void font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) = 0; - virtual Vector2 font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const = 0; - virtual void font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) = 0; + virtual Vector2 font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0; + virtual void font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) = 0; - virtual Rect2 font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const = 0; - virtual void font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) = 0; + virtual Rect2 font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0; + virtual void font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) = 0; - virtual int font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const = 0; - virtual void font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) = 0; + virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0; + virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) = 0; - virtual Dictionary font_get_glyph_contours(RID p_font, int p_size, int32_t p_index) const = 0; + virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const = 0; - virtual Array font_get_kerning_list(RID p_font_rid, int p_size) const = 0; - virtual void font_clear_kerning_map(RID p_font_rid, int p_size) = 0; - virtual void font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) = 0; + virtual Array font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const = 0; + virtual void font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) = 0; + virtual void font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) = 0; - virtual void font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) = 0; - virtual Vector2 font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const = 0; + virtual void font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) = 0; + virtual Vector2 font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const = 0; - virtual int32_t font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const = 0; + virtual int64_t font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const = 0; - virtual bool font_has_char(RID p_font_rid, char32_t p_char) const = 0; - virtual String font_get_supported_chars(RID p_font_rid) const = 0; + virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const = 0; + virtual String font_get_supported_chars(const RID &p_font_rid) const = 0; - virtual void font_render_range(RID p_font, const Vector2i &p_size, char32_t p_start, char32_t p_end) = 0; - virtual void font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) = 0; + virtual void font_render_range(const RID &p_font, const Vector2i &p_size, int64_t p_start, int64_t p_end) = 0; + virtual void font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) = 0; - virtual void font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const = 0; - virtual void font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color = Color(1, 1, 1)) const = 0; + virtual void font_draw_glyph(const RID &p_font, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const = 0; + virtual void font_draw_glyph_outline(const RID &p_font, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const = 0; - virtual bool font_is_language_supported(RID p_font_rid, const String &p_language) const = 0; - virtual void font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) = 0; - virtual bool font_get_language_support_override(RID p_font_rid, const String &p_language) = 0; - virtual void font_remove_language_support_override(RID p_font_rid, const String &p_language) = 0; - virtual Vector font_get_language_support_overrides(RID p_font_rid) = 0; + virtual bool font_is_language_supported(const RID &p_font_rid, const String &p_language) const = 0; + virtual void font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) = 0; + virtual bool font_get_language_support_override(const RID &p_font_rid, const String &p_language) = 0; + virtual void font_remove_language_support_override(const RID &p_font_rid, const String &p_language) = 0; + virtual PackedStringArray font_get_language_support_overrides(const RID &p_font_rid) = 0; - virtual bool font_is_script_supported(RID p_font_rid, const String &p_script) const = 0; - virtual void font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) = 0; - virtual bool font_get_script_support_override(RID p_font_rid, const String &p_script) = 0; - virtual void font_remove_script_support_override(RID p_font_rid, const String &p_script) = 0; - virtual Vector font_get_script_support_overrides(RID p_font_rid) = 0; + virtual bool font_is_script_supported(const RID &p_font_rid, const String &p_script) const = 0; + virtual void font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) = 0; + virtual bool font_get_script_support_override(const RID &p_font_rid, const String &p_script) = 0; + virtual void font_remove_script_support_override(const RID &p_font_rid, const String &p_script) = 0; + virtual PackedStringArray font_get_script_support_overrides(const 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 void font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) = 0; + virtual Dictionary font_get_opentype_feature_overrides(const 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; + virtual Dictionary font_supported_feature_list(const RID &p_font_rid) const = 0; + virtual Dictionary font_supported_variation_list(const RID &p_font_rid) const = 0; - virtual float font_get_global_oversampling() const = 0; - virtual void font_set_global_oversampling(float p_oversampling) = 0; + virtual double font_get_global_oversampling() const = 0; + virtual void font_set_global_oversampling(double p_oversampling) = 0; - virtual Vector2 get_hex_code_box_size(int p_size, char32_t p_index) const; - virtual void draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const; + virtual Vector2 get_hex_code_box_size(int64_t p_size, int64_t p_index) const; + virtual void draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const; /* Shaped text buffer interface */ virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0; - virtual void shaped_text_clear(RID p_shaped) = 0; + virtual void shaped_text_clear(const RID &p_shaped) = 0; - virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) = 0; - virtual Direction shaped_text_get_direction(RID p_shaped) const = 0; - virtual Direction shaped_text_get_inferred_direction(RID p_shaped) const = 0; + virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) = 0; + virtual Direction shaped_text_get_direction(const RID &p_shaped) const = 0; + virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const = 0; - virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) = 0; + virtual void shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) = 0; - virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) = 0; - virtual String shaped_text_get_custom_punctuation(RID p_shaped) const = 0; + virtual void shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) = 0; + virtual String shaped_text_get_custom_punctuation(const RID &p_shaped) const = 0; - virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0; - virtual Orientation shaped_text_get_orientation(RID p_shaped) const = 0; + virtual void shaped_text_set_orientation(const RID &p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0; + virtual Orientation shaped_text_get_orientation(const RID &p_shaped) const = 0; - virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) = 0; - virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const = 0; + virtual void shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) = 0; + virtual bool shaped_text_get_preserve_invalid(const RID &p_shaped) const = 0; - virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) = 0; - virtual bool shaped_text_get_preserve_control(RID p_shaped) const = 0; + virtual void shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) = 0; + virtual bool shaped_text_get_preserve_control(const RID &p_shaped) const = 0; - virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) = 0; - virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int p_length = 1) = 0; - virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) = 0; + virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) = 0; + virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1) = 0; + virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER) = 0; - virtual int shaped_get_span_count(RID p_shaped) const = 0; - virtual Variant shaped_get_span_meta(RID p_shaped, int p_index) const = 0; - virtual void shaped_set_span_update_font(RID p_shaped, int p_index, const Vector &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary()) = 0; + virtual int64_t shaped_get_span_count(const RID &p_shaped) const = 0; + virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const = 0; + virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const Array &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) = 0; - virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const = 0; // Copy shaped substring (e.g. line break) without reshaping, but correctly reordered, preservers range. - virtual RID shaped_text_get_parent(RID p_shaped) const = 0; + virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const = 0; // Copy shaped substring (e.g. line break) without reshaping, but correctly reordered, preservers range. + virtual RID shaped_text_get_parent(const RID &p_shaped) const = 0; - virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0; - virtual float shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) = 0; + virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, int64_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) = 0; + virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) = 0; - virtual bool shaped_text_shape(RID p_shaped) = 0; - virtual bool shaped_text_update_breaks(RID p_shaped) = 0; - virtual bool shaped_text_update_justification_ops(RID p_shaped) = 0; + virtual bool shaped_text_shape(const RID &p_shaped) = 0; + virtual bool shaped_text_update_breaks(const RID &p_shaped) = 0; + virtual bool shaped_text_update_justification_ops(const RID &p_shaped) = 0; - virtual bool shaped_text_is_ready(RID p_shaped) const = 0; + virtual bool shaped_text_is_ready(const RID &p_shaped) const = 0; - virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const = 0; - Array _shaped_text_get_glyphs_wrapper(RID p_shaped) const; - virtual const Glyph *shaped_text_sort_logical(RID p_shaped) = 0; - Array _shaped_text_sort_logical_wrapper(RID p_shaped); - virtual int shaped_text_get_glyph_count(RID p_shaped) const = 0; + virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const = 0; + Array _shaped_text_get_glyphs_wrapper(const RID &p_shaped) const; + virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) = 0; + Array _shaped_text_sort_logical_wrapper(const RID &p_shaped); + virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const = 0; - virtual Vector2i shaped_text_get_range(RID p_shaped) const = 0; + virtual Vector2i shaped_text_get_range(const RID &p_shaped) const = 0; - virtual PackedInt32Array shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start = 0, bool p_once = true, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; - virtual PackedInt32Array shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint16_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; - virtual PackedInt32Array shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const; + virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; + virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, int64_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; + virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, int64_t p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const; - virtual int shaped_text_get_trim_pos(RID p_shaped) const = 0; - virtual int shaped_text_get_ellipsis_pos(RID p_shaped) const = 0; - virtual const Glyph *shaped_text_get_ellipsis_glyphs(RID p_shaped) const = 0; - Array _shaped_text_get_ellipsis_glyphs_wrapper(RID p_shaped) const; - virtual int shaped_text_get_ellipsis_glyph_count(RID p_shaped) const = 0; + virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const = 0; + virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const = 0; + virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const = 0; + Array _shaped_text_get_ellipsis_glyphs_wrapper(const RID &p_shaped) const; + virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const = 0; - virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint16_t p_trim_flags) = 0; + virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, int64_t p_trim_flags) = 0; - virtual Array shaped_text_get_objects(RID p_shaped) const = 0; - virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const = 0; + virtual Array shaped_text_get_objects(const RID &p_shaped) const = 0; + virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const = 0; - virtual Size2 shaped_text_get_size(RID p_shaped) const = 0; - virtual float shaped_text_get_ascent(RID p_shaped) const = 0; - virtual float shaped_text_get_descent(RID p_shaped) const = 0; - virtual float shaped_text_get_width(RID p_shaped) const = 0; - virtual float shaped_text_get_underline_position(RID p_shaped) const = 0; - virtual float shaped_text_get_underline_thickness(RID p_shaped) const = 0; + virtual Size2 shaped_text_get_size(const RID &p_shaped) const = 0; + virtual double shaped_text_get_ascent(const RID &p_shaped) const = 0; + virtual double shaped_text_get_descent(const RID &p_shaped) const = 0; + virtual double shaped_text_get_width(const RID &p_shaped) const = 0; + virtual double shaped_text_get_underline_position(const RID &p_shaped) const = 0; + virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const = 0; - virtual Direction shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const; + virtual Direction shaped_text_get_dominant_direction_in_range(const RID &p_shaped, int64_t p_start, int64_t p_end) const; - virtual CaretInfo shaped_text_get_carets(RID p_shaped, int p_position) const; - Dictionary _shaped_text_get_carets_wrapper(RID p_shaped, int p_position) const; + virtual CaretInfo shaped_text_get_carets(const RID &p_shaped, int64_t p_position) const; + Dictionary _shaped_text_get_carets_wrapper(const RID &p_shaped, int64_t p_position) const; - virtual Vector shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const; + virtual Vector shaped_text_get_selection(const RID &p_shaped, int64_t p_start, int64_t p_end) const; - virtual int shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const; // Return grapheme index. - virtual int shaped_text_hit_test_position(RID p_shaped, float p_coords) const; // Return caret/selection position. + virtual int64_t shaped_text_hit_test_grapheme(const RID &p_shaped, double p_coords) const; // Return grapheme index. + virtual int64_t shaped_text_hit_test_position(const RID &p_shaped, double p_coords) const; // Return caret/selection position. - virtual Vector2 shaped_text_get_grapheme_bounds(RID p_shaped, int p_pos) const; - virtual int shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const; - virtual int shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const; + virtual Vector2 shaped_text_get_grapheme_bounds(const RID &p_shaped, int64_t p_pos) const; + virtual int64_t shaped_text_next_grapheme_pos(const RID &p_shaped, int64_t p_pos) const; + virtual int64_t shaped_text_prev_grapheme_pos(const RID &p_shaped, int64_t p_pos) const; // The pen position is always placed on the baseline and moveing left to right. - virtual void shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, const Color &p_color = Color(1, 1, 1)) const; - virtual void shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l = -1.f, float p_clip_r = -1.f, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const; + virtual void shaped_text_draw(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, const Color &p_color = Color(1, 1, 1)) const; + virtual void shaped_text_draw_outline(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, int64_t p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const; // Number conversion. - virtual String format_number(const String &p_string, const String &p_language = "") const { return p_string; }; - virtual String parse_number(const String &p_string, const String &p_language = "") const { return p_string; }; - virtual String percent_sign(const String &p_language = "") const { return "%"; }; + virtual String format_number(const String &p_string, const String &p_language = "") const = 0; + virtual String parse_number(const String &p_string, const String &p_language = "") const = 0; + virtual String percent_sign(const String &p_language = "") const = 0; virtual String strip_diacritics(const String &p_string) const; @@ -507,23 +458,6 @@ struct CaretInfo { TextServer::Direction t_dir; }; -struct GlyphCompare { // For line breaking reordering. - _FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const { - if (l.start == r.start) { - if (l.count == r.count) { - if ((l.flags & TextServer::GRAPHEME_IS_VIRTUAL) == TextServer::GRAPHEME_IS_VIRTUAL) { - return false; - } else { - return true; - } - } - return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant. - } else { - return l.start < r.start; - } - } -}; - /*************************************************************************/ class TextServerManager : public Object { diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index e4145c8408b..5cf5403a508 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -671,10 +671,6 @@ void add_exposed_classes(Context &r_context) { } else { exposed_class.methods.push_back(method); } - - if (method.is_virtual) { - TEST_COND(String(method.name)[0] != '_', "Virtual method ", String(method.name), " does not start with underscore."); - } } // Add signals diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 8bd35df1074..0e0d2a218c7 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -2901,291 +2901,293 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { } SUBCASE("[CodeEdit] autocomplete completion") { - CHECK(code_edit->get_code_completion_selected_index() == -1); - code_edit->set_code_completion_enabled(true); - CHECK(code_edit->get_code_completion_selected_index() == -1); + if (TS->has_feature(TextServer::FEATURE_FONT_DYNAMIC) && TS->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + CHECK(code_edit->get_code_completion_selected_index() == -1); + code_edit->set_code_completion_enabled(true); + CHECK(code_edit->get_code_completion_selected_index() == -1); - code_edit->update_code_completion_options(); - code_edit->set_code_completion_selected_index(1); - CHECK(code_edit->get_code_completion_selected_index() == -1); - CHECK(code_edit->get_code_completion_option(0).size() == 0); - CHECK(code_edit->get_code_completion_options().size() == 0); + code_edit->update_code_completion_options(); + code_edit->set_code_completion_selected_index(1); + CHECK(code_edit->get_code_completion_selected_index() == -1); + CHECK(code_edit->get_code_completion_option(0).size() == 0); + CHECK(code_edit->get_code_completion_options().size() == 0); - /* Adding does not update the list. */ - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_0.", "item_0"); + /* Adding does not update the list. */ + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_0.", "item_0"); - code_edit->set_code_completion_selected_index(1); - CHECK(code_edit->get_code_completion_selected_index() == -1); - CHECK(code_edit->get_code_completion_option(0).size() == 0); - CHECK(code_edit->get_code_completion_options().size() == 0); + code_edit->set_code_completion_selected_index(1); + CHECK(code_edit->get_code_completion_selected_index() == -1); + CHECK(code_edit->get_code_completion_option(0).size() == 0); + CHECK(code_edit->get_code_completion_options().size() == 0); - /* After update, pending add should not be counted, */ - /* also does not work on col 0 */ - code_edit->insert_text_at_caret("i"); - code_edit->update_code_completion_options(); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0", Color(1, 0, 0), RES(), Color(1, 0, 0)); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_1.", "item_1"); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_2.", "item_2"); + /* After update, pending add should not be counted, */ + /* also does not work on col 0 */ + code_edit->insert_text_at_caret("i"); + code_edit->update_code_completion_options(); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0", Color(1, 0, 0), RES(), Color(1, 0, 0)); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_1.", "item_1"); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_2.", "item_2"); - ERR_PRINT_OFF; - code_edit->set_code_completion_selected_index(1); - ERR_PRINT_ON; - CHECK(code_edit->get_code_completion_selected_index() == 0); - CHECK(code_edit->get_code_completion_option(0).size() == 6); - CHECK(code_edit->get_code_completion_options().size() == 1); + ERR_PRINT_OFF; + code_edit->set_code_completion_selected_index(1); + ERR_PRINT_ON; + CHECK(code_edit->get_code_completion_selected_index() == 0); + CHECK(code_edit->get_code_completion_option(0).size() == 6); + CHECK(code_edit->get_code_completion_options().size() == 1); - /* Check cancel closes completion. */ - SEND_GUI_ACTION(code_edit, "ui_cancel"); - CHECK(code_edit->get_code_completion_selected_index() == -1); + /* Check cancel closes completion. */ + SEND_GUI_ACTION(code_edit, "ui_cancel"); + CHECK(code_edit->get_code_completion_selected_index() == -1); - code_edit->update_code_completion_options(); - CHECK(code_edit->get_code_completion_selected_index() == 0); - code_edit->set_code_completion_selected_index(1); - CHECK(code_edit->get_code_completion_selected_index() == 1); - CHECK(code_edit->get_code_completion_option(0).size() == 6); - CHECK(code_edit->get_code_completion_options().size() == 3); + code_edit->update_code_completion_options(); + CHECK(code_edit->get_code_completion_selected_index() == 0); + code_edit->set_code_completion_selected_index(1); + CHECK(code_edit->get_code_completion_selected_index() == 1); + CHECK(code_edit->get_code_completion_option(0).size() == 6); + CHECK(code_edit->get_code_completion_options().size() == 3); - /* Check data. */ - Dictionary option = code_edit->get_code_completion_option(0); - CHECK((int)option["kind"] == (int)CodeEdit::CodeCompletionKind::KIND_CLASS); - CHECK(option["display_text"] == "item_0."); - CHECK(option["insert_text"] == "item_0"); - CHECK(option["font_color"] == Color(1, 0, 0)); - CHECK(option["icon"] == RES()); - CHECK(option["default_value"] == Color(1, 0, 0)); + /* Check data. */ + Dictionary option = code_edit->get_code_completion_option(0); + CHECK((int)option["kind"] == (int)CodeEdit::CodeCompletionKind::KIND_CLASS); + CHECK(option["display_text"] == "item_0."); + CHECK(option["insert_text"] == "item_0"); + CHECK(option["font_color"] == Color(1, 0, 0)); + CHECK(option["icon"] == RES()); + CHECK(option["default_value"] == Color(1, 0, 0)); - /* Set size for mouse input. */ - code_edit->set_size(Size2(100, 100)); + /* Set size for mouse input. */ + code_edit->set_size(Size2(100, 100)); - /* Check input. */ - SEND_GUI_ACTION(code_edit, "ui_end"); - CHECK(code_edit->get_code_completion_selected_index() == 2); + /* Check input. */ + SEND_GUI_ACTION(code_edit, "ui_end"); + CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_home"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_home"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_page_down"); - CHECK(code_edit->get_code_completion_selected_index() == 2); + SEND_GUI_ACTION(code_edit, "ui_page_down"); + CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_page_up"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_page_up"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_up"); - CHECK(code_edit->get_code_completion_selected_index() == 2); + SEND_GUI_ACTION(code_edit, "ui_up"); + CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_down"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_down"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_KEY_EVENT(code_edit, Key::T); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_KEY_EVENT(code_edit, Key::T); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_left"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_left"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_right"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_right"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + CHECK(code_edit->get_code_completion_selected_index() == 0); - Point2 caret_pos = code_edit->get_caret_draw_pos(); - caret_pos.y -= code_edit->get_line_height(); - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE); - CHECK(code_edit->get_code_completion_selected_index() == 1); + Point2 caret_pos = code_edit->get_caret_draw_pos(); + caret_pos.y -= code_edit->get_line_height(); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE); + CHECK(code_edit->get_code_completion_selected_index() == 1); - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, MouseButton::NONE); - CHECK(code_edit->get_code_completion_selected_index() == 0); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, MouseButton::NONE); + CHECK(code_edit->get_code_completion_selected_index() == 0); - /* Single click selects. */ - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT); - CHECK(code_edit->get_code_completion_selected_index() == 2); + /* Single click selects. */ + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT); + CHECK(code_edit->get_code_completion_selected_index() == 2); - /* Double click inserts. */ - SEND_GUI_DOUBLE_CLICK(code_edit, caret_pos); - CHECK(code_edit->get_code_completion_selected_index() == -1); - CHECK(code_edit->get_line(0) == "item_2"); + /* Double click inserts. */ + SEND_GUI_DOUBLE_CLICK(code_edit, caret_pos); + CHECK(code_edit->get_code_completion_selected_index() == -1); + CHECK(code_edit->get_line(0) == "item_2"); - code_edit->set_auto_brace_completion_enabled(false); + code_edit->set_auto_brace_completion_enabled(false); - /* Does nothing in readonly. */ - code_edit->undo(); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - code_edit->set_editable(false); - code_edit->confirm_code_completion(); - code_edit->set_editable(true); - CHECK(code_edit->get_line(0) == "i"); + /* Does nothing in readonly. */ + code_edit->undo(); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + code_edit->set_editable(false); + code_edit->confirm_code_completion(); + code_edit->set_editable(true); + CHECK(code_edit->get_line(0) == "i"); - /* Replace */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0 test"); + /* Replace */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0 test"); - /* Replace string. */ - code_edit->clear(); - code_edit->insert_text_at_caret("\"item_1 test\""); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "\"item_0\""); + /* Replace string. */ + code_edit->clear(); + code_edit->insert_text_at_caret("\"item_1 test\""); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "\"item_0\""); - /* Normal replace if no end is given. */ - code_edit->clear(); - code_edit->insert_text_at_caret("\"item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "\"item_0\" test"); + /* Normal replace if no end is given. */ + code_edit->clear(); + code_edit->insert_text_at_caret("\"item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "\"item_0\" test"); - /* Insert at completion. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_accept"); - CHECK(code_edit->get_line(0) == "item_01 test"); + /* Insert at completion. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_accept"); + CHECK(code_edit->get_line(0) == "item_01 test"); - /* Insert at completion with string should have same output. */ - code_edit->clear(); - code_edit->insert_text_at_caret("\"item_1 test\""); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_accept"); - CHECK(code_edit->get_line(0) == "\"item_0\"1 test\""); + /* Insert at completion with string should have same output. */ + code_edit->clear(); + code_edit->insert_text_at_caret("\"item_1 test\""); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_accept"); + CHECK(code_edit->get_line(0) == "\"item_0\"1 test\""); - /* Merge symbol at end on insert text. */ - /* End on completion entry. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0( test"); - CHECK(code_edit->get_caret_column() == 7); + /* Merge symbol at end on insert text. */ + /* End on completion entry. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0( test"); + CHECK(code_edit->get_caret_column() == 7); - /* End of text*/ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1( test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0( test"); - CHECK(code_edit->get_caret_column() == 6); + /* End of text*/ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1( test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0( test"); + CHECK(code_edit->get_caret_column() == 6); - /* End of both. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1( test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0( test"); - CHECK(code_edit->get_caret_column() == 7); + /* End of both. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1( test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0( test"); + CHECK(code_edit->get_caret_column() == 7); - /* Full set. */ - /* End on completion entry. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 8); + /* Full set. */ + /* End on completion entry. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 8); - /* End of text*/ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1() test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 6); + /* End of text*/ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1() test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 6); - /* End of both. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1() test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 8); + /* End of both. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1() test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 8); - /* Autobrace completion. */ - code_edit->set_auto_brace_completion_enabled(true); + /* Autobrace completion. */ + code_edit->set_auto_brace_completion_enabled(true); - /* End on completion entry. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 7); + /* End on completion entry. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 7); - /* End of text*/ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1( test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0( test"); - CHECK(code_edit->get_caret_column() == 6); + /* End of text*/ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1( test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0( test"); + CHECK(code_edit->get_caret_column() == 6); - /* End of both. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1( test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0( test"); - CHECK(code_edit->get_caret_column() == 7); + /* End of both. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1( test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0("); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0( test"); + CHECK(code_edit->get_caret_column() == 7); - /* Full set. */ - /* End on completion entry. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1 test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 8); + /* Full set. */ + /* End on completion entry. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1 test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 8); - /* End of text*/ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1() test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 6); + /* End of text*/ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1() test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 6); - /* End of both. */ - code_edit->clear(); - code_edit->insert_text_at_caret("item_1() test"); - code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); - code_edit->update_code_completion_options(); - SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); - CHECK(code_edit->get_line(0) == "item_0() test"); - CHECK(code_edit->get_caret_column() == 8); + /* End of both. */ + code_edit->clear(); + code_edit->insert_text_at_caret("item_1() test"); + code_edit->set_caret_column(2); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()"); + code_edit->update_code_completion_options(); + SEND_GUI_ACTION(code_edit, "ui_text_completion_replace"); + CHECK(code_edit->get_line(0) == "item_0() test"); + CHECK(code_edit->get_caret_column() == 8); + } } memdelete(code_edit); @@ -3198,33 +3200,35 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") { code_edit->set_symbol_lookup_on_click_enabled(true); CHECK(code_edit->is_symbol_lookup_on_click_enabled()); - /* Set size for mouse input. */ - code_edit->set_size(Size2(100, 100)); + if (TS->has_feature(TextServer::FEATURE_FONT_DYNAMIC) && TS->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + /* Set size for mouse input. */ + code_edit->set_size(Size2(100, 100)); - code_edit->set_text("this is some text"); + code_edit->set_text("this is some text"); - Point2 caret_pos = code_edit->get_caret_draw_pos(); - caret_pos.x += 58; - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::NONE, MouseButton::NONE); - CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text"); + Point2 caret_pos = code_edit->get_caret_draw_pos(); + caret_pos.x += 58; + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::NONE, MouseButton::NONE); + CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text"); - SIGNAL_WATCH(code_edit, "symbol_validate"); + SIGNAL_WATCH(code_edit, "symbol_validate"); #ifdef OSX_ENABLED - SEND_GUI_KEY_EVENT(code_edit, Key::META); + SEND_GUI_KEY_EVENT(code_edit, Key::META); #else - SEND_GUI_KEY_EVENT(code_edit, Key::CTRL); + SEND_GUI_KEY_EVENT(code_edit, Key::CTRL); #endif - Array signal_args; - Array arg; - arg.push_back("some"); - signal_args.push_back(arg); - SIGNAL_CHECK("symbol_validate", signal_args); + Array signal_args; + Array arg; + arg.push_back("some"); + signal_args.push_back(arg); + SIGNAL_CHECK("symbol_validate", signal_args); - SIGNAL_UNWATCH(code_edit, "symbol_validate"); + SIGNAL_UNWATCH(code_edit, "symbol_validate"); - memdelete(code_edit); + memdelete(code_edit); + } } TEST_CASE("[SceneTree][CodeEdit] line length guidelines") { diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h index 0a642372854..d7de94516ff 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -46,10 +46,14 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC)) { + continue; + } + RID font = ts->create_font(); ts->font_set_data_ptr(font, _font_NotoSans_Regular, _font_NotoSans_Regular_size); TEST_FAIL_COND(font == RID(), "Loading font failed."); - ts->free(font); + ts->free_rid(font); } } @@ -58,12 +62,16 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); - Vector font; + Array font; font.push_back(font1); font.push_back(font2); @@ -93,10 +101,10 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND(glyphs[j].font_size != 16, "Incorrect glyph font size."); } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -107,7 +115,7 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); - if (!ts->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) { + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) { continue; } @@ -116,7 +124,7 @@ TEST_SUITE("[[TextServer]") { RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector font; + Array font; font.push_back(font1); font.push_back(font2); @@ -145,10 +153,10 @@ TEST_SUITE("[[TextServer]") { } } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -159,6 +167,10 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); @@ -166,7 +178,7 @@ TEST_SUITE("[[TextServer]") { RID font3 = ts->create_font(); ts->font_set_data_ptr(font3, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector font; + Array font; font.push_back(font1); font.push_back(font2); font.push_back(font3); @@ -198,7 +210,7 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -241,7 +253,7 @@ TEST_SUITE("[[TextServer]") { } } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -294,7 +306,7 @@ TEST_SUITE("[[TextServer]") { } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -322,7 +334,7 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } if (ts->has_feature(TextServer::FEATURE_BREAK_ITERATORS)) { @@ -350,11 +362,11 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -365,6 +377,10 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + String test_1 = U"test test test"; // 5^ 10^ @@ -373,7 +389,7 @@ TEST_SUITE("[[TextServer]") { RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); - Vector font; + Array font; font.push_back(font1); font.push_back(font2); @@ -395,10 +411,10 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND(brks[5] != 14, "Invalid line break position."); } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -409,12 +425,16 @@ TEST_SUITE("[[TextServer]") { Ref ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector font; + Array font; font.push_back(font1); font.push_back(font2); @@ -438,7 +458,7 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); ctx = ts->create_shaped_text(); TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); @@ -451,7 +471,7 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); } ctx = ts->create_shaped_text(); @@ -463,10 +483,10 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); }