Path: blob/master/modules/text_server_adv/text_server_adv.h
21207 views
/**************************************************************************/1/* text_server_adv.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132/*************************************************************************/33/* ICU/HarfBuzz/Graphite backed Text Server implementation with BiDi, */34/* shaping and advanced font features support. */35/*************************************************************************/3637#include "script_iterator.h"3839#ifdef GDEXTENSION40// Headers for building as GDExtension plug-in.4142#include <godot_cpp/godot.hpp>4344#include <godot_cpp/core/class_db.hpp>45#include <godot_cpp/core/ext_wrappers.gen.inc>46#include <godot_cpp/core/mutex_lock.hpp>4748#include <godot_cpp/variant/array.hpp>49#include <godot_cpp/variant/dictionary.hpp>50#include <godot_cpp/variant/packed_int32_array.hpp>51#include <godot_cpp/variant/packed_string_array.hpp>52#include <godot_cpp/variant/packed_vector2_array.hpp>53#include <godot_cpp/variant/rect2.hpp>54#include <godot_cpp/variant/rid.hpp>55#include <godot_cpp/variant/string.hpp>56#include <godot_cpp/variant/typed_array.hpp>57#include <godot_cpp/variant/vector2.hpp>58#include <godot_cpp/variant/vector2i.hpp>5960#include <godot_cpp/classes/text_server.hpp>61#include <godot_cpp/classes/text_server_extension.hpp>62#include <godot_cpp/classes/text_server_manager.hpp>6364#include <godot_cpp/classes/caret_info.hpp>65#include <godot_cpp/classes/global_constants_binds.hpp>66#include <godot_cpp/classes/glyph.hpp>67#include <godot_cpp/classes/image.hpp>68#include <godot_cpp/classes/image_texture.hpp>69#include <godot_cpp/classes/ref.hpp>70#include <godot_cpp/classes/worker_thread_pool.hpp>7172#include <godot_cpp/templates/hash_map.hpp>73#include <godot_cpp/templates/hash_set.hpp>74#include <godot_cpp/templates/rid_owner.hpp>75#include <godot_cpp/templates/safe_refcount.hpp>76#include <godot_cpp/templates/vector.hpp>7778using namespace godot;7980#elif defined(GODOT_MODULE)81// Headers for building as built-in module.8283#include "core/extension/ext_wrappers.gen.h"84#include "core/templates/hash_map.h"85#include "core/templates/rid_owner.h"86#include "core/templates/safe_refcount.h"87#include "scene/resources/image_texture.h"88#include "servers/text/text_server_extension.h"8990#include "modules/modules_enabled.gen.h" // For freetype, msdfgen, svg.9192#endif9394// Thirdparty headers.9596GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wshadow")97#if defined(__EMSCRIPTEN__) || (defined(__MINGW32__) && __clang_major__ >= 21)98GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunnecessary-virtual-specifier")99#endif100101#include <unicode/ubidi.h>102#include <unicode/ubrk.h>103#include <unicode/uchar.h>104#include <unicode/uclean.h>105#include <unicode/udata.h>106#include <unicode/uiter.h>107#include <unicode/uloc.h>108#include <unicode/unorm2.h>109#include <unicode/uscript.h>110#include <unicode/uspoof.h>111#include <unicode/ustring.h>112#include <unicode/utypes.h>113114GODOT_GCC_WARNING_POP115#if defined(__EMSCRIPTEN__) || (defined(__MINGW32__) && __clang_major__ >= 21)116GODOT_CLANG_WARNING_POP117#endif118119#ifdef MODULE_FREETYPE_ENABLED120#include <ft2build.h>121#include FT_FREETYPE_H122#include FT_TRUETYPE_TABLES_H123#include FT_STROKER_H124#include FT_ADVANCES_H125#include FT_MULTIPLE_MASTERS_H126#include FT_BBOX_H127#include FT_SIZES_H128#include FT_MODULE_H129#include FT_CONFIG_OPTIONS_H130#if !defined(FT_CONFIG_OPTION_USE_BROTLI) && !defined(_MSC_VER)131#warning FreeType is configured without Brotli support, built-in fonts will not be available.132#endif133#include <hb-ft.h>134#include <hb-ot.h>135#endif136137#include <hb-icu.h>138#include <hb.h>139140/*************************************************************************/141142class TextServerAdvanced : public TextServerExtension {143GDCLASS(TextServerAdvanced, TextServerExtension);144_THREAD_SAFE_CLASS_145146struct FeatureInfo {147StringName name;148Variant::Type vtype = Variant::INT;149bool hidden = false;150};151152HashMap<StringName, int32_t> feature_sets;153HashMap<int32_t, FeatureInfo> feature_sets_inv;154155enum LineBreakStrictness {156LB_AUTO,157LB_LOOSE,158LB_NORMAL,159LB_STRICT,160};161162SafeNumeric<TextServer::FontLCDSubpixelLayout> lcd_subpixel_layout{ TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE };163LineBreakStrictness lb_strictness = LB_AUTO;164void _update_settings();165166void _insert_feature_sets();167_FORCE_INLINE_ void _insert_feature(const StringName &p_name, int32_t p_tag, Variant::Type p_vtype = Variant::INT, bool p_hidden = false);168169// ICU support data.170171static bool icu_data_loaded;172static PackedByteArray icu_data;173mutable USet *allowed = nullptr;174mutable USpoofChecker *sc_spoof = nullptr;175mutable USpoofChecker *sc_conf = nullptr;176177mutable HashMap<String, UBreakIterator *> line_break_iterators_per_language;178179UBreakIterator *_create_line_break_iterator_for_locale(const String &p_language, UErrorCode *r_err) const;180181// Font cache data.182183#ifdef MODULE_FREETYPE_ENABLED184mutable FT_Library ft_library = nullptr;185#endif186187const int rect_range = 1;188189struct FontTexturePosition {190int32_t index = -1;191int32_t x = 0;192int32_t y = 0;193194FontTexturePosition() {}195FontTexturePosition(int32_t p_id, int32_t p_x, int32_t p_y) :196index(p_id), x(p_x), y(p_y) {}197};198199struct Shelf {200int32_t x = 0;201int32_t y = 0;202int32_t w = 0;203int32_t h = 0;204205FontTexturePosition alloc_shelf(int32_t p_id, int32_t p_w, int32_t p_h) {206if (p_w > w || p_h > h) {207return FontTexturePosition(-1, 0, 0);208}209int32_t xx = x;210x += p_w;211w -= p_w;212return FontTexturePosition(p_id, xx, y);213}214215Shelf() {}216Shelf(int32_t p_x, int32_t p_y, int32_t p_w, int32_t p_h) :217x(p_x), y(p_y), w(p_w), h(p_h) {}218};219220struct ShelfPackTexture {221int32_t texture_w = 1024;222int32_t texture_h = 1024;223224Ref<Image> image;225Ref<ImageTexture> texture;226bool dirty = true;227228List<Shelf> shelves;229230FontTexturePosition pack_rect(int32_t p_id, int32_t p_h, int32_t p_w) {231int32_t y = 0;232int32_t waste = 0;233Shelf *best_shelf = nullptr;234int32_t best_waste = std::numeric_limits<std::int32_t>::max();235236for (Shelf &E : shelves) {237y += E.h;238if (p_w > E.w) {239continue;240}241if (p_h == E.h) {242return E.alloc_shelf(p_id, p_w, p_h);243}244if (p_h > E.h) {245continue;246}247if (p_h < E.h) {248waste = (E.h - p_h) * p_w;249if (waste < best_waste) {250best_waste = waste;251best_shelf = &E;252}253}254}255if (best_shelf) {256return best_shelf->alloc_shelf(p_id, p_w, p_h);257}258if (p_h <= (texture_h - y) && p_w <= texture_w) {259List<Shelf>::Element *E = shelves.push_back(Shelf(0, y, texture_w, p_h));260return E->get().alloc_shelf(p_id, p_w, p_h);261}262return FontTexturePosition(-1, 0, 0);263}264265ShelfPackTexture() {}266ShelfPackTexture(int32_t p_w, int32_t p_h) :267texture_w(p_w), texture_h(p_h) {}268};269270struct FontGlyph {271bool found = false;272int texture_idx = -1;273Rect2 rect;274Rect2 uv_rect;275Vector2 advance;276bool from_svg = false;277};278279struct FontAdvanced;280struct FontForSizeAdvanced {281double ascent = 0.0;282double descent = 0.0;283double underline_position = 0.0;284double underline_thickness = 0.0;285double scale = 1.0;286287FontAdvanced *owner = nullptr;288uint32_t viewport_oversampling = 0;289290Vector2i size;291292Vector<ShelfPackTexture> textures;293HashMap<int64_t, int64_t> inv_glyph_map;294HashMap<int32_t, FontGlyph> glyph_map;295HashMap<Vector2i, Vector2> kerning_map;296hb_font_t *hb_handle = nullptr;297298#ifdef MODULE_FREETYPE_ENABLED299FT_Size fsize = nullptr;300#endif301302~FontForSizeAdvanced() {303if (hb_handle != nullptr) {304hb_font_destroy(hb_handle);305}306#ifdef MODULE_FREETYPE_ENABLED307if (fsize != nullptr) {308FT_Done_Size(fsize);309}310#endif311}312};313314struct OversamplingLevel {315HashSet<FontForSizeAdvanced *> fonts;316int32_t refcount = 1;317};318319mutable HashMap<uint32_t, OversamplingLevel> oversampling_levels;320321struct FontAdvancedLinkedVariation {322RID base_font;323int extra_spacing[4] = { 0, 0, 0, 0 };324double baseline_offset = 0.0;325};326327struct FontAdvanced {328Mutex mutex;329330TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;331bool disable_embedded_bitmaps = true;332bool mipmaps = false;333bool msdf = false;334int msdf_range = 14;335FixedSizeScaleMode fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE;336int msdf_source_size = 48;337int fixed_size = 0;338bool allow_system_fallback = true;339bool force_autohinter = false;340bool modulate_color_glyphs = false;341TextServer::Hinting hinting = TextServer::HINTING_LIGHT;342TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;343bool keep_rounding_remainders = true;344Dictionary variation_coordinates;345double oversampling_override = 0.0;346double embolden = 0.0;347Transform2D transform;348349BitField<TextServer::FontStyle> style_flags = 0;350String font_name;351String style_name;352int weight = 400;353int stretch = 100;354int extra_spacing[4] = { 0, 0, 0, 0 };355double baseline_offset = 0.0;356357HashMap<Vector2i, FontForSizeAdvanced *> cache;358359bool face_init = false;360HashSet<uint32_t> supported_scripts;361Dictionary supported_features;362Dictionary supported_varaitions;363Dictionary feature_overrides;364365// Language/script support override.366HashMap<String, bool> language_support_overrides;367HashMap<String, bool> script_support_overrides;368369PackedByteArray data;370const uint8_t *data_ptr = nullptr;371size_t data_size;372int face_index = 0;373374#ifdef MODULE_FREETYPE_ENABLED375FT_Face face = nullptr;376FT_StreamRec stream;377#endif378379~FontAdvanced() {380for (const KeyValue<Vector2i, FontForSizeAdvanced *> &E : cache) {381memdelete(E.value);382}383cache.clear();384#ifdef MODULE_FREETYPE_ENABLED385if (face != nullptr) {386FT_Done_Face(face);387}388#endif389}390};391392_FORCE_INLINE_ FontTexturePosition find_texture_pos_for_glyph(FontForSizeAdvanced *p_data, int p_color_size, Image::Format p_image_format, int p_width, int p_height, bool p_msdf) const;393#ifdef MODULE_MSDFGEN_ENABLED394_FORCE_INLINE_ FontGlyph rasterize_msdf(FontAdvanced *p_font_data, FontForSizeAdvanced *p_data, int p_pixel_range, int p_rect_margin, FT_Outline *p_outline, const Vector2 &p_advance) const;395#endif396#ifdef MODULE_FREETYPE_ENABLED397_FORCE_INLINE_ FontGlyph rasterize_bitmap(FontForSizeAdvanced *p_data, int p_rect_margin, FT_Bitmap p_bitmap, int p_yofs, int p_xofs, const Vector2 &p_advance, bool p_bgra) const;398#endif399bool _ensure_glyph(FontAdvanced *p_font_data, const Vector2i &p_size, int32_t p_glyph, FontGlyph &r_glyph, uint32_t p_oversampling = 0) const;400bool _ensure_cache_for_size(FontAdvanced *p_font_data, const Vector2i &p_size, FontForSizeAdvanced *&r_cache_for_size, bool p_silent = false, uint32_t p_oversampling = 0) const;401_FORCE_INLINE_ bool _font_validate(const RID &p_font_rid) const;402_FORCE_INLINE_ void _font_clear_cache(FontAdvanced *p_font_data);403static void _generateMTSDF_threaded(void *p_td, uint32_t p_y);404405_FORCE_INLINE_ Vector2i _get_size(const FontAdvanced *p_font_data, int p_size) const {406if (p_font_data->msdf) {407return Vector2i(p_font_data->msdf_source_size * 64, 0);408} else if (p_font_data->fixed_size > 0) {409return Vector2i(p_font_data->fixed_size * 64, 0);410} else {411return Vector2i(p_size * 64, 0);412}413}414415_FORCE_INLINE_ Vector2i _get_size_outline(const FontAdvanced *p_font_data, const Vector2i &p_size) const {416if (p_font_data->msdf) {417return Vector2i(p_font_data->msdf_source_size * 64, 0);418} else if (p_font_data->fixed_size > 0) {419return Vector2i(p_font_data->fixed_size * 64, MIN(p_size.y, 1));420} else {421return Vector2i(p_size.x * 64, p_size.y);422}423}424425_FORCE_INLINE_ double _get_extra_advance(RID p_font_rid, int p_font_size) const;426_FORCE_INLINE_ Variant::Type _get_tag_type(int64_t p_tag) const;427_FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const;428_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {429String sty_name = p_sty_name.remove_chars(" -");430if (sty_name.contains("thin") || sty_name.contains("hairline")) {431return 100;432} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {433return 200;434} else if (sty_name.contains("light")) {435return 300;436} else if (sty_name.contains("semilight")) {437return 350;438} else if (sty_name.contains("regular")) {439return 400;440} else if (sty_name.contains("medium")) {441return 500;442} else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {443return 600;444} else if (sty_name.contains("bold")) {445return 700;446} else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {447return 800;448} else if (sty_name.contains("black") || sty_name.contains("heavy")) {449return 900;450} else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {451return 950;452}453return 400;454}455_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {456String sty_name = p_sty_name.remove_chars(" -");457if (sty_name.contains("ultracondensed")) {458return 50;459} else if (sty_name.contains("extracondensed")) {460return 63;461} else if (sty_name.contains("condensed")) {462return 75;463} else if (sty_name.contains("semicondensed")) {464return 87;465} else if (sty_name.contains("semiexpanded")) {466return 113;467} else if (sty_name.contains("expanded")) {468return 125;469} else if (sty_name.contains("extraexpanded")) {470return 150;471} else if (sty_name.contains("ultraexpanded")) {472return 200;473}474return 100;475}476_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {477return p_sty_name.contains("italic") || p_sty_name.contains("oblique");478}479480// Shaped text cache data.481struct TrimData {482int trim_pos = -1;483int ellipsis_pos = -1;484Vector<Glyph> ellipsis_glyph_buf;485};486487struct TextRun {488Vector2i range;489RID font_rid;490int font_size = 0;491bool rtl = false;492int64_t span_index = -1;493};494495struct ShapedTextDataAdvanced {496Mutex mutex;497498/* Source data */499RID parent; // Substring parent ShapedTextData.500501int start = 0; // Substring start offset in the parent string.502int end = 0; // Substring end offset in the parent string.503504String text;505String custom_punct;506TextServer::Direction direction = DIRECTION_LTR; // Desired text direction.507TextServer::Orientation orientation = ORIENTATION_HORIZONTAL;508509struct Span {510int start = -1;511int end = -1;512513Array fonts;514int font_size = 0;515516Variant embedded_key;517518String language;519Dictionary features;520Variant meta;521};522Vector<Span> spans;523int first_span = 0; // First span in the parent ShapedTextData.524int last_span = 0;525526Vector<TextRun> runs;527bool runs_dirty = true;528529struct EmbeddedObject {530int start = -1;531int end = -1;532InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER;533Rect2 rect;534double baseline = 0;535};536HashMap<Variant, EmbeddedObject> objects;537538/* Shaped data */539TextServer::Direction para_direction = DIRECTION_LTR; // Detected text direction.540int base_para_direction = UBIDI_DEFAULT_LTR;541SafeFlag valid{ false }; // String is shaped.542bool line_breaks_valid = false; // Line and word break flags are populated (and virtual zero width spaces inserted).543bool justification_ops_valid = false; // Virtual elongation glyphs are added to the string.544bool sort_valid = false;545bool text_trimmed = false;546547bool preserve_invalid = true; // Draw hex code box instead of missing characters.548bool preserve_control = false; // Draw control characters.549550double ascent = 0.0; // Ascent for horizontal layout, 1/2 of width for vertical.551double descent = 0.0; // Descent for horizontal layout, 1/2 of width for vertical.552double width = 0.0; // Width for horizontal layout, height for vertical.553double width_trimmed = 0.0;554int extra_spacing[4] = { 0, 0, 0, 0 };555556double upos = 0.0;557double uthk = 0.0;558559char32_t el_char = 0x2026;560TrimData overrun_trim_data;561bool fit_width_minimum_reached = false;562563LocalVector<Glyph> glyphs;564LocalVector<Glyph> glyphs_logical;565566/* Intermediate data */567Char16String utf16;568Vector<UBiDi *> bidi_iter;569Vector<Vector3i> bidi_override;570ScriptIterator *script_iter = nullptr;571hb_buffer_t *hb_buffer = nullptr;572573HashMap<int, bool> jstops;574HashMap<int, bool> breaks;575PackedInt32Array chars;576int break_inserts = 0;577bool break_ops_valid = false;578bool js_ops_valid = false;579bool chars_valid = false;580581~ShapedTextDataAdvanced() {582for (int i = 0; i < bidi_iter.size(); i++) {583if (bidi_iter[i]) {584ubidi_close(bidi_iter[i]);585}586}587if (script_iter) {588memdelete(script_iter);589}590if (hb_buffer) {591hb_buffer_destroy(hb_buffer);592}593}594};595596// Common data.597598mutable RID_PtrOwner<FontAdvancedLinkedVariation> font_var_owner;599mutable RID_PtrOwner<FontAdvanced> font_owner;600mutable RID_PtrOwner<ShapedTextDataAdvanced> shaped_owner;601602_FORCE_INLINE_ FontAdvanced *_get_font_data(const RID &p_font_rid) const {603RID rid = p_font_rid;604FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(rid);605if (unlikely(fdv)) {606rid = fdv->base_font;607}608return font_owner.get_or_null(rid);609}610611struct SystemFontKey {612String font_name;613TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;614bool disable_embedded_bitmaps = true;615bool italic = false;616bool mipmaps = false;617bool msdf = false;618bool force_autohinter = false;619int weight = 400;620int stretch = 100;621int msdf_range = 14;622int msdf_source_size = 48;623int fixed_size = 0;624TextServer::Hinting hinting = TextServer::HINTING_LIGHT;625TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;626bool keep_rounding_remainders = true;627Dictionary variation_coordinates;628double embolden = 0.0;629Transform2D transform;630int extra_spacing[4] = { 0, 0, 0, 0 };631double baseline_offset = 0.0;632633bool operator==(const SystemFontKey &p_b) const {634return (font_name == p_b.font_name) && (antialiasing == p_b.antialiasing) && (italic == p_b.italic) && (disable_embedded_bitmaps == p_b.disable_embedded_bitmaps) && (mipmaps == p_b.mipmaps) && (msdf == p_b.msdf) && (force_autohinter == p_b.force_autohinter) && (weight == p_b.weight) && (stretch == p_b.stretch) && (msdf_range == p_b.msdf_range) && (msdf_source_size == p_b.msdf_source_size) && (fixed_size == p_b.fixed_size) && (hinting == p_b.hinting) && (subpixel_positioning == p_b.subpixel_positioning) && (keep_rounding_remainders == p_b.keep_rounding_remainders) && (variation_coordinates == p_b.variation_coordinates) && (embolden == p_b.embolden) && (transform == p_b.transform) && (extra_spacing[SPACING_TOP] == p_b.extra_spacing[SPACING_TOP]) && (extra_spacing[SPACING_BOTTOM] == p_b.extra_spacing[SPACING_BOTTOM]) && (extra_spacing[SPACING_SPACE] == p_b.extra_spacing[SPACING_SPACE]) && (extra_spacing[SPACING_GLYPH] == p_b.extra_spacing[SPACING_GLYPH]) && (baseline_offset == p_b.baseline_offset);635}636637SystemFontKey(const String &p_font_name, bool p_italic, int p_weight, int p_stretch, RID p_font, const TextServerAdvanced *p_fb) {638font_name = p_font_name;639italic = p_italic;640weight = p_weight;641stretch = p_stretch;642antialiasing = p_fb->_font_get_antialiasing(p_font);643disable_embedded_bitmaps = p_fb->_font_get_disable_embedded_bitmaps(p_font);644mipmaps = p_fb->_font_get_generate_mipmaps(p_font);645msdf = p_fb->_font_is_multichannel_signed_distance_field(p_font);646msdf_range = p_fb->_font_get_msdf_pixel_range(p_font);647msdf_source_size = p_fb->_font_get_msdf_size(p_font);648fixed_size = p_fb->_font_get_fixed_size(p_font);649force_autohinter = p_fb->_font_is_force_autohinter(p_font);650hinting = p_fb->_font_get_hinting(p_font);651subpixel_positioning = p_fb->_font_get_subpixel_positioning(p_font);652keep_rounding_remainders = p_fb->_font_get_keep_rounding_remainders(p_font);653variation_coordinates = p_fb->_font_get_variation_coordinates(p_font);654embolden = p_fb->_font_get_embolden(p_font);655transform = p_fb->_font_get_transform(p_font);656extra_spacing[SPACING_TOP] = p_fb->_font_get_spacing(p_font, SPACING_TOP);657extra_spacing[SPACING_BOTTOM] = p_fb->_font_get_spacing(p_font, SPACING_BOTTOM);658extra_spacing[SPACING_SPACE] = p_fb->_font_get_spacing(p_font, SPACING_SPACE);659extra_spacing[SPACING_GLYPH] = p_fb->_font_get_spacing(p_font, SPACING_GLYPH);660baseline_offset = p_fb->_font_get_baseline_offset(p_font);661}662};663664struct SystemFontCacheRec {665RID rid;666int index = 0;667};668669struct SystemFontCache {670Vector<SystemFontCacheRec> var;671int max_var = 0;672};673674struct SystemFontKeyHasher {675_FORCE_INLINE_ static uint32_t hash(const SystemFontKey &p_a) {676uint32_t hash = p_a.font_name.hash();677hash = hash_murmur3_one_32(p_a.variation_coordinates.hash(), hash);678hash = hash_murmur3_one_32(p_a.weight, hash);679hash = hash_murmur3_one_32(p_a.stretch, hash);680hash = hash_murmur3_one_32(p_a.msdf_range, hash);681hash = hash_murmur3_one_32(p_a.msdf_source_size, hash);682hash = hash_murmur3_one_32(p_a.fixed_size, hash);683hash = hash_murmur3_one_double(p_a.embolden, hash);684hash = hash_murmur3_one_real(p_a.transform[0].x, hash);685hash = hash_murmur3_one_real(p_a.transform[0].y, hash);686hash = hash_murmur3_one_real(p_a.transform[1].x, hash);687hash = hash_murmur3_one_real(p_a.transform[1].y, hash);688hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_TOP], hash);689hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_BOTTOM], hash);690hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_SPACE], hash);691hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_GLYPH], hash);692hash = hash_murmur3_one_double(p_a.baseline_offset, hash);693return hash_fmix32(hash_murmur3_one_32(((int)p_a.mipmaps) | ((int)p_a.msdf << 1) | ((int)p_a.italic << 2) | ((int)p_a.force_autohinter << 3) | ((int)p_a.hinting << 4) | ((int)p_a.subpixel_positioning << 8) | ((int)p_a.antialiasing << 12) | ((int)p_a.disable_embedded_bitmaps << 14) | ((int)p_a.keep_rounding_remainders << 15), hash));694}695};696mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts;697mutable HashMap<String, PackedByteArray> system_font_data;698699void _update_chars(ShapedTextDataAdvanced *p_sd) const;700void _generate_runs(ShapedTextDataAdvanced *p_sd) const;701void _realign(ShapedTextDataAdvanced *p_sd) const;702int64_t _convert_pos(const String &p_utf32, const Char16String &p_utf16, int64_t p_pos) const;703int64_t _convert_pos(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const;704int64_t _convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const;705bool _shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_length) const;706707struct FontPriorityList {708friend class TextServerAdvanced;709710const int PRIORITY_SKIP = 100; // Font already used.711const int PRIORITY_MAX = 2;712int current_priority = 0;713uint32_t current_index = 0;714uint32_t font_count = 0;715String language;716String script_code;717bool color = false;718LocalVector<Pair<RID, int>> unprocessed_fonts;719LocalVector<RID> fonts;720const TextServerAdvanced *text_server;721722FontPriorityList(const TextServerAdvanced *p_text_server, const Array &p_fonts, const String &p_language, const String &p_script_code, bool p_color) {723text_server = p_text_server;724language = p_language;725script_code = p_script_code;726font_count = p_fonts.size();727color = p_color;728729unprocessed_fonts.reserve(font_count);730for (uint32_t i = 0; i < font_count; i++) {731unprocessed_fonts.push_back(Pair<RID, int>(p_fonts[i], -1));732}733734fonts.reserve(font_count);735if (font_count > 0) {736fonts.push_back(p_fonts[0]);737unprocessed_fonts[0].second = PRIORITY_SKIP;738current_index++;739}740}741742_FORCE_INLINE_ uint32_t size() const {743return font_count;744}745746_FORCE_INLINE_ int _get_priority(const RID &p_font) {747if (color && text_server->_font_is_color(p_font)) {748return 0;749}750return text_server->_font_is_script_supported(p_font, script_code) ? (text_server->_font_is_language_supported(p_font, language) ? 0 : 1) : 2;751}752753RID operator[](uint32_t p_index) {754if (p_index < fonts.size()) {755return fonts[p_index];756}757while (current_priority < PRIORITY_MAX || current_index < font_count) {758if (current_index >= font_count) {759current_priority++;760current_index = 0;761}762const RID &font = unprocessed_fonts[current_index].first;763int &priority = unprocessed_fonts[current_index].second;764if (priority < 0) {765priority = _get_priority(font);766}767if (priority == current_priority) {768unprocessed_fonts[current_index].second = PRIORITY_SKIP;769fonts.push_back(font);770if (p_index < fonts.size()) {771return fonts[p_index];772}773}774current_index++;775}776return RID();777}778};779void _shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_end, const String &p_language, hb_script_t p_script, hb_direction_t p_direction, FontPriorityList &p_fonts, int64_t p_span, int64_t p_fb_index, int64_t p_prev_start, int64_t p_prev_end, RID p_prev_font);780Glyph _shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, const RID &p_font, int64_t p_font_size);781_FORCE_INLINE_ RID _find_sys_font_for_text(const RID &p_fdef, const String &p_script_code, const String &p_language, const String &p_text);782783_FORCE_INLINE_ void _add_features(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs);784785String os_locale;786787Mutex ft_mutex;788789// HarfBuzz bitmap font interface.790791static hb_font_funcs_t *funcs;792793struct bmp_font_t {794TextServerAdvanced::FontForSizeAdvanced *face = nullptr;795bool unref = false; /* Whether to destroy bm_face when done. */796};797798static bmp_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref);799static void _bmp_font_destroy(void *p_data);800static hb_bool_t _bmp_get_nominal_glyph(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_unicode, hb_codepoint_t *r_glyph, void *p_user_data);801static hb_position_t _bmp_get_glyph_h_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data);802static hb_position_t _bmp_get_glyph_v_advance(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, void *p_user_data);803static hb_position_t _bmp_get_glyph_h_kerning(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_left_glyph, hb_codepoint_t p_right_glyph, void *p_user_data);804static hb_bool_t _bmp_get_glyph_v_origin(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_position_t *r_x, hb_position_t *r_y, void *p_user_data);805static hb_bool_t _bmp_get_glyph_extents(hb_font_t *p_font, void *p_font_data, hb_codepoint_t p_glyph, hb_glyph_extents_t *r_extents, void *p_user_data);806static hb_bool_t _bmp_get_font_h_extents(hb_font_t *p_font, void *p_font_data, hb_font_extents_t *r_metrics, void *p_user_data);807static void _bmp_create_font_funcs();808static void _bmp_free_font_funcs();809static void _bmp_font_set_funcs(hb_font_t *p_font, TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref);810static hb_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, hb_destroy_func_t p_destroy);811812hb_font_t *_font_get_hb_handle(const RID &p_font, int64_t p_font_size, bool &r_is_color) const;813bool _font_is_color(const RID &p_font) const;814815struct GlyphCompare { // For line breaking reordering.816_FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const {817if (l.start == r.start) {818if (l.count == r.count) {819return (l.flags & TextServer::GRAPHEME_IS_VIRTUAL) < (r.flags & TextServer::GRAPHEME_IS_VIRTUAL);820}821return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant.822} else {823return l.start < r.start;824}825}826};827828protected:829static void _bind_methods() {}830831void full_copy(ShapedTextDataAdvanced *p_shaped);832void invalidate(ShapedTextDataAdvanced *p_shaped, bool p_text = false);833834public:835MODBIND1RC(bool, has_feature, Feature);836MODBIND0RC(String, get_name);837MODBIND0RC(int64_t, get_features);838839MODBIND1(free_rid, const RID &);840MODBIND1R(bool, has, const RID &);841MODBIND1R(bool, load_support_data, const String &);842843MODBIND0RC(String, get_support_data_filename);844MODBIND0RC(String, get_support_data_info);845MODBIND1RC(bool, save_support_data, const String &);846MODBIND0RC(PackedByteArray, get_support_data);847MODBIND1RC(bool, is_locale_using_support_data, const String &);848849MODBIND1RC(bool, is_locale_right_to_left, const String &);850851MODBIND1RC(int64_t, name_to_tag, const String &);852MODBIND1RC(String, tag_to_name, int64_t);853854/* Font interface */855856MODBIND0R(RID, create_font);857MODBIND1R(RID, create_font_linked_variation, const RID &);858859MODBIND2(font_set_data, const RID &, const PackedByteArray &);860MODBIND3(font_set_data_ptr, const RID &, const uint8_t *, int64_t);861862MODBIND2(font_set_face_index, const RID &, int64_t);863MODBIND1RC(int64_t, font_get_face_index, const RID &);864865MODBIND1RC(int64_t, font_get_face_count, const RID &);866867MODBIND2(font_set_style, const RID &, BitField<FontStyle>);868MODBIND1RC(BitField<FontStyle>, font_get_style, const RID &);869870MODBIND2(font_set_style_name, const RID &, const String &);871MODBIND1RC(String, font_get_style_name, const RID &);872873MODBIND2(font_set_weight, const RID &, int64_t);874MODBIND1RC(int64_t, font_get_weight, const RID &);875876MODBIND2(font_set_stretch, const RID &, int64_t);877MODBIND1RC(int64_t, font_get_stretch, const RID &);878879MODBIND2(font_set_name, const RID &, const String &);880MODBIND1RC(String, font_get_name, const RID &);881MODBIND1RC(Dictionary, font_get_ot_name_strings, const RID &);882883MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);884MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);885886MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);887MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);888889MODBIND2(font_set_generate_mipmaps, const RID &, bool);890MODBIND1RC(bool, font_get_generate_mipmaps, const RID &);891892MODBIND2(font_set_multichannel_signed_distance_field, const RID &, bool);893MODBIND1RC(bool, font_is_multichannel_signed_distance_field, const RID &);894895MODBIND2(font_set_msdf_pixel_range, const RID &, int64_t);896MODBIND1RC(int64_t, font_get_msdf_pixel_range, const RID &);897898MODBIND2(font_set_msdf_size, const RID &, int64_t);899MODBIND1RC(int64_t, font_get_msdf_size, const RID &);900901MODBIND2(font_set_fixed_size, const RID &, int64_t);902MODBIND1RC(int64_t, font_get_fixed_size, const RID &);903904MODBIND2(font_set_fixed_size_scale_mode, const RID &, FixedSizeScaleMode);905MODBIND1RC(FixedSizeScaleMode, font_get_fixed_size_scale_mode, const RID &);906907MODBIND2(font_set_allow_system_fallback, const RID &, bool);908MODBIND1RC(bool, font_is_allow_system_fallback, const RID &);909MODBIND0(font_clear_system_fallback_cache);910911MODBIND2(font_set_force_autohinter, const RID &, bool);912MODBIND1RC(bool, font_is_force_autohinter, const RID &);913914MODBIND2(font_set_modulate_color_glyphs, const RID &, bool);915MODBIND1RC(bool, font_is_modulate_color_glyphs, const RID &);916917MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning);918MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &);919920MODBIND2(font_set_keep_rounding_remainders, const RID &, bool);921MODBIND1RC(bool, font_get_keep_rounding_remainders, const RID &);922923MODBIND2(font_set_embolden, const RID &, double);924MODBIND1RC(double, font_get_embolden, const RID &);925926MODBIND3(font_set_spacing, const RID &, SpacingType, int64_t);927MODBIND2RC(int64_t, font_get_spacing, const RID &, SpacingType);928929MODBIND2(font_set_baseline_offset, const RID &, double);930MODBIND1RC(double, font_get_baseline_offset, const RID &);931932MODBIND2(font_set_transform, const RID &, const Transform2D &);933MODBIND1RC(Transform2D, font_get_transform, const RID &);934935MODBIND2(font_set_variation_coordinates, const RID &, const Dictionary &);936MODBIND1RC(Dictionary, font_get_variation_coordinates, const RID &);937938MODBIND2(font_set_oversampling, const RID &, double);939MODBIND1RC(double, font_get_oversampling, const RID &);940941MODBIND2(font_set_hinting, const RID &, TextServer::Hinting);942MODBIND1RC(TextServer::Hinting, font_get_hinting, const RID &);943944MODBIND1RC(TypedArray<Vector2i>, font_get_size_cache_list, const RID &);945MODBIND1(font_clear_size_cache, const RID &);946MODBIND2(font_remove_size_cache, const RID &, const Vector2i &);947MODBIND1RC(TypedArray<Dictionary>, font_get_size_cache_info, const RID &);948949MODBIND3(font_set_ascent, const RID &, int64_t, double);950MODBIND2RC(double, font_get_ascent, const RID &, int64_t);951952MODBIND3(font_set_descent, const RID &, int64_t, double);953MODBIND2RC(double, font_get_descent, const RID &, int64_t);954955MODBIND3(font_set_underline_position, const RID &, int64_t, double);956MODBIND2RC(double, font_get_underline_position, const RID &, int64_t);957958MODBIND3(font_set_underline_thickness, const RID &, int64_t, double);959MODBIND2RC(double, font_get_underline_thickness, const RID &, int64_t);960961MODBIND3(font_set_scale, const RID &, int64_t, double);962MODBIND2RC(double, font_get_scale, const RID &, int64_t);963964MODBIND2RC(int64_t, font_get_texture_count, const RID &, const Vector2i &);965MODBIND2(font_clear_textures, const RID &, const Vector2i &);966MODBIND3(font_remove_texture, const RID &, const Vector2i &, int64_t);967968MODBIND4(font_set_texture_image, const RID &, const Vector2i &, int64_t, const Ref<Image> &);969MODBIND3RC(Ref<Image>, font_get_texture_image, const RID &, const Vector2i &, int64_t);970971MODBIND4(font_set_texture_offsets, const RID &, const Vector2i &, int64_t, const PackedInt32Array &);972MODBIND3RC(PackedInt32Array, font_get_texture_offsets, const RID &, const Vector2i &, int64_t);973974MODBIND2RC(PackedInt32Array, font_get_glyph_list, const RID &, const Vector2i &);975MODBIND2(font_clear_glyphs, const RID &, const Vector2i &);976MODBIND3(font_remove_glyph, const RID &, const Vector2i &, int64_t);977978MODBIND3RC(Vector2, font_get_glyph_advance, const RID &, int64_t, int64_t);979MODBIND4(font_set_glyph_advance, const RID &, int64_t, int64_t, const Vector2 &);980981MODBIND3RC(Vector2, font_get_glyph_offset, const RID &, const Vector2i &, int64_t);982MODBIND4(font_set_glyph_offset, const RID &, const Vector2i &, int64_t, const Vector2 &);983984MODBIND3RC(Vector2, font_get_glyph_size, const RID &, const Vector2i &, int64_t);985MODBIND4(font_set_glyph_size, const RID &, const Vector2i &, int64_t, const Vector2 &);986987MODBIND3RC(Rect2, font_get_glyph_uv_rect, const RID &, const Vector2i &, int64_t);988MODBIND4(font_set_glyph_uv_rect, const RID &, const Vector2i &, int64_t, const Rect2 &);989990MODBIND3RC(int64_t, font_get_glyph_texture_idx, const RID &, const Vector2i &, int64_t);991MODBIND4(font_set_glyph_texture_idx, const RID &, const Vector2i &, int64_t, int64_t);992993MODBIND3RC(RID, font_get_glyph_texture_rid, const RID &, const Vector2i &, int64_t);994MODBIND3RC(Size2, font_get_glyph_texture_size, const RID &, const Vector2i &, int64_t);995996MODBIND3RC(Dictionary, font_get_glyph_contours, const RID &, int64_t, int64_t);997998MODBIND2RC(TypedArray<Vector2i>, font_get_kerning_list, const RID &, int64_t);999MODBIND2(font_clear_kerning_map, const RID &, int64_t);1000MODBIND3(font_remove_kerning, const RID &, int64_t, const Vector2i &);10011002MODBIND4(font_set_kerning, const RID &, int64_t, const Vector2i &, const Vector2 &);1003MODBIND3RC(Vector2, font_get_kerning, const RID &, int64_t, const Vector2i &);10041005MODBIND4RC(int64_t, font_get_glyph_index, const RID &, int64_t, int64_t, int64_t);1006MODBIND3RC(int64_t, font_get_char_from_glyph_index, const RID &, int64_t, int64_t);10071008MODBIND2RC(bool, font_has_char, const RID &, int64_t);1009MODBIND1RC(String, font_get_supported_chars, const RID &);1010MODBIND1RC(PackedInt32Array, font_get_supported_glyphs, const RID &);10111012MODBIND4(font_render_range, const RID &, const Vector2i &, int64_t, int64_t);1013MODBIND3(font_render_glyph, const RID &, const Vector2i &, int64_t);10141015MODBIND7C(font_draw_glyph, const RID &, const RID &, int64_t, const Vector2 &, int64_t, const Color &, float);1016MODBIND8C(font_draw_glyph_outline, const RID &, const RID &, int64_t, int64_t, const Vector2 &, int64_t, const Color &, float);10171018MODBIND2RC(bool, font_is_language_supported, const RID &, const String &);1019MODBIND3(font_set_language_support_override, const RID &, const String &, bool);1020MODBIND2R(bool, font_get_language_support_override, const RID &, const String &);1021MODBIND2(font_remove_language_support_override, const RID &, const String &);1022MODBIND1R(PackedStringArray, font_get_language_support_overrides, const RID &);10231024MODBIND2RC(bool, font_is_script_supported, const RID &, const String &);1025MODBIND3(font_set_script_support_override, const RID &, const String &, bool);1026MODBIND2R(bool, font_get_script_support_override, const RID &, const String &);1027MODBIND2(font_remove_script_support_override, const RID &, const String &);1028MODBIND1R(PackedStringArray, font_get_script_support_overrides, const RID &);10291030MODBIND2(font_set_opentype_feature_overrides, const RID &, const Dictionary &);1031MODBIND1RC(Dictionary, font_get_opentype_feature_overrides, const RID &);10321033MODBIND1RC(Dictionary, font_supported_feature_list, const RID &);1034MODBIND1RC(Dictionary, font_supported_variation_list, const RID &);10351036MODBIND1(reference_oversampling_level, double);1037MODBIND1(unreference_oversampling_level, double);10381039/* Shaped text buffer interface */10401041MODBIND2R(RID, create_shaped_text, Direction, Orientation);10421043MODBIND1(shaped_text_clear, const RID &);1044MODBIND1R(RID, shaped_text_duplicate, const RID &);10451046MODBIND2(shaped_text_set_direction, const RID &, Direction);1047MODBIND1RC(Direction, shaped_text_get_direction, const RID &);1048MODBIND1RC(Direction, shaped_text_get_inferred_direction, const RID &);10491050MODBIND2(shaped_text_set_bidi_override, const RID &, const Array &);10511052MODBIND2(shaped_text_set_custom_punctuation, const RID &, const String &);1053MODBIND1RC(String, shaped_text_get_custom_punctuation, const RID &);10541055MODBIND2(shaped_text_set_custom_ellipsis, const RID &, int64_t);1056MODBIND1RC(int64_t, shaped_text_get_custom_ellipsis, const RID &);10571058MODBIND2(shaped_text_set_orientation, const RID &, Orientation);1059MODBIND1RC(Orientation, shaped_text_get_orientation, const RID &);10601061MODBIND2(shaped_text_set_preserve_invalid, const RID &, bool);1062MODBIND1RC(bool, shaped_text_get_preserve_invalid, const RID &);10631064MODBIND2(shaped_text_set_preserve_control, const RID &, bool);1065MODBIND1RC(bool, shaped_text_get_preserve_control, const RID &);10661067MODBIND3(shaped_text_set_spacing, const RID &, SpacingType, int64_t);1068MODBIND2RC(int64_t, shaped_text_get_spacing, const RID &, SpacingType);10691070MODBIND7R(bool, shaped_text_add_string, const RID &, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);1071MODBIND6R(bool, shaped_text_add_object, const RID &, const Variant &, const Size2 &, InlineAlignment, int64_t, double);1072MODBIND5R(bool, shaped_text_resize_object, const RID &, const Variant &, const Size2 &, InlineAlignment, double);1073MODBIND2RC(bool, shaped_text_has_object, const RID &, const Variant &);1074MODBIND1RC(String, shaped_get_text, const RID &);10751076MODBIND1RC(int64_t, shaped_get_span_count, const RID &);1077MODBIND2RC(Variant, shaped_get_span_meta, const RID &, int64_t);1078MODBIND2RC(Variant, shaped_get_span_embedded_object, const RID &, int64_t);1079MODBIND2RC(String, shaped_get_span_text, const RID &, int64_t);1080MODBIND2RC(Variant, shaped_get_span_object, const RID &, int64_t);1081MODBIND5(shaped_set_span_update_font, const RID &, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &);10821083MODBIND1RC(int64_t, shaped_get_run_count, const RID &);1084MODBIND2RC(String, shaped_get_run_text, const RID &, int64_t);1085MODBIND2RC(Vector2i, shaped_get_run_range, const RID &, int64_t);1086MODBIND2RC(RID, shaped_get_run_font_rid, const RID &, int64_t);1087MODBIND2RC(int, shaped_get_run_font_size, const RID &, int64_t);1088MODBIND2RC(String, shaped_get_run_language, const RID &, int64_t);1089MODBIND2RC(Direction, shaped_get_run_direction, const RID &, int64_t);1090MODBIND2RC(Variant, shaped_get_run_object, const RID &, int64_t);10911092MODBIND3RC(RID, shaped_text_substr, const RID &, int64_t, int64_t);1093MODBIND1RC(RID, shaped_text_get_parent, const RID &);10941095MODBIND3R(double, shaped_text_fit_to_width, const RID &, double, BitField<TextServer::JustificationFlag>);1096MODBIND2R(double, shaped_text_tab_align, const RID &, const PackedFloat32Array &);10971098MODBIND1R(bool, shaped_text_shape, const RID &);1099MODBIND1R(bool, shaped_text_update_breaks, const RID &);1100MODBIND1R(bool, shaped_text_update_justification_ops, const RID &);11011102MODBIND1RC(int64_t, shaped_text_get_trim_pos, const RID &);1103MODBIND1RC(int64_t, shaped_text_get_ellipsis_pos, const RID &);1104MODBIND1RC(const Glyph *, shaped_text_get_ellipsis_glyphs, const RID &);1105MODBIND1RC(int64_t, shaped_text_get_ellipsis_glyph_count, const RID &);11061107MODBIND3(shaped_text_overrun_trim_to_width, const RID &, double, BitField<TextServer::TextOverrunFlag>);11081109MODBIND1RC(bool, shaped_text_is_ready, const RID &);11101111MODBIND1RC(const Glyph *, shaped_text_get_glyphs, const RID &);1112MODBIND1R(const Glyph *, shaped_text_sort_logical, const RID &);1113MODBIND1RC(int64_t, shaped_text_get_glyph_count, const RID &);11141115MODBIND1RC(Vector2i, shaped_text_get_range, const RID &);11161117MODBIND1RC(Array, shaped_text_get_objects, const RID &);1118MODBIND2RC(Rect2, shaped_text_get_object_rect, const RID &, const Variant &);1119MODBIND2RC(Vector2i, shaped_text_get_object_range, const RID &, const Variant &);1120MODBIND2RC(int64_t, shaped_text_get_object_glyph, const RID &, const Variant &);11211122MODBIND1RC(Size2, shaped_text_get_size, const RID &);1123MODBIND1RC(double, shaped_text_get_ascent, const RID &);1124MODBIND1RC(double, shaped_text_get_descent, const RID &);1125MODBIND1RC(double, shaped_text_get_width, const RID &);1126MODBIND1RC(double, shaped_text_get_underline_position, const RID &);1127MODBIND1RC(double, shaped_text_get_underline_thickness, const RID &);11281129MODBIND1RC(PackedInt32Array, shaped_text_get_character_breaks, const RID &);11301131MODBIND3RC(PackedInt32Array, string_get_word_breaks, const String &, const String &, int64_t);1132MODBIND2RC(PackedInt32Array, string_get_character_breaks, const String &, const String &);11331134MODBIND2RC(int64_t, is_confusable, const String &, const PackedStringArray &);1135MODBIND1RC(bool, spoof_check, const String &);11361137MODBIND1RC(String, strip_diacritics, const String &);1138MODBIND1RC(bool, is_valid_identifier, const String &);1139MODBIND1RC(bool, is_valid_letter, uint64_t);11401141MODBIND2RC(String, string_to_upper, const String &, const String &);1142MODBIND2RC(String, string_to_lower, const String &, const String &);1143MODBIND2RC(String, string_to_title, const String &, const String &);11441145MODBIND0(cleanup);11461147TextServerAdvanced();1148~TextServerAdvanced();1149};115011511152