| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
#include "script_iterator.h" |
| 39 |
|
| 40 |
#ifdef GDEXTENSION |
| 41 |
|
| 42 |
|
| 43 |
#include <godot_cpp/godot.hpp> |
| 44 |
|
| 45 |
#include <godot_cpp/core/class_db.hpp> |
| 46 |
#include <godot_cpp/core/ext_wrappers.gen.inc> |
| 47 |
#include <godot_cpp/core/mutex_lock.hpp> |
| 48 |
|
| 49 |
#include <godot_cpp/variant/array.hpp> |
| 50 |
#include <godot_cpp/variant/dictionary.hpp> |
| 51 |
#include <godot_cpp/variant/packed_int32_array.hpp> |
| 52 |
#include <godot_cpp/variant/packed_string_array.hpp> |
| 53 |
#include <godot_cpp/variant/packed_vector2_array.hpp> |
| 54 |
#include <godot_cpp/variant/rect2.hpp> |
| 55 |
#include <godot_cpp/variant/rid.hpp> |
| 56 |
#include <godot_cpp/variant/string.hpp> |
| 57 |
#include <godot_cpp/variant/typed_array.hpp> |
| 58 |
#include <godot_cpp/variant/vector2.hpp> |
| 59 |
#include <godot_cpp/variant/vector2i.hpp> |
| 60 |
|
| 61 |
#include <godot_cpp/classes/text_server.hpp> |
| 62 |
#include <godot_cpp/classes/text_server_extension.hpp> |
| 63 |
#include <godot_cpp/classes/text_server_manager.hpp> |
| 64 |
|
| 65 |
#include <godot_cpp/classes/caret_info.hpp> |
| 66 |
#include <godot_cpp/classes/global_constants_binds.hpp> |
| 67 |
#include <godot_cpp/classes/glyph.hpp> |
| 68 |
#include <godot_cpp/classes/image.hpp> |
| 69 |
#include <godot_cpp/classes/image_texture.hpp> |
| 70 |
#include <godot_cpp/classes/ref.hpp> |
| 71 |
#include <godot_cpp/classes/worker_thread_pool.hpp> |
| 72 |
|
| 73 |
#include <godot_cpp/templates/hash_map.hpp> |
| 74 |
#include <godot_cpp/templates/hash_set.hpp> |
| 75 |
#include <godot_cpp/templates/rid_owner.hpp> |
| 76 |
#include <godot_cpp/templates/safe_refcount.hpp> |
| 77 |
#include <godot_cpp/templates/vector.hpp> |
| 78 |
|
| 79 |
using namespace godot; |
| 80 |
|
| 81 |
#elif defined(GODOT_MODULE) |
| 82 |
|
| 83 |
|
| 84 |
#include "core/extension/ext_wrappers.gen.inc" |
| 85 |
#include "core/templates/hash_map.h" |
| 86 |
#include "core/templates/rid_owner.h" |
| 87 |
#include "core/templates/safe_refcount.h" |
| 88 |
#include "scene/resources/image_texture.h" |
| 89 |
#include "servers/text/text_server_extension.h" |
| 90 |
|
| 91 |
#include "modules/modules_enabled.gen.h" |
| 92 |
|
| 93 |
#endif |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wshadow") |
| 98 |
#if defined(__EMSCRIPTEN__) || (defined(__MINGW32__) && __clang_major__ >= 21) |
| 99 |
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunnecessary-virtual-specifier") |
| 100 |
#endif |
| 101 |
|
| 102 |
#include <unicode/ubidi.h> |
| 103 |
#include <unicode/ubrk.h> |
| 104 |
#include <unicode/uchar.h> |
| 105 |
#include <unicode/uclean.h> |
| 106 |
#include <unicode/udata.h> |
| 107 |
#include <unicode/uiter.h> |
| 108 |
#include <unicode/uloc.h> |
| 109 |
#include <unicode/unorm2.h> |
| 110 |
#include <unicode/uscript.h> |
| 111 |
#include <unicode/uspoof.h> |
| 112 |
#include <unicode/ustring.h> |
| 113 |
#include <unicode/utypes.h> |
| 114 |
|
| 115 |
GODOT_GCC_WARNING_POP |
| 116 |
#if defined(__EMSCRIPTEN__) || (defined(__MINGW32__) && __clang_major__ >= 21) |
| 117 |
GODOT_CLANG_WARNING_POP |
| 118 |
#endif |
| 119 |
|
| 120 |
#ifdef MODULE_FREETYPE_ENABLED |
| 121 |
#include <ft2build.h> |
| 122 |
#include FT_FREETYPE_H |
| 123 |
#include FT_TRUETYPE_TABLES_H |
| 124 |
#include FT_STROKER_H |
| 125 |
#include FT_ADVANCES_H |
| 126 |
#include FT_MULTIPLE_MASTERS_H |
| 127 |
#include FT_BBOX_H |
| 128 |
#include FT_MODULE_H |
| 129 |
#include FT_CONFIG_OPTIONS_H |
| 130 |
#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 |
#endif |
| 133 |
#include <hb-ft.h> |
| 134 |
#include <hb-ot.h> |
| 135 |
#endif |
| 136 |
|
| 137 |
#include <hb-icu.h> |
| 138 |
#include <hb.h> |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
class TextServerAdvanced : public TextServerExtension { |
| 143 |
GDCLASS(TextServerAdvanced, TextServerExtension); |
| 144 |
_THREAD_SAFE_CLASS_ |
| 145 |
|
| 146 |
struct FeatureInfo { |
| 147 |
StringName name; |
| 148 |
Variant::Type vtype = Variant::INT; |
| 149 |
bool hidden = false; |
| 150 |
}; |
| 151 |
|
| 152 |
HashMap<StringName, int32_t> feature_sets; |
| 153 |
HashMap<int32_t, FeatureInfo> feature_sets_inv; |
| 154 |
|
| 155 |
enum LineBreakStrictness { |
| 156 |
LB_AUTO, |
| 157 |
LB_LOOSE, |
| 158 |
LB_NORMAL, |
| 159 |
LB_STRICT, |
| 160 |
}; |
| 161 |
|
| 162 |
SafeNumeric<TextServer::FontLCDSubpixelLayout> lcd_subpixel_layout{ TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_NONE }; |
| 163 |
LineBreakStrictness lb_strictness = LB_AUTO; |
| 164 |
void _update_settings(); |
| 165 |
|
| 166 |
void _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); |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
static bool icu_data_loaded; |
| 172 |
static PackedByteArray icu_data; |
| 173 |
mutable USet *allowed = nullptr; |
| 174 |
mutable USpoofChecker *sc_spoof = nullptr; |
| 175 |
mutable USpoofChecker *sc_conf = nullptr; |
| 176 |
|
| 177 |
mutable HashMap<String, UBreakIterator *> line_break_iterators_per_language; |
| 178 |
|
| 179 |
UBreakIterator *_create_line_break_iterator_for_locale(const String &p_language, UErrorCode *r_err) const; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
#ifdef MODULE_FREETYPE_ENABLED |
| 184 |
mutable FT_Library ft_library = nullptr; |
| 185 |
#endif |
| 186 |
|
| 187 |
const int rect_range = 1; |
| 188 |
|
| 189 |
struct FontTexturePosition { |
| 190 |
int32_t index = -1; |
| 191 |
int32_t x = 0; |
| 192 |
int32_t y = 0; |
| 193 |
|
| 194 |
FontTexturePosition() {} |
| 195 |
FontTexturePosition(int32_t p_id, int32_t p_x, int32_t p_y) : |
| 196 |
index(p_id), x(p_x), y(p_y) {} |
| 197 |
}; |
| 198 |
|
| 199 |
struct Shelf { |
| 200 |
int32_t x = 0; |
| 201 |
int32_t y = 0; |
| 202 |
int32_t w = 0; |
| 203 |
int32_t h = 0; |
| 204 |
|
| 205 |
FontTexturePosition alloc_shelf(int32_t p_id, int32_t p_w, int32_t p_h) { |
| 206 |
if (p_w > w || p_h > h) { |
| 207 |
return FontTexturePosition(-1, 0, 0); |
| 208 |
} |
| 209 |
int32_t xx = x; |
| 210 |
x += p_w; |
| 211 |
w -= p_w; |
| 212 |
return FontTexturePosition(p_id, xx, y); |
| 213 |
} |
| 214 |
|
| 215 |
Shelf() {} |
| 216 |
Shelf(int32_t p_x, int32_t p_y, int32_t p_w, int32_t p_h) : |
| 217 |
x(p_x), y(p_y), w(p_w), h(p_h) {} |
| 218 |
}; |
| 219 |
|
| 220 |
struct ShelfPackTexture { |
| 221 |
int32_t texture_w = 1024; |
| 222 |
int32_t texture_h = 1024; |
| 223 |
|
| 224 |
Ref<Image> image; |
| 225 |
Ref<ImageTexture> texture; |
| 226 |
bool dirty = true; |
| 227 |
|
| 228 |
List<Shelf> shelves; |
| 229 |
|
| 230 |
FontTexturePosition pack_rect(int32_t p_id, int32_t p_h, int32_t p_w) { |
| 231 |
int32_t y = 0; |
| 232 |
int32_t waste = 0; |
| 233 |
Shelf *best_shelf = nullptr; |
| 234 |
int32_t best_waste = std::numeric_limits<std::int32_t>::max(); |
| 235 |
|
| 236 |
for (Shelf &E : shelves) { |
| 237 |
y += E.h; |
| 238 |
if (p_w > E.w) { |
| 239 |
continue; |
| 240 |
} |
| 241 |
if (p_h == E.h) { |
| 242 |
return E.alloc_shelf(p_id, p_w, p_h); |
| 243 |
} |
| 244 |
if (p_h > E.h) { |
| 245 |
continue; |
| 246 |
} |
| 247 |
if (p_h < E.h) { |
| 248 |
waste = (E.h - p_h) * p_w; |
| 249 |
if (waste < best_waste) { |
| 250 |
best_waste = waste; |
| 251 |
best_shelf = &E; |
| 252 |
} |
| 253 |
} |
| 254 |
} |
| 255 |
if (best_shelf) { |
| 256 |
return best_shelf->alloc_shelf(p_id, p_w, p_h); |
| 257 |
} |
| 258 |
if (p_h <= (texture_h - y) && p_w <= texture_w) { |
| 259 |
List<Shelf>::Element *E = shelves.push_back(Shelf(0, y, texture_w, p_h)); |
| 260 |
return E->get().alloc_shelf(p_id, p_w, p_h); |
| 261 |
} |
| 262 |
return FontTexturePosition(-1, 0, 0); |
| 263 |
} |
| 264 |
|
| 265 |
ShelfPackTexture() {} |
| 266 |
ShelfPackTexture(int32_t p_w, int32_t p_h) : |
| 267 |
texture_w(p_w), texture_h(p_h) {} |
| 268 |
}; |
| 269 |
|
| 270 |
struct FontGlyph { |
| 271 |
bool found = false; |
| 272 |
int texture_idx = -1; |
| 273 |
Rect2 rect; |
| 274 |
Rect2 uv_rect; |
| 275 |
Vector2 advance; |
| 276 |
bool from_svg = false; |
| 277 |
}; |
| 278 |
|
| 279 |
struct FontAdvanced; |
| 280 |
struct FontForSizeAdvanced { |
| 281 |
double ascent = 0.0; |
| 282 |
double descent = 0.0; |
| 283 |
double underline_position = 0.0; |
| 284 |
double underline_thickness = 0.0; |
| 285 |
double scale = 1.0; |
| 286 |
|
| 287 |
FontAdvanced *owner = nullptr; |
| 288 |
uint32_t viewport_oversampling = 0; |
| 289 |
|
| 290 |
Vector2i size; |
| 291 |
|
| 292 |
Vector<ShelfPackTexture> textures; |
| 293 |
HashMap<int64_t, int64_t> inv_glyph_map; |
| 294 |
HashMap<int32_t, FontGlyph> glyph_map; |
| 295 |
HashMap<Vector2i, Vector2> kerning_map; |
| 296 |
hb_font_t *hb_handle = nullptr; |
| 297 |
|
| 298 |
#ifdef MODULE_FREETYPE_ENABLED |
| 299 |
FT_Face face = nullptr; |
| 300 |
FT_StreamRec stream; |
| 301 |
#endif |
| 302 |
|
| 303 |
~FontForSizeAdvanced() { |
| 304 |
if (hb_handle != nullptr) { |
| 305 |
hb_font_destroy(hb_handle); |
| 306 |
} |
| 307 |
#ifdef MODULE_FREETYPE_ENABLED |
| 308 |
if (face != nullptr) { |
| 309 |
FT_Done_Face(face); |
| 310 |
} |
| 311 |
#endif |
| 312 |
} |
| 313 |
}; |
| 314 |
|
| 315 |
struct OversamplingLevel { |
| 316 |
HashSet<FontForSizeAdvanced *> fonts; |
| 317 |
int32_t refcount = 1; |
| 318 |
}; |
| 319 |
|
| 320 |
mutable HashMap<uint32_t, OversamplingLevel> oversampling_levels; |
| 321 |
|
| 322 |
struct FontAdvancedLinkedVariation { |
| 323 |
RID base_font; |
| 324 |
int extra_spacing[4] = { 0, 0, 0, 0 }; |
| 325 |
double baseline_offset = 0.0; |
| 326 |
}; |
| 327 |
|
| 328 |
struct FontAdvanced { |
| 329 |
Mutex mutex; |
| 330 |
|
| 331 |
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY; |
| 332 |
bool disable_embedded_bitmaps = true; |
| 333 |
bool mipmaps = false; |
| 334 |
bool msdf = false; |
| 335 |
int msdf_range = 14; |
| 336 |
FixedSizeScaleMode fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE; |
| 337 |
int msdf_source_size = 48; |
| 338 |
int fixed_size = 0; |
| 339 |
bool allow_system_fallback = true; |
| 340 |
bool force_autohinter = false; |
| 341 |
bool modulate_color_glyphs = false; |
| 342 |
TextServer::Hinting hinting = TextServer::HINTING_LIGHT; |
| 343 |
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO; |
| 344 |
bool keep_rounding_remainders = true; |
| 345 |
Dictionary variation_coordinates; |
| 346 |
double oversampling_override = 0.0; |
| 347 |
double embolden = 0.0; |
| 348 |
Transform2D transform; |
| 349 |
|
| 350 |
BitField<TextServer::FontStyle> style_flags = 0; |
| 351 |
String font_name; |
| 352 |
String style_name; |
| 353 |
int weight = 400; |
| 354 |
int stretch = 100; |
| 355 |
int extra_spacing[4] = { 0, 0, 0, 0 }; |
| 356 |
double baseline_offset = 0.0; |
| 357 |
|
| 358 |
HashMap<Vector2i, FontForSizeAdvanced *> cache; |
| 359 |
|
| 360 |
bool face_init = false; |
| 361 |
HashSet<uint32_t> supported_scripts; |
| 362 |
Dictionary supported_features; |
| 363 |
Dictionary supported_varaitions; |
| 364 |
Dictionary feature_overrides; |
| 365 |
|
| 366 |
|
| 367 |
HashMap<String, bool> language_support_overrides; |
| 368 |
HashMap<String, bool> script_support_overrides; |
| 369 |
|
| 370 |
PackedByteArray data; |
| 371 |
const uint8_t *data_ptr = nullptr; |
| 372 |
size_t data_size; |
| 373 |
int face_index = 0; |
| 374 |
|
| 375 |
~FontAdvanced() { |
| 376 |
for (const KeyValue<Vector2i, FontForSizeAdvanced *> &E : cache) { |
| 377 |
memdelete(E.value); |
| 378 |
} |
| 379 |
cache.clear(); |
| 380 |
} |
| 381 |
}; |
| 382 |
|
| 383 |
_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; |
| 384 |
#ifdef MODULE_MSDFGEN_ENABLED |
| 385 |
_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; |
| 386 |
#endif |
| 387 |
#ifdef MODULE_FREETYPE_ENABLED |
| 388 |
_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; |
| 389 |
#endif |
| 390 |
bool _ensure_glyph(FontAdvanced *p_font_data, const Vector2i &p_size, int32_t p_glyph, FontGlyph &r_glyph, uint32_t p_oversampling = 0) const; |
| 391 |
bool _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; |
| 392 |
_FORCE_INLINE_ bool _font_validate(const RID &p_font_rid) const; |
| 393 |
_FORCE_INLINE_ void _font_clear_cache(FontAdvanced *p_font_data); |
| 394 |
static void _generateMTSDF_threaded(void *p_td, uint32_t p_y); |
| 395 |
|
| 396 |
_FORCE_INLINE_ Vector2i _get_size(const FontAdvanced *p_font_data, int p_size) const { |
| 397 |
if (p_font_data->msdf) { |
| 398 |
return Vector2i(p_font_data->msdf_source_size * 64, 0); |
| 399 |
} else if (p_font_data->fixed_size > 0) { |
| 400 |
return Vector2i(p_font_data->fixed_size * 64, 0); |
| 401 |
} else { |
| 402 |
return Vector2i(p_size * 64, 0); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
_FORCE_INLINE_ Vector2i _get_size_outline(const FontAdvanced *p_font_data, const Vector2i &p_size) const { |
| 407 |
if (p_font_data->msdf) { |
| 408 |
return Vector2i(p_font_data->msdf_source_size * 64, 0); |
| 409 |
} else if (p_font_data->fixed_size > 0) { |
| 410 |
return Vector2i(p_font_data->fixed_size * 64, MIN(p_size.y, 1)); |
| 411 |
} else { |
| 412 |
return Vector2i(p_size.x * 64, p_size.y); |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
_FORCE_INLINE_ double _get_extra_advance(RID p_font_rid, int p_font_size) const; |
| 417 |
_FORCE_INLINE_ Variant::Type _get_tag_type(int64_t p_tag) const; |
| 418 |
_FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const; |
| 419 |
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const { |
| 420 |
String sty_name = p_sty_name.remove_chars(" -"); |
| 421 |
if (sty_name.contains("thin") || sty_name.contains("hairline")) { |
| 422 |
return 100; |
| 423 |
} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) { |
| 424 |
return 200; |
| 425 |
} else if (sty_name.contains("light")) { |
| 426 |
return 300; |
| 427 |
} else if (sty_name.contains("semilight")) { |
| 428 |
return 350; |
| 429 |
} else if (sty_name.contains("regular")) { |
| 430 |
return 400; |
| 431 |
} else if (sty_name.contains("medium")) { |
| 432 |
return 500; |
| 433 |
} else if (sty_name.contains("semibold") || sty_name.contains("demibold")) { |
| 434 |
return 600; |
| 435 |
} else if (sty_name.contains("bold")) { |
| 436 |
return 700; |
| 437 |
} else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) { |
| 438 |
return 800; |
| 439 |
} else if (sty_name.contains("black") || sty_name.contains("heavy")) { |
| 440 |
return 900; |
| 441 |
} else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) { |
| 442 |
return 950; |
| 443 |
} |
| 444 |
return 400; |
| 445 |
} |
| 446 |
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const { |
| 447 |
String sty_name = p_sty_name.remove_chars(" -"); |
| 448 |
if (sty_name.contains("ultracondensed")) { |
| 449 |
return 50; |
| 450 |
} else if (sty_name.contains("extracondensed")) { |
| 451 |
return 63; |
| 452 |
} else if (sty_name.contains("condensed")) { |
| 453 |
return 75; |
| 454 |
} else if (sty_name.contains("semicondensed")) { |
| 455 |
return 87; |
| 456 |
} else if (sty_name.contains("semiexpanded")) { |
| 457 |
return 113; |
| 458 |
} else if (sty_name.contains("expanded")) { |
| 459 |
return 125; |
| 460 |
} else if (sty_name.contains("extraexpanded")) { |
| 461 |
return 150; |
| 462 |
} else if (sty_name.contains("ultraexpanded")) { |
| 463 |
return 200; |
| 464 |
} |
| 465 |
return 100; |
| 466 |
} |
| 467 |
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const { |
| 468 |
return p_sty_name.contains("italic") || p_sty_name.contains("oblique"); |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
struct TrimData { |
| 473 |
int trim_pos = -1; |
| 474 |
int ellipsis_pos = -1; |
| 475 |
Vector<Glyph> ellipsis_glyph_buf; |
| 476 |
}; |
| 477 |
|
| 478 |
struct TextRun { |
| 479 |
Vector2i range; |
| 480 |
Vector2i gl_range; |
| 481 |
RID font_rid; |
| 482 |
int font_size = 0; |
| 483 |
bool rtl = false; |
| 484 |
int64_t span_index = -1; |
| 485 |
}; |
| 486 |
|
| 487 |
struct ShapedTextDataAdvanced { |
| 488 |
Mutex mutex; |
| 489 |
|
| 490 |
|
| 491 |
RID parent; |
| 492 |
|
| 493 |
int start = 0; |
| 494 |
int end = 0; |
| 495 |
|
| 496 |
String text; |
| 497 |
String custom_punct; |
| 498 |
TextServer::Direction direction = DIRECTION_LTR; |
| 499 |
TextServer::Orientation orientation = ORIENTATION_HORIZONTAL; |
| 500 |
|
| 501 |
struct Span { |
| 502 |
int start = -1; |
| 503 |
int end = -1; |
| 504 |
|
| 505 |
Array fonts; |
| 506 |
int font_size = 0; |
| 507 |
|
| 508 |
Variant embedded_key; |
| 509 |
|
| 510 |
String language; |
| 511 |
Dictionary features; |
| 512 |
Variant meta; |
| 513 |
}; |
| 514 |
Vector<Span> spans; |
| 515 |
int first_span = 0; |
| 516 |
int last_span = 0; |
| 517 |
|
| 518 |
Vector<TextRun> runs; |
| 519 |
bool runs_dirty = true; |
| 520 |
|
| 521 |
struct EmbeddedObject { |
| 522 |
int start = -1; |
| 523 |
int end = -1; |
| 524 |
InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER; |
| 525 |
Rect2 rect; |
| 526 |
double baseline = 0; |
| 527 |
}; |
| 528 |
HashMap<Variant, EmbeddedObject> objects; |
| 529 |
|
| 530 |
|
| 531 |
TextServer::Direction para_direction = DIRECTION_LTR; |
| 532 |
int base_para_direction = UBIDI_DEFAULT_LTR; |
| 533 |
SafeFlag valid{ false }; |
| 534 |
bool line_breaks_valid = false; |
| 535 |
bool justification_ops_valid = false; |
| 536 |
bool sort_valid = false; |
| 537 |
bool text_trimmed = false; |
| 538 |
|
| 539 |
bool preserve_invalid = true; |
| 540 |
bool preserve_control = false; |
| 541 |
|
| 542 |
double ascent = 0.0; |
| 543 |
double descent = 0.0; |
| 544 |
double width = 0.0; |
| 545 |
double width_trimmed = 0.0; |
| 546 |
int extra_spacing[4] = { 0, 0, 0, 0 }; |
| 547 |
|
| 548 |
double upos = 0.0; |
| 549 |
double uthk = 0.0; |
| 550 |
|
| 551 |
char32_t el_char = 0x2026; |
| 552 |
TrimData overrun_trim_data; |
| 553 |
bool fit_width_minimum_reached = false; |
| 554 |
|
| 555 |
LocalVector<Glyph> glyphs; |
| 556 |
LocalVector<Glyph> glyphs_logical; |
| 557 |
|
| 558 |
|
| 559 |
Char16String utf16; |
| 560 |
Vector<UBiDi *> bidi_iter; |
| 561 |
Vector<Vector3i> bidi_override; |
| 562 |
ScriptIterator *script_iter = nullptr; |
| 563 |
hb_buffer_t *hb_buffer = nullptr; |
| 564 |
|
| 565 |
HashMap<int, bool> jstops; |
| 566 |
HashMap<int, bool> breaks; |
| 567 |
PackedInt32Array chars; |
| 568 |
int break_inserts = 0; |
| 569 |
bool break_ops_valid = false; |
| 570 |
bool js_ops_valid = false; |
| 571 |
bool chars_valid = false; |
| 572 |
|
| 573 |
~ShapedTextDataAdvanced() { |
| 574 |
for (int i = 0; i < bidi_iter.size(); i++) { |
| 575 |
if (bidi_iter[i]) { |
| 576 |
ubidi_close(bidi_iter[i]); |
| 577 |
} |
| 578 |
} |
| 579 |
if (script_iter) { |
| 580 |
memdelete(script_iter); |
| 581 |
} |
| 582 |
if (hb_buffer) { |
| 583 |
hb_buffer_destroy(hb_buffer); |
| 584 |
} |
| 585 |
} |
| 586 |
}; |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
mutable RID_PtrOwner<FontAdvancedLinkedVariation> font_var_owner; |
| 591 |
mutable RID_PtrOwner<FontAdvanced> font_owner; |
| 592 |
mutable RID_PtrOwner<ShapedTextDataAdvanced> shaped_owner; |
| 593 |
|
| 594 |
_FORCE_INLINE_ FontAdvanced *_get_font_data(const RID &p_font_rid) const { |
| 595 |
RID rid = p_font_rid; |
| 596 |
FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(rid); |
| 597 |
if (unlikely(fdv)) { |
| 598 |
rid = fdv->base_font; |
| 599 |
} |
| 600 |
return font_owner.get_or_null(rid); |
| 601 |
} |
| 602 |
|
| 603 |
struct SystemFontKey { |
| 604 |
String font_name; |
| 605 |
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY; |
| 606 |
bool disable_embedded_bitmaps = true; |
| 607 |
bool italic = false; |
| 608 |
bool mipmaps = false; |
| 609 |
bool msdf = false; |
| 610 |
bool force_autohinter = false; |
| 611 |
int weight = 400; |
| 612 |
int stretch = 100; |
| 613 |
int msdf_range = 14; |
| 614 |
int msdf_source_size = 48; |
| 615 |
int fixed_size = 0; |
| 616 |
TextServer::Hinting hinting = TextServer::HINTING_LIGHT; |
| 617 |
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO; |
| 618 |
bool keep_rounding_remainders = true; |
| 619 |
Dictionary variation_coordinates; |
| 620 |
double embolden = 0.0; |
| 621 |
Transform2D transform; |
| 622 |
int extra_spacing[4] = { 0, 0, 0, 0 }; |
| 623 |
double baseline_offset = 0.0; |
| 624 |
|
| 625 |
bool operator==(const SystemFontKey &p_b) const { |
| 626 |
return (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); |
| 627 |
} |
| 628 |
|
| 629 |
SystemFontKey(const String &p_font_name, bool p_italic, int p_weight, int p_stretch, RID p_font, const TextServerAdvanced *p_fb) { |
| 630 |
font_name = p_font_name; |
| 631 |
italic = p_italic; |
| 632 |
weight = p_weight; |
| 633 |
stretch = p_stretch; |
| 634 |
antialiasing = p_fb->_font_get_antialiasing(p_font); |
| 635 |
disable_embedded_bitmaps = p_fb->_font_get_disable_embedded_bitmaps(p_font); |
| 636 |
mipmaps = p_fb->_font_get_generate_mipmaps(p_font); |
| 637 |
msdf = p_fb->_font_is_multichannel_signed_distance_field(p_font); |
| 638 |
msdf_range = p_fb->_font_get_msdf_pixel_range(p_font); |
| 639 |
msdf_source_size = p_fb->_font_get_msdf_size(p_font); |
| 640 |
fixed_size = p_fb->_font_get_fixed_size(p_font); |
| 641 |
force_autohinter = p_fb->_font_is_force_autohinter(p_font); |
| 642 |
hinting = p_fb->_font_get_hinting(p_font); |
| 643 |
subpixel_positioning = p_fb->_font_get_subpixel_positioning(p_font); |
| 644 |
keep_rounding_remainders = p_fb->_font_get_keep_rounding_remainders(p_font); |
| 645 |
variation_coordinates = p_fb->_font_get_variation_coordinates(p_font); |
| 646 |
embolden = p_fb->_font_get_embolden(p_font); |
| 647 |
transform = p_fb->_font_get_transform(p_font); |
| 648 |
extra_spacing[SPACING_TOP] = p_fb->_font_get_spacing(p_font, SPACING_TOP); |
| 649 |
extra_spacing[SPACING_BOTTOM] = p_fb->_font_get_spacing(p_font, SPACING_BOTTOM); |
| 650 |
extra_spacing[SPACING_SPACE] = p_fb->_font_get_spacing(p_font, SPACING_SPACE); |
| 651 |
extra_spacing[SPACING_GLYPH] = p_fb->_font_get_spacing(p_font, SPACING_GLYPH); |
| 652 |
baseline_offset = p_fb->_font_get_baseline_offset(p_font); |
| 653 |
} |
| 654 |
}; |
| 655 |
|
| 656 |
struct SystemFontCacheRec { |
| 657 |
RID rid; |
| 658 |
int index = 0; |
| 659 |
}; |
| 660 |
|
| 661 |
struct SystemFontCache { |
| 662 |
Vector<SystemFontCacheRec> var; |
| 663 |
int max_var = 0; |
| 664 |
}; |
| 665 |
|
| 666 |
struct SystemFontKeyHasher { |
| 667 |
_FORCE_INLINE_ static uint32_t hash(const SystemFontKey &p_a) { |
| 668 |
uint32_t hash = p_a.font_name.hash(); |
| 669 |
hash = hash_murmur3_one_32(p_a.variation_coordinates.hash(), hash); |
| 670 |
hash = hash_murmur3_one_32(p_a.weight, hash); |
| 671 |
hash = hash_murmur3_one_32(p_a.stretch, hash); |
| 672 |
hash = hash_murmur3_one_32(p_a.msdf_range, hash); |
| 673 |
hash = hash_murmur3_one_32(p_a.msdf_source_size, hash); |
| 674 |
hash = hash_murmur3_one_32(p_a.fixed_size, hash); |
| 675 |
hash = hash_murmur3_one_double(p_a.embolden, hash); |
| 676 |
hash = hash_murmur3_one_real(p_a.transform[0].x, hash); |
| 677 |
hash = hash_murmur3_one_real(p_a.transform[0].y, hash); |
| 678 |
hash = hash_murmur3_one_real(p_a.transform[1].x, hash); |
| 679 |
hash = hash_murmur3_one_real(p_a.transform[1].y, hash); |
| 680 |
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_TOP], hash); |
| 681 |
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_BOTTOM], hash); |
| 682 |
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_SPACE], hash); |
| 683 |
hash = hash_murmur3_one_32(p_a.extra_spacing[SPACING_GLYPH], hash); |
| 684 |
hash = hash_murmur3_one_double(p_a.baseline_offset, hash); |
| 685 |
return 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)); |
| 686 |
} |
| 687 |
}; |
| 688 |
mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts; |
| 689 |
mutable HashMap<String, PackedByteArray> system_font_data; |
| 690 |
|
| 691 |
void _update_chars(ShapedTextDataAdvanced *p_sd) const; |
| 692 |
void _generate_runs(ShapedTextDataAdvanced *p_sd) const; |
| 693 |
void _realign(ShapedTextDataAdvanced *p_sd) const; |
| 694 |
int64_t _convert_pos(const String &p_utf32, const Char16String &p_utf16, int64_t p_pos) const; |
| 695 |
int64_t _convert_pos(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const; |
| 696 |
int64_t _convert_pos_inv(const ShapedTextDataAdvanced *p_sd, int64_t p_pos) const; |
| 697 |
bool _shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_length) const; |
| 698 |
|
| 699 |
struct FontPriorityList { |
| 700 |
friend class TextServerAdvanced; |
| 701 |
|
| 702 |
const int PRIORITY_SKIP = 100; |
| 703 |
const int PRIORITY_MAX = 2; |
| 704 |
int current_priority = 0; |
| 705 |
uint32_t current_index = 0; |
| 706 |
uint32_t font_count = 0; |
| 707 |
String language; |
| 708 |
String script_code; |
| 709 |
bool color = false; |
| 710 |
LocalVector<Pair<RID, int>> unprocessed_fonts; |
| 711 |
LocalVector<RID> fonts; |
| 712 |
const TextServerAdvanced *text_server; |
| 713 |
|
| 714 |
FontPriorityList(const TextServerAdvanced *p_text_server, const Array &p_fonts, const String &p_language, const String &p_script_code, bool p_color) { |
| 715 |
text_server = p_text_server; |
| 716 |
language = p_language; |
| 717 |
script_code = p_script_code; |
| 718 |
font_count = p_fonts.size(); |
| 719 |
color = p_color; |
| 720 |
|
| 721 |
unprocessed_fonts.reserve(font_count); |
| 722 |
for (uint32_t i = 0; i < font_count; i++) { |
| 723 |
unprocessed_fonts.push_back(Pair<RID, int>(p_fonts[i], -1)); |
| 724 |
} |
| 725 |
|
| 726 |
fonts.reserve(font_count); |
| 727 |
if (font_count > 0) { |
| 728 |
fonts.push_back(p_fonts[0]); |
| 729 |
unprocessed_fonts[0].second = PRIORITY_SKIP; |
| 730 |
current_index++; |
| 731 |
} |
| 732 |
} |
| 733 |
|
| 734 |
_FORCE_INLINE_ uint32_t size() const { |
| 735 |
return font_count; |
| 736 |
} |
| 737 |
|
| 738 |
_FORCE_INLINE_ int _get_priority(const RID &p_font) { |
| 739 |
if (color && text_server->_font_is_color(p_font)) { |
| 740 |
return 0; |
| 741 |
} |
| 742 |
return text_server->_font_is_script_supported(p_font, script_code) ? (text_server->_font_is_language_supported(p_font, language) ? 0 : 1) : 2; |
| 743 |
} |
| 744 |
|
| 745 |
RID operator[](uint32_t p_index) { |
| 746 |
if (p_index < fonts.size()) { |
| 747 |
return fonts[p_index]; |
| 748 |
} |
| 749 |
while (current_priority < PRIORITY_MAX || current_index < font_count) { |
| 750 |
if (current_index >= font_count) { |
| 751 |
current_priority++; |
| 752 |
current_index = 0; |
| 753 |
} |
| 754 |
const RID &font = unprocessed_fonts[current_index].first; |
| 755 |
int &priority = unprocessed_fonts[current_index].second; |
| 756 |
if (priority < 0) { |
| 757 |
priority = _get_priority(font); |
| 758 |
} |
| 759 |
if (priority == current_priority) { |
| 760 |
unprocessed_fonts[current_index].second = PRIORITY_SKIP; |
| 761 |
fonts.push_back(font); |
| 762 |
if (p_index < fonts.size()) { |
| 763 |
return fonts[p_index]; |
| 764 |
} |
| 765 |
} |
| 766 |
current_index++; |
| 767 |
} |
| 768 |
return RID(); |
| 769 |
} |
| 770 |
}; |
| 771 |
void _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); |
| 772 |
Glyph _shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, const RID &p_font, int64_t p_font_size); |
| 773 |
_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); |
| 774 |
|
| 775 |
_FORCE_INLINE_ void _add_features(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs); |
| 776 |
|
| 777 |
String os_locale; |
| 778 |
|
| 779 |
Mutex ft_mutex; |
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
static hb_font_funcs_t *funcs; |
| 784 |
|
| 785 |
struct bmp_font_t { |
| 786 |
TextServerAdvanced::FontForSizeAdvanced *face = nullptr; |
| 787 |
bool unref = false; |
| 788 |
}; |
| 789 |
|
| 790 |
static bmp_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref); |
| 791 |
static void _bmp_font_destroy(void *p_data); |
| 792 |
static 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); |
| 793 |
static 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); |
| 794 |
static 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); |
| 795 |
static 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); |
| 796 |
static 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); |
| 797 |
static 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); |
| 798 |
static 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); |
| 799 |
static void _bmp_create_font_funcs(); |
| 800 |
static void _bmp_free_font_funcs(); |
| 801 |
static void _bmp_font_set_funcs(hb_font_t *p_font, TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref); |
| 802 |
static hb_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, hb_destroy_func_t p_destroy); |
| 803 |
|
| 804 |
hb_font_t *_font_get_hb_handle(const RID &p_font, int64_t p_font_size, bool &r_is_color) const; |
| 805 |
bool _font_is_color(const RID &p_font) const; |
| 806 |
|
| 807 |
struct GlyphCompare { |
| 808 |
_FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const { |
| 809 |
if (l.start == r.start) { |
| 810 |
if (l.count == r.count) { |
| 811 |
return (l.flags & TextServer::GRAPHEME_IS_VIRTUAL) < (r.flags & TextServer::GRAPHEME_IS_VIRTUAL); |
| 812 |
} |
| 813 |
return l.count > r.count; |
| 814 |
} else { |
| 815 |
return l.start < r.start; |
| 816 |
} |
| 817 |
} |
| 818 |
}; |
| 819 |
|
| 820 |
protected: |
| 821 |
static void _bind_methods() {} |
| 822 |
|
| 823 |
void full_copy(ShapedTextDataAdvanced *p_shaped); |
| 824 |
void invalidate(ShapedTextDataAdvanced *p_shaped, bool p_text = false); |
| 825 |
|
| 826 |
public: |
| 827 |
MODBIND1RC(bool, has_feature, Feature); |
| 828 |
MODBIND0RC(String, get_name); |
| 829 |
MODBIND0RC(int64_t, get_features); |
| 830 |
|
| 831 |
MODBIND1(free_rid, const RID &); |
| 832 |
MODBIND1R(bool, has, const RID &); |
| 833 |
MODBIND1R(bool, load_support_data, const String &); |
| 834 |
|
| 835 |
MODBIND0RC(String, get_support_data_filename); |
| 836 |
MODBIND0RC(String, get_support_data_info); |
| 837 |
MODBIND1RC(bool, save_support_data, const String &); |
| 838 |
MODBIND0RC(PackedByteArray, get_support_data); |
| 839 |
MODBIND1RC(bool, is_locale_using_support_data, const String &); |
| 840 |
|
| 841 |
MODBIND1RC(bool, is_locale_right_to_left, const String &); |
| 842 |
|
| 843 |
MODBIND1RC(int64_t, name_to_tag, const String &); |
| 844 |
MODBIND1RC(String, tag_to_name, int64_t); |
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
MODBIND0R(RID, create_font); |
| 849 |
MODBIND1R(RID, create_font_linked_variation, const RID &); |
| 850 |
|
| 851 |
MODBIND2(font_set_data, const RID &, const PackedByteArray &); |
| 852 |
MODBIND3(font_set_data_ptr, const RID &, const uint8_t *, int64_t); |
| 853 |
|
| 854 |
MODBIND2(font_set_face_index, const RID &, int64_t); |
| 855 |
MODBIND1RC(int64_t, font_get_face_index, const RID &); |
| 856 |
|
| 857 |
MODBIND1RC(int64_t, font_get_face_count, const RID &); |
| 858 |
|
| 859 |
MODBIND2(font_set_style, const RID &, BitField<FontStyle>); |
| 860 |
MODBIND1RC(BitField<FontStyle>, font_get_style, const RID &); |
| 861 |
|
| 862 |
MODBIND2(font_set_style_name, const RID &, const String &); |
| 863 |
MODBIND1RC(String, font_get_style_name, const RID &); |
| 864 |
|
| 865 |
MODBIND2(font_set_weight, const RID &, int64_t); |
| 866 |
MODBIND1RC(int64_t, font_get_weight, const RID &); |
| 867 |
|
| 868 |
MODBIND2(font_set_stretch, const RID &, int64_t); |
| 869 |
MODBIND1RC(int64_t, font_get_stretch, const RID &); |
| 870 |
|
| 871 |
MODBIND2(font_set_name, const RID &, const String &); |
| 872 |
MODBIND1RC(String, font_get_name, const RID &); |
| 873 |
MODBIND1RC(Dictionary, font_get_ot_name_strings, const RID &); |
| 874 |
|
| 875 |
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing); |
| 876 |
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &); |
| 877 |
|
| 878 |
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool); |
| 879 |
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &); |
| 880 |
|
| 881 |
MODBIND2(font_set_generate_mipmaps, const RID &, bool); |
| 882 |
MODBIND1RC(bool, font_get_generate_mipmaps, const RID &); |
| 883 |
|
| 884 |
MODBIND2(font_set_multichannel_signed_distance_field, const RID &, bool); |
| 885 |
MODBIND1RC(bool, font_is_multichannel_signed_distance_field, const RID &); |
| 886 |
|
| 887 |
MODBIND2(font_set_msdf_pixel_range, const RID &, int64_t); |
| 888 |
MODBIND1RC(int64_t, font_get_msdf_pixel_range, const RID &); |
| 889 |
|
| 890 |
MODBIND2(font_set_msdf_size, const RID &, int64_t); |
| 891 |
MODBIND1RC(int64_t, font_get_msdf_size, const RID &); |
| 892 |
|
| 893 |
MODBIND2(font_set_fixed_size, const RID &, int64_t); |
| 894 |
MODBIND1RC(int64_t, font_get_fixed_size, const RID &); |
| 895 |
|
| 896 |
MODBIND2(font_set_fixed_size_scale_mode, const RID &, FixedSizeScaleMode); |
| 897 |
MODBIND1RC(FixedSizeScaleMode, font_get_fixed_size_scale_mode, const RID &); |
| 898 |
|
| 899 |
MODBIND2(font_set_allow_system_fallback, const RID &, bool); |
| 900 |
MODBIND1RC(bool, font_is_allow_system_fallback, const RID &); |
| 901 |
MODBIND0(font_clear_system_fallback_cache); |
| 902 |
|
| 903 |
MODBIND2(font_set_force_autohinter, const RID &, bool); |
| 904 |
MODBIND1RC(bool, font_is_force_autohinter, const RID &); |
| 905 |
|
| 906 |
MODBIND2(font_set_modulate_color_glyphs, const RID &, bool); |
| 907 |
MODBIND1RC(bool, font_is_modulate_color_glyphs, const RID &); |
| 908 |
|
| 909 |
MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning); |
| 910 |
MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &); |
| 911 |
|
| 912 |
MODBIND2(font_set_keep_rounding_remainders, const RID &, bool); |
| 913 |
MODBIND1RC(bool, font_get_keep_rounding_remainders, const RID &); |
| 914 |
|
| 915 |
MODBIND2(font_set_embolden, const RID &, double); |
| 916 |
MODBIND1RC(double, font_get_embolden, const RID &); |
| 917 |
|
| 918 |
MODBIND3(font_set_spacing, const RID &, SpacingType, int64_t); |
| 919 |
MODBIND2RC(int64_t, font_get_spacing, const RID &, SpacingType); |
| 920 |
|
| 921 |
MODBIND2(font_set_baseline_offset, const RID &, double); |
| 922 |
MODBIND1RC(double, font_get_baseline_offset, const RID &); |
| 923 |
|
| 924 |
MODBIND2(font_set_transform, const RID &, const Transform2D &); |
| 925 |
MODBIND1RC(Transform2D, font_get_transform, const RID &); |
| 926 |
|
| 927 |
MODBIND2(font_set_variation_coordinates, const RID &, const Dictionary &); |
| 928 |
MODBIND1RC(Dictionary, font_get_variation_coordinates, const RID &); |
| 929 |
|
| 930 |
MODBIND2(font_set_oversampling, const RID &, double); |
| 931 |
MODBIND1RC(double, font_get_oversampling, const RID &); |
| 932 |
|
| 933 |
MODBIND2(font_set_hinting, const RID &, TextServer::Hinting); |
| 934 |
MODBIND1RC(TextServer::Hinting, font_get_hinting, const RID &); |
| 935 |
|
| 936 |
MODBIND1RC(TypedArray<Vector2i>, font_get_size_cache_list, const RID &); |
| 937 |
MODBIND1(font_clear_size_cache, const RID &); |
| 938 |
MODBIND2(font_remove_size_cache, const RID &, const Vector2i &); |
| 939 |
MODBIND1RC(TypedArray<Dictionary>, font_get_size_cache_info, const RID &); |
| 940 |
|
| 941 |
MODBIND3(font_set_ascent, const RID &, int64_t, double); |
| 942 |
MODBIND2RC(double, font_get_ascent, const RID &, int64_t); |
| 943 |
|
| 944 |
MODBIND3(font_set_descent, const RID &, int64_t, double); |
| 945 |
MODBIND2RC(double, font_get_descent, const RID &, int64_t); |
| 946 |
|
| 947 |
MODBIND3(font_set_underline_position, const RID &, int64_t, double); |
| 948 |
MODBIND2RC(double, font_get_underline_position, const RID &, int64_t); |
| 949 |
|
| 950 |
MODBIND3(font_set_underline_thickness, const RID &, int64_t, double); |
| 951 |
MODBIND2RC(double, font_get_underline_thickness, const RID &, int64_t); |
| 952 |
|
| 953 |
MODBIND3(font_set_scale, const RID &, int64_t, double); |
| 954 |
MODBIND2RC(double, font_get_scale, const RID &, int64_t); |
| 955 |
|
| 956 |
MODBIND2RC(int64_t, font_get_texture_count, const RID &, const Vector2i &); |
| 957 |
MODBIND2(font_clear_textures, const RID &, const Vector2i &); |
| 958 |
MODBIND3(font_remove_texture, const RID &, const Vector2i &, int64_t); |
| 959 |
|
| 960 |
MODBIND4(font_set_texture_image, const RID &, const Vector2i &, int64_t, const Ref<Image> &); |
| 961 |
MODBIND3RC(Ref<Image>, font_get_texture_image, const RID &, const Vector2i &, int64_t); |
| 962 |
|
| 963 |
MODBIND4(font_set_texture_offsets, const RID &, const Vector2i &, int64_t, const PackedInt32Array &); |
| 964 |
MODBIND3RC(PackedInt32Array, font_get_texture_offsets, const RID &, const Vector2i &, int64_t); |
| 965 |
|
| 966 |
MODBIND2RC(PackedInt32Array, font_get_glyph_list, const RID &, const Vector2i &); |
| 967 |
MODBIND2(font_clear_glyphs, const RID &, const Vector2i &); |
| 968 |
MODBIND3(font_remove_glyph, const RID &, const Vector2i &, int64_t); |
| 969 |
|
| 970 |
MODBIND3RC(Vector2, font_get_glyph_advance, const RID &, int64_t, int64_t); |
| 971 |
MODBIND4(font_set_glyph_advance, const RID &, int64_t, int64_t, const Vector2 &); |
| 972 |
|
| 973 |
MODBIND3RC(Vector2, font_get_glyph_offset, const RID &, const Vector2i &, int64_t); |
| 974 |
MODBIND4(font_set_glyph_offset, const RID &, const Vector2i &, int64_t, const Vector2 &); |
| 975 |
|
| 976 |
MODBIND3RC(Vector2, font_get_glyph_size, const RID &, const Vector2i &, int64_t); |
| 977 |
MODBIND4(font_set_glyph_size, const RID &, const Vector2i &, int64_t, const Vector2 &); |
| 978 |
|
| 979 |
MODBIND3RC(Rect2, font_get_glyph_uv_rect, const RID &, const Vector2i &, int64_t); |
| 980 |
MODBIND4(font_set_glyph_uv_rect, const RID &, const Vector2i &, int64_t, const Rect2 &); |
| 981 |
|
| 982 |
MODBIND3RC(int64_t, font_get_glyph_texture_idx, const RID &, const Vector2i &, int64_t); |
| 983 |
MODBIND4(font_set_glyph_texture_idx, const RID &, const Vector2i &, int64_t, int64_t); |
| 984 |
|
| 985 |
MODBIND3RC(RID, font_get_glyph_texture_rid, const RID &, const Vector2i &, int64_t); |
| 986 |
MODBIND3RC(Size2, font_get_glyph_texture_size, const RID &, const Vector2i &, int64_t); |
| 987 |
|
| 988 |
MODBIND3RC(Dictionary, font_get_glyph_contours, const RID &, int64_t, int64_t); |
| 989 |
|
| 990 |
MODBIND2RC(TypedArray<Vector2i>, font_get_kerning_list, const RID &, int64_t); |
| 991 |
MODBIND2(font_clear_kerning_map, const RID &, int64_t); |
| 992 |
MODBIND3(font_remove_kerning, const RID &, int64_t, const Vector2i &); |
| 993 |
|
| 994 |
MODBIND4(font_set_kerning, const RID &, int64_t, const Vector2i &, const Vector2 &); |
| 995 |
MODBIND3RC(Vector2, font_get_kerning, const RID &, int64_t, const Vector2i &); |
| 996 |
|
| 997 |
MODBIND4RC(int64_t, font_get_glyph_index, const RID &, int64_t, int64_t, int64_t); |
| 998 |
MODBIND3RC(int64_t, font_get_char_from_glyph_index, const RID &, int64_t, int64_t); |
| 999 |
|
| 1000 |
MODBIND2RC(bool, font_has_char, const RID &, int64_t); |
| 1001 |
MODBIND1RC(String, font_get_supported_chars, const RID &); |
| 1002 |
MODBIND1RC(PackedInt32Array, font_get_supported_glyphs, const RID &); |
| 1003 |
|
| 1004 |
MODBIND4(font_render_range, const RID &, const Vector2i &, int64_t, int64_t); |
| 1005 |
MODBIND3(font_render_glyph, const RID &, const Vector2i &, int64_t); |
| 1006 |
|
| 1007 |
MODBIND7C(font_draw_glyph, const RID &, const RID &, int64_t, const Vector2 &, int64_t, const Color &, float); |
| 1008 |
MODBIND8C(font_draw_glyph_outline, const RID &, const RID &, int64_t, int64_t, const Vector2 &, int64_t, const Color &, float); |
| 1009 |
|
| 1010 |
MODBIND2RC(bool, font_is_language_supported, const RID &, const String &); |
| 1011 |
MODBIND3(font_set_language_support_override, const RID &, const String &, bool); |
| 1012 |
MODBIND2R(bool, font_get_language_support_override, const RID &, const String &); |
| 1013 |
MODBIND2(font_remove_language_support_override, const RID &, const String &); |
| 1014 |
MODBIND1R(PackedStringArray, font_get_language_support_overrides, const RID &); |
| 1015 |
|
| 1016 |
MODBIND2RC(bool, font_is_script_supported, const RID &, const String &); |
| 1017 |
MODBIND3(font_set_script_support_override, const RID &, const String &, bool); |
| 1018 |
MODBIND2R(bool, font_get_script_support_override, const RID &, const String &); |
| 1019 |
MODBIND2(font_remove_script_support_override, const RID &, const String &); |
| 1020 |
MODBIND1R(PackedStringArray, font_get_script_support_overrides, const RID &); |
| 1021 |
|
| 1022 |
MODBIND2(font_set_opentype_feature_overrides, const RID &, const Dictionary &); |
| 1023 |
MODBIND1RC(Dictionary, font_get_opentype_feature_overrides, const RID &); |
| 1024 |
|
| 1025 |
MODBIND1RC(Dictionary, font_supported_feature_list, const RID &); |
| 1026 |
MODBIND1RC(Dictionary, font_supported_variation_list, const RID &); |
| 1027 |
|
| 1028 |
MODBIND1(reference_oversampling_level, double); |
| 1029 |
MODBIND1(unreference_oversampling_level, double); |
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
MODBIND2R(RID, create_shaped_text, Direction, Orientation); |
| 1034 |
|
| 1035 |
MODBIND1(shaped_text_clear, const RID &); |
| 1036 |
MODBIND1R(RID, shaped_text_duplicate, const RID &); |
| 1037 |
|
| 1038 |
MODBIND2(shaped_text_set_direction, const RID &, Direction); |
| 1039 |
MODBIND1RC(Direction, shaped_text_get_direction, const RID &); |
| 1040 |
MODBIND1RC(Direction, shaped_text_get_inferred_direction, const RID &); |
| 1041 |
|
| 1042 |
MODBIND2(shaped_text_set_bidi_override, const RID &, const Array &); |
| 1043 |
|
| 1044 |
MODBIND2(shaped_text_set_custom_punctuation, const RID &, const String &); |
| 1045 |
MODBIND1RC(String, shaped_text_get_custom_punctuation, const RID &); |
| 1046 |
|
| 1047 |
MODBIND2(shaped_text_set_custom_ellipsis, const RID &, int64_t); |
| 1048 |
MODBIND1RC(int64_t, shaped_text_get_custom_ellipsis, const RID &); |
| 1049 |
|
| 1050 |
MODBIND2(shaped_text_set_orientation, const RID &, Orientation); |
| 1051 |
MODBIND1RC(Orientation, shaped_text_get_orientation, const RID &); |
| 1052 |
|
| 1053 |
MODBIND2(shaped_text_set_preserve_invalid, const RID &, bool); |
| 1054 |
MODBIND1RC(bool, shaped_text_get_preserve_invalid, const RID &); |
| 1055 |
|
| 1056 |
MODBIND2(shaped_text_set_preserve_control, const RID &, bool); |
| 1057 |
MODBIND1RC(bool, shaped_text_get_preserve_control, const RID &); |
| 1058 |
|
| 1059 |
MODBIND3(shaped_text_set_spacing, const RID &, SpacingType, int64_t); |
| 1060 |
MODBIND2RC(int64_t, shaped_text_get_spacing, const RID &, SpacingType); |
| 1061 |
|
| 1062 |
MODBIND7R(bool, shaped_text_add_string, const RID &, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &); |
| 1063 |
MODBIND6R(bool, shaped_text_add_object, const RID &, const Variant &, const Size2 &, InlineAlignment, int64_t, double); |
| 1064 |
MODBIND5R(bool, shaped_text_resize_object, const RID &, const Variant &, const Size2 &, InlineAlignment, double); |
| 1065 |
MODBIND2RC(bool, shaped_text_has_object, const RID &, const Variant &); |
| 1066 |
MODBIND1RC(String, shaped_get_text, const RID &); |
| 1067 |
|
| 1068 |
MODBIND1RC(int64_t, shaped_get_span_count, const RID &); |
| 1069 |
MODBIND2RC(Variant, shaped_get_span_meta, const RID &, int64_t); |
| 1070 |
MODBIND2RC(Variant, shaped_get_span_embedded_object, const RID &, int64_t); |
| 1071 |
MODBIND2RC(String, shaped_get_span_text, const RID &, int64_t); |
| 1072 |
MODBIND2RC(Variant, shaped_get_span_object, const RID &, int64_t); |
| 1073 |
MODBIND5(shaped_set_span_update_font, const RID &, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &); |
| 1074 |
|
| 1075 |
MODBIND1RC(int64_t, shaped_get_run_count, const RID &); |
| 1076 |
MODBIND2RC(String, shaped_get_run_text, const RID &, int64_t); |
| 1077 |
MODBIND2RC(Vector2i, shaped_get_run_range, const RID &, int64_t); |
| 1078 |
MODBIND2RC(Vector2i, shaped_get_run_glyph_range, const RID &, int64_t); |
| 1079 |
MODBIND2RC(RID, shaped_get_run_font_rid, const RID &, int64_t); |
| 1080 |
MODBIND2RC(int, shaped_get_run_font_size, const RID &, int64_t); |
| 1081 |
MODBIND2RC(String, shaped_get_run_language, const RID &, int64_t); |
| 1082 |
MODBIND2RC(Direction, shaped_get_run_direction, const RID &, int64_t); |
| 1083 |
MODBIND2RC(Variant, shaped_get_run_object, const RID &, int64_t); |
| 1084 |
|
| 1085 |
MODBIND3RC(RID, shaped_text_substr, const RID &, int64_t, int64_t); |
| 1086 |
MODBIND1RC(RID, shaped_text_get_parent, const RID &); |
| 1087 |
|
| 1088 |
MODBIND3R(double, shaped_text_fit_to_width, const RID &, double, BitField<TextServer::JustificationFlag>); |
| 1089 |
MODBIND2R(double, shaped_text_tab_align, const RID &, const PackedFloat32Array &); |
| 1090 |
|
| 1091 |
MODBIND1R(bool, shaped_text_shape, const RID &); |
| 1092 |
MODBIND1R(bool, shaped_text_update_breaks, const RID &); |
| 1093 |
MODBIND1R(bool, shaped_text_update_justification_ops, const RID &); |
| 1094 |
|
| 1095 |
MODBIND1RC(int64_t, shaped_text_get_trim_pos, const RID &); |
| 1096 |
MODBIND1RC(int64_t, shaped_text_get_ellipsis_pos, const RID &); |
| 1097 |
MODBIND1RC(const Glyph *, shaped_text_get_ellipsis_glyphs, const RID &); |
| 1098 |
MODBIND1RC(int64_t, shaped_text_get_ellipsis_glyph_count, const RID &); |
| 1099 |
|
| 1100 |
MODBIND3(shaped_text_overrun_trim_to_width, const RID &, double, BitField<TextServer::TextOverrunFlag>); |
| 1101 |
|
| 1102 |
MODBIND1RC(bool, shaped_text_is_ready, const RID &); |
| 1103 |
|
| 1104 |
MODBIND1RC(const Glyph *, shaped_text_get_glyphs, const RID &); |
| 1105 |
MODBIND1R(const Glyph *, shaped_text_sort_logical, const RID &); |
| 1106 |
MODBIND1RC(int64_t, shaped_text_get_glyph_count, const RID &); |
| 1107 |
|
| 1108 |
MODBIND1RC(Vector2i, shaped_text_get_range, const RID &); |
| 1109 |
|
| 1110 |
MODBIND1RC(Array, shaped_text_get_objects, const RID &); |
| 1111 |
MODBIND2RC(Rect2, shaped_text_get_object_rect, const RID &, const Variant &); |
| 1112 |
MODBIND2RC(Vector2i, shaped_text_get_object_range, const RID &, const Variant &); |
| 1113 |
MODBIND2RC(int64_t, shaped_text_get_object_glyph, const RID &, const Variant &); |
| 1114 |
|
| 1115 |
MODBIND1RC(Size2, shaped_text_get_size, const RID &); |
| 1116 |
MODBIND1RC(double, shaped_text_get_ascent, const RID &); |
| 1117 |
MODBIND1RC(double, shaped_text_get_descent, const RID &); |
| 1118 |
MODBIND1RC(double, shaped_text_get_width, const RID &); |
| 1119 |
MODBIND1RC(double, shaped_text_get_underline_position, const RID &); |
| 1120 |
MODBIND1RC(double, shaped_text_get_underline_thickness, const RID &); |
| 1121 |
|
| 1122 |
MODBIND1RC(PackedInt32Array, shaped_text_get_character_breaks, const RID &); |
| 1123 |
|
| 1124 |
MODBIND3RC(PackedInt32Array, string_get_word_breaks, const String &, const String &, int64_t); |
| 1125 |
MODBIND2RC(PackedInt32Array, string_get_character_breaks, const String &, const String &); |
| 1126 |
|
| 1127 |
MODBIND2RC(int64_t, is_confusable, const String &, const PackedStringArray &); |
| 1128 |
MODBIND1RC(bool, spoof_check, const String &); |
| 1129 |
|
| 1130 |
MODBIND1RC(String, strip_diacritics, const String &); |
| 1131 |
MODBIND1RC(bool, is_valid_identifier, const String &); |
| 1132 |
MODBIND1RC(bool, is_valid_letter, uint64_t); |
| 1133 |
|
| 1134 |
MODBIND2RC(String, string_to_upper, const String &, const String &); |
| 1135 |
MODBIND2RC(String, string_to_lower, const String &, const String &); |
| 1136 |
MODBIND2RC(String, string_to_title, const String &, const String &); |
| 1137 |
|
| 1138 |
MODBIND0(cleanup); |
| 1139 |
|
| 1140 |
TextServerAdvanced(); |
| 1141 |
~TextServerAdvanced(); |
| 1142 |
}; |