diff options
Diffstat (limited to 'modules/text_server_fb')
-rw-r--r-- | modules/text_server_fb/.gitignore | 2 | ||||
-rw-r--r-- | modules/text_server_fb/doc_classes/TextServerFallback.xml | 2 | ||||
-rw-r--r-- | modules/text_server_fb/gdextension_build/SConstruct | 205 | ||||
-rw-r--r-- | modules/text_server_fb/gdextension_build/methods.py | 130 | ||||
-rw-r--r-- | modules/text_server_fb/gdextension_build/text_server_fb.gdextension | 12 | ||||
-rw-r--r-- | modules/text_server_fb/register_types.cpp | 28 | ||||
-rw-r--r-- | modules/text_server_fb/text_server_fb.cpp | 830 | ||||
-rw-r--r-- | modules/text_server_fb/text_server_fb.h | 429 |
8 files changed, 1053 insertions, 585 deletions
diff --git a/modules/text_server_fb/.gitignore b/modules/text_server_fb/.gitignore new file mode 100644 index 0000000000..15cc38b59c --- /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 76194a7bda..950b64e49f 100644 --- a/modules/text_server_fb/doc_classes/TextServerFallback.xml +++ b/modules/text_server_fb/doc_classes/TextServerFallback.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TextServerFallback" inherits="TextServer" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> +<class name="TextServerFallback" inherits="TextServerExtension" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> Fallback implementation of the Text Server, without BiDi and complex text layout support. </brief_description> diff --git a/modules/text_server_fb/gdextension_build/SConstruct b/modules/text_server_fb/gdextension_build/SConstruct new file mode 100644 index 0000000000..1753bc8b86 --- /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 0000000000..d404f2851e --- /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'<?xml version="1.0" encoding="UTF-8"?>\n') + f.write(f'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n') + f.write(f'<plist version="1.0">\n') + f.write(f"<dict>\n") + f.write(f"\t<key>CFBundleExecutable</key>\n") + f.write(f"\t<string>{binary_name}</string>\n") + f.write(f"\t<key>CFBundleIdentifier</key>\n") + f.write(f"\t<string>{identifier}</string>\n") + f.write(f"\t<key>CFBundleInfoDictionaryVersion</key>\n") + f.write(f"\t<string>6.0</string>\n") + f.write(f"\t<key>CFBundleName</key>\n") + f.write(f"\t<string>{name}</string>\n") + f.write(f"\t<key>CFBundlePackageType</key>\n") + f.write(f"\t<string>FMWK</string>\n") + f.write(f"\t<key>CFBundleShortVersionString</key>\n") + f.write(f"\t<string>1.0.0</string>\n") + f.write(f"\t<key>CFBundleSupportedPlatforms</key>\n") + f.write(f"\t<array>\n") + f.write(f"\t\t<string>MacOSX</string>\n") + f.write(f"\t</array>\n") + f.write(f"\t<key>CFBundleVersion</key>\n") + f.write(f"\t<string>1.0.0</string>\n") + f.write(f"\t<key>LSMinimumSystemVersion</key>\n") + f.write(f"\t<string>10.14</string>\n") + f.write(f"</dict>\n") + f.write(f"</plist>\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 0000000000..1026c6cb85 --- /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 a545f84939..1044c3f872 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<TextServerFallback> 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 <godot_cpp/core/class_db.hpp> +#include <godot_cpp/core/defs.hpp> +#include <godot_cpp/core/memory.hpp> + +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 e6f9bcf131..6c2e5a6084 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 <godot_cpp/classes/file.hpp> +#include <godot_cpp/classes/rendering_server.hpp> +#include <godot_cpp/classes/translation_server.hpp> +#include <godot_cpp/core/error_macros.hpp> + +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<StringName, int32_t> &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. @@ -155,7 +199,7 @@ String TextServerFallback::tag_to_name(int32_t p_tag) const { /* Font Glyph Rendering */ /*************************************************************************/ -_FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_texture_pos_for_glyph(FontDataForSizeFallback *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height) const { +_FORCE_INLINE_ TextServerFallback::FontTexturePosition TextServerFallback::find_texture_pos_for_glyph(FontDataForSizeFallback *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height, bool p_msdf) const { FontTexturePosition ret; ret.index = -1; @@ -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,9 +263,17 @@ _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 - texsize = MIN(texsize, 4096); + if (p_msdf) { + texsize = MIN(texsize, 2048); + } else { + texsize = MIN(texsize, 1024); + } FontTexture tex; tex.texture_w = texsize; @@ -252,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); @@ -386,10 +439,10 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf( int mw = w + p_rect_margin * 2; int mh = h + p_rect_margin * 2; - ERR_FAIL_COND_V(mw > 4096, FontGlyph()); - ERR_FAIL_COND_V(mh > 4096, FontGlyph()); + ERR_FAIL_COND_V(mw > 1024, FontGlyph()); + ERR_FAIL_COND_V(mh > 1024, FontGlyph()); - FontTexturePosition tex_pos = find_texture_pos_for_glyph(p_data, 4, Image::FORMAT_RGBA8, mw, mh); + FontTexturePosition tex_pos = find_texture_pos_for_glyph(p_data, 4, Image::FORMAT_RGBA8, mw, mh, true); ERR_FAIL_COND_V(tex_pos.index < 0, FontGlyph()); FontTexture &tex = p_data->textures.write[tex_pos.index]; @@ -431,7 +484,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf( // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref<Image> img = memnew(Image(tex.texture_w, tex.texture_h, 0, Image::FORMAT_RGBA8, tex.imgdata)); + Ref<Image> 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); @@ -442,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; @@ -464,13 +520,13 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma int mw = w + p_rect_margin * 2; int mh = h + p_rect_margin * 2; - ERR_FAIL_COND_V(mw > 4096, FontGlyph()); - ERR_FAIL_COND_V(mh > 4096, FontGlyph()); + ERR_FAIL_COND_V(mw > 1024, FontGlyph()); + ERR_FAIL_COND_V(mh > 1024, FontGlyph()); int color_size = bitmap.pixel_mode == FT_PIXEL_MODE_BGRA ? 4 : 2; Image::Format require_format = color_size == 4 ? Image::FORMAT_RGBA8 : Image::FORMAT_LA8; - FontTexturePosition tex_pos = find_texture_pos_for_glyph(p_data, color_size, require_format, mw, mh); + FontTexturePosition tex_pos = find_texture_pos_for_glyph(p_data, color_size, require_format, mw, mh, false); ERR_FAIL_COND_V(tex_pos.index < 0, FontGlyph()); // Fit character in char texture. @@ -503,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; } } @@ -513,7 +569,9 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma // Blit to image and texture. { if (RenderingServer::get_singleton() != nullptr) { - Ref<Image> img = memnew(Image(tex.texture_w, tex.texture_h, 0, require_format, tex.imgdata)); + Ref<Image> 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(); @@ -525,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; @@ -548,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)) { @@ -586,6 +645,8 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_d flags |= FT_LOAD_COLOR; } + glyph_index = FT_Get_Char_Index(fd->face, glyph_index); + FT_Fixed v, h; FT_Get_Advance(fd->face, glyph_index, flags, &h); FT_Get_Advance(fd->face, glyph_index, flags | FT_LOAD_VERTICAL_LAYOUT, &v); @@ -606,6 +667,16 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontDataFallback *p_font_d } } + if (p_font_data->embolden != 0.f) { + FT_Pos strength = p_font_data->embolden * p_size.x * 4; // 26.6 fractional units (1 / 64). + FT_Outline_Embolden(&fd->face->glyph->outline, strength); + } + + if (p_font_data->transform != Transform2D()) { + FT_Matrix mat = { FT_Fixed(p_font_data->transform[0][0] * 65536), FT_Fixed(p_font_data->transform[0][1] * 65536), FT_Fixed(p_font_data->transform[1][0] * 65536), FT_Fixed(p_font_data->transform[1][1] * 65536) }; // 16.16 fractional units (1 / 65536). + FT_Outline_Transform(&fd->face->glyph->outline, &mat); + } + if (!outline) { if (!p_font_data->msdf) { error = FT_Render_Glyph(fd->face->glyph, p_font_data->antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO); @@ -625,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."); } @@ -671,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)) + "'."); } @@ -687,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; @@ -695,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; @@ -706,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; @@ -752,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; } @@ -771,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!"); @@ -812,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); @@ -823,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); @@ -844,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); @@ -854,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); @@ -864,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()); @@ -874,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); @@ -884,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()); @@ -894,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); @@ -905,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); @@ -913,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); @@ -924,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); @@ -932,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); @@ -943,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); @@ -951,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); @@ -962,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); @@ -970,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); @@ -980,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); @@ -988,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); @@ -999,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); @@ -1007,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); @@ -1018,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); @@ -1026,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); @@ -1036,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); @@ -1044,7 +1115,45 @@ TextServer::SubpixelPositioning TextServerFallback::font_get_subpixel_positionin return fd->subpixel_positioning; } -void TextServerFallback::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) { +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); + + MutexLock lock(fd->mutex); + if (fd->embolden != p_strength) { + _font_clear_cache(fd); + fd->embolden = p_strength; + } +} + +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.0); + + MutexLock lock(fd->mutex); + return fd->embolden; +} + +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); + + MutexLock lock(fd->mutex); + if (fd->transform != p_transform) { + _font_clear_cache(fd); + fd->transform = p_transform; + } +} + +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()); + + MutexLock lock(fd->mutex); + return fd->transform; +} + +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); @@ -1055,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()); @@ -1063,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); @@ -1074,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()); @@ -1094,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); @@ -1105,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); @@ -1116,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); @@ -1127,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); @@ -1153,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); @@ -1180,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); @@ -1207,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); @@ -1234,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); @@ -1266,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); @@ -1283,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); @@ -1314,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); @@ -1324,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); @@ -1336,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<Image> &p_image) { +void TextServerFallback::font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref<Image> &p_image) { FontDataFallback *fd = font_owner.get_or_null(p_font_rid); ERR_FAIL_COND(!fd); ERR_FAIL_COND(p_image.is_null()); @@ -1356,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<Image> img = memnew(Image(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata)); + Ref<Image> img; + img.instantiate(); + img->create_from_data(tex.texture_w, tex.texture_h, 0, tex.format, tex.imgdata); + tex.texture = Ref<ImageTexture>(); tex.texture.instantiate(); tex.texture->create_from_image(img); } -Ref<Image> TextServerFallback::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const { +Ref<Image> 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<Image>()); @@ -1371,13 +1483,15 @@ Ref<Image> TextServerFallback::font_get_texture_image(RID p_font_rid, const Vect ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Ref<Image>()); ERR_FAIL_INDEX_V(p_texture_index, fd->cache[size]->textures.size(), Ref<Image>()); - const FontTexture &tex = fd->cache[size]->textures.write[p_texture_index]; - Ref<Image> 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<Image> 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); @@ -1393,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()); @@ -1402,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()); @@ -1423,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); @@ -1434,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); @@ -1445,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()); @@ -1459,16 +1573,21 @@ Vector2 TextServerFallback::font_get_glyph_advance(RID p_font_rid, int p_size, i const HashMap<int32_t, FontGlyph> &gl = fd->cache[size]->glyph_map; + Vector2 ea; + if (fd->embolden != 0.0) { + ea.x = fd->embolden * double(size.x) / 64.0; + } + if (fd->msdf) { - return gl[p_glyph].advance * (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.round(); + return (gl[p_glyph].advance + ea).round(); } else { - return gl[p_glyph].advance; + return gl[p_glyph].advance + ea; } } -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); @@ -1483,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()); @@ -1498,13 +1617,13 @@ Vector2 TextServerFallback::font_get_glyph_offset(RID p_font_rid, const Vector2i const HashMap<int32_t, FontGlyph> &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); @@ -1519,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()); @@ -1534,13 +1653,13 @@ Vector2 TextServerFallback::font_get_glyph_size(RID p_font_rid, const Vector2i & const HashMap<int32_t, FontGlyph> &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); @@ -1555,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()); @@ -1571,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); @@ -1586,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); @@ -1602,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); @@ -1617,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()); @@ -1626,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<Vector3> points; - Vector<int32_t> 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)); - ERR_FAIL_COND_V(error, Dictionary()); + int32_t index = p_index & 0xffffff; // Remove subpixel shifts. - points.clear(); - contours.clear(); + 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()); - 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]))); @@ -1659,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()); @@ -1675,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); @@ -1686,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); @@ -1697,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); @@ -1708,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()); @@ -1721,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]; } @@ -1733,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); } @@ -1743,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) + "."); @@ -1767,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()); @@ -1784,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); } @@ -1795,13 +1913,13 @@ String TextServerFallback::font_get_supported_chars(RID p_font_rid) const { const HashMap<int32_t, FontGlyph> &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) + "."); @@ -1810,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) { @@ -1834,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); @@ -1842,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); @@ -1863,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); @@ -1871,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) { @@ -1904,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; @@ -1926,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); @@ -1934,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) { @@ -1967,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; @@ -1989,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); @@ -2001,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); @@ -2009,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); @@ -2017,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); @@ -2025,19 +2143,19 @@ void TextServerFallback::font_remove_language_support_override(RID p_font_rid, c fd->language_support_overrides.erase(p_language); } -Vector<String> 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<String>()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector<String> out; + PackedStringArray out; for (const KeyValue<String, bool> &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); @@ -2049,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); @@ -2057,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); @@ -2065,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); @@ -2075,19 +2193,19 @@ void TextServerFallback::font_remove_script_support_override(RID p_font_rid, con fd->script_support_overrides.erase(p_script); } -Vector<String> 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<String>()); + ERR_FAIL_COND_V(!fd, PackedStringArray()); MutexLock lock(fd->mutex); - Vector<String> out; + PackedStringArray out; for (const KeyValue<String, bool> &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); @@ -2097,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()); @@ -2105,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()); @@ -2119,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; @@ -2156,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(); } @@ -2196,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); @@ -2210,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); @@ -2238,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); @@ -2259,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); @@ -2271,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); @@ -2285,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); @@ -2293,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); @@ -2307,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); @@ -2315,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<RID> &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<RID> 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)) { @@ -2352,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<RID> &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); @@ -2376,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<RID> 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)) { @@ -2393,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); @@ -2423,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); @@ -2431,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); @@ -2485,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; @@ -2499,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<Variant, ShapedTextDataFallback::EmbeddedObject> &E : p_sd->objects) { if ((E.value.pos >= p_sd->start) && (E.value.pos < p_sd->end)) { if (p_sd->orientation == ORIENTATION_HORIZONTAL) { @@ -2566,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()); @@ -2638,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; @@ -2648,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<Variant, ShapedTextDataFallback::EmbeddedObject> &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()); @@ -2728,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) { @@ -2768,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; @@ -2813,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); } @@ -2837,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) { @@ -2851,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) { @@ -2873,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++; @@ -2881,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; @@ -2890,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); @@ -2949,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); @@ -2965,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."); @@ -3011,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<RID> &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<RID> &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; } } @@ -3041,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; @@ -3117,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."); @@ -3125,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."); @@ -3133,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."); @@ -3141,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."); @@ -3149,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); @@ -3165,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) { @@ -3268,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; @@ -3279,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<Variant, ShapedTextDataFallback::EmbeddedObject> &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); @@ -3354,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); @@ -3365,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); @@ -3376,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); @@ -3388,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()); @@ -3396,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); @@ -3409,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()); @@ -3421,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()); @@ -3436,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) { @@ -3447,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) { @@ -3458,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) { @@ -3469,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) { @@ -3481,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) { @@ -3496,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 @@ -3510,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 @@ -3527,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 91afd02ae9..3944c371b7 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 <godot_cpp/godot.hpp> + +#include <godot_cpp/core/class_db.hpp> +#include <godot_cpp/core/mutex_lock.hpp> + +#include <godot_cpp/variant/array.hpp> +#include <godot_cpp/variant/dictionary.hpp> +#include <godot_cpp/variant/packed_int32_array.hpp> +#include <godot_cpp/variant/packed_string_array.hpp> +#include <godot_cpp/variant/packed_vector2_array.hpp> +#include <godot_cpp/variant/rect2.hpp> +#include <godot_cpp/variant/rid.hpp> +#include <godot_cpp/variant/string.hpp> +#include <godot_cpp/variant/vector2.hpp> +#include <godot_cpp/variant/vector2i.hpp> + +#include <godot_cpp/classes/text_server.hpp> +#include <godot_cpp/classes/text_server_extension.hpp> +#include <godot_cpp/classes/text_server_manager.hpp> + +#include <godot_cpp/classes/caret_info.hpp> +#include <godot_cpp/classes/global_constants_binds.hpp> +#include <godot_cpp/classes/glyph.hpp> +#include <godot_cpp/classes/image.hpp> +#include <godot_cpp/classes/image_texture.hpp> +#include <godot_cpp/classes/ref.hpp> + +#include <godot_cpp/templates/hash_map.hpp> +#include <godot_cpp/templates/map.hpp> +#include <godot_cpp/templates/rid_owner.hpp> +#include <godot_cpp/templates/set.hpp> +#include <godot_cpp/templates/thread_work_pool.hpp> +#include <godot_cpp/templates/vector.hpp> + +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 <ft2build.h> #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<StringName, int32_t> feature_sets; + Map<int32_t, StringName> 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,7 +186,9 @@ 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; + double oversampling = 0.0; + double embolden = 0.0; + Transform2D transform; uint32_t style_flags = 0; String font_name; @@ -165,14 +212,14 @@ class TextServerFallback : public TextServer { ~FontDataFallback() { work_pool.finish(); - for (const Map<Vector2i, FontDataForSizeFallback *>::Element *E = cache.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue<Vector2i, FontDataForSizeFallback *> &E : cache) { + memdelete(E.value); } cache.clear(); } }; - _FORCE_INLINE_ FontTexturePosition find_texture_pos_for_glyph(FontDataForSizeFallback *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height) const; + _FORCE_INLINE_ FontTexturePosition find_texture_pos_for_glyph(FontDataForSizeFallback *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height, bool p_msdf) const; #ifdef MODULE_MSDFGEN_ENABLED _FORCE_INLINE_ FontGlyph rasterize_msdf(FontDataFallback *p_font_data, FontDataForSizeFallback *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *outline, const Vector2 &advance) const; #endif @@ -205,13 +252,31 @@ class TextServerFallback : public TextServer { } // Shaped text cache data. + struct TrimData { + int trim_pos = -1; + int ellipsis_pos = -1; + Vector<Glyph> 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<RID> fonts; + Array fonts; int font_size = 0; Variant embedded_key; @@ -221,11 +286,43 @@ class TextServerFallback : public TextServer { Variant meta; }; Vector<Span> spans; + + struct EmbeddedObject { + int pos = 0; + InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER; + Rect2 rect; + }; + Map<Variant, EmbeddedObject> 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<Glyph> glyphs; + Vector<Glyph> glyphs_logical; }; // Common data. - float oversampling = 1.f; + double oversampling = 1.0; mutable RID_PtrOwner<FontDataFallback> font_owner; mutable RID_PtrOwner<ShapedTextDataFallback> shaped_owner; @@ -240,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 ""; }; @@ -252,212 +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(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(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_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_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_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_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_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_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_antialiased(RID p_font_rid, bool p_antialiased) override; - virtual bool font_is_antialiased(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_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_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_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_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_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_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_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_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_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_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_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_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_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_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<Image> &p_image) override; - virtual Ref<Image> 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<Image> &p_image) override; + virtual Ref<Image> 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<String> 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<String> 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<RID> &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<RID> &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; |