Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/text_server_adv/text_server_adv.h
10277 views
1
/**************************************************************************/
2
/* text_server_adv.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
/*************************************************************************/
34
/* ICU/HarfBuzz/Graphite backed Text Server implementation with BiDi, */
35
/* shaping and advanced font features support. */
36
/*************************************************************************/
37
38
#include "script_iterator.h"
39
40
#ifdef GDEXTENSION
41
// Headers for building as GDExtension plug-in.
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
// Headers for building as built-in module.
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" // For freetype, msdfgen, svg.
92
93
#endif
94
95
// Thirdparty headers.
96
97
#include <unicode/ubidi.h>
98
#include <unicode/ubrk.h>
99
#include <unicode/uchar.h>
100
#include <unicode/uclean.h>
101
#include <unicode/udata.h>
102
#include <unicode/uiter.h>
103
#include <unicode/uloc.h>
104
#include <unicode/unorm2.h>
105
#include <unicode/uscript.h>
106
#include <unicode/uspoof.h>
107
#include <unicode/ustring.h>
108
#include <unicode/utypes.h>
109
110
#ifdef MODULE_FREETYPE_ENABLED
111
#include <ft2build.h>
112
#include FT_FREETYPE_H
113
#include FT_TRUETYPE_TABLES_H
114
#include FT_STROKER_H
115
#include FT_ADVANCES_H
116
#include FT_MULTIPLE_MASTERS_H
117
#include FT_BBOX_H
118
#include FT_MODULE_H
119
#include FT_CONFIG_OPTIONS_H
120
#if !defined(FT_CONFIG_OPTION_USE_BROTLI) && !defined(_MSC_VER)
121
#warning FreeType is configured without Brotli support, built-in fonts will not be available.
122
#endif
123
#include <hb-ft.h>
124
#include <hb-ot.h>
125
#endif
126
127
#include <hb-icu.h>
128
#include <hb.h>
129
130
/*************************************************************************/
131
132
class TextServerAdvanced : public TextServerExtension {
133
GDCLASS(TextServerAdvanced, TextServerExtension);
134
_THREAD_SAFE_CLASS_
135
136
struct NumSystemData {
137
HashSet<StringName> lang;
138
String digits;
139
String percent_sign;
140
String exp_l;
141
String exp_u;
142
};
143
144
Vector<NumSystemData> num_systems;
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_num_systems_lang();
167
void _insert_feature_sets();
168
_FORCE_INLINE_ void _insert_feature(const StringName &p_name, int32_t p_tag, Variant::Type p_vtype = Variant::INT, bool p_hidden = false);
169
170
// ICU support data.
171
172
static bool icu_data_loaded;
173
static PackedByteArray icu_data;
174
mutable USet *allowed = nullptr;
175
mutable USpoofChecker *sc_spoof = nullptr;
176
mutable USpoofChecker *sc_conf = nullptr;
177
178
mutable HashMap<String, UBreakIterator *> line_break_iterators_per_language;
179
180
UBreakIterator *_create_line_break_iterator_for_locale(const String &p_language, UErrorCode *r_err) const;
181
182
// Font cache data.
183
184
#ifdef MODULE_FREETYPE_ENABLED
185
mutable FT_Library ft_library = nullptr;
186
#endif
187
188
const int rect_range = 1;
189
190
struct FontTexturePosition {
191
int32_t index = -1;
192
int32_t x = 0;
193
int32_t y = 0;
194
195
FontTexturePosition() {}
196
FontTexturePosition(int32_t p_id, int32_t p_x, int32_t p_y) :
197
index(p_id), x(p_x), y(p_y) {}
198
};
199
200
struct Shelf {
201
int32_t x = 0;
202
int32_t y = 0;
203
int32_t w = 0;
204
int32_t h = 0;
205
206
FontTexturePosition alloc_shelf(int32_t p_id, int32_t p_w, int32_t p_h) {
207
if (p_w > w || p_h > h) {
208
return FontTexturePosition(-1, 0, 0);
209
}
210
int32_t xx = x;
211
x += p_w;
212
w -= p_w;
213
return FontTexturePosition(p_id, xx, y);
214
}
215
216
Shelf() {}
217
Shelf(int32_t p_x, int32_t p_y, int32_t p_w, int32_t p_h) :
218
x(p_x), y(p_y), w(p_w), h(p_h) {}
219
};
220
221
struct ShelfPackTexture {
222
int32_t texture_w = 1024;
223
int32_t texture_h = 1024;
224
225
Ref<Image> image;
226
Ref<ImageTexture> texture;
227
bool dirty = true;
228
229
List<Shelf> shelves;
230
231
FontTexturePosition pack_rect(int32_t p_id, int32_t p_h, int32_t p_w) {
232
int32_t y = 0;
233
int32_t waste = 0;
234
Shelf *best_shelf = nullptr;
235
int32_t best_waste = std::numeric_limits<std::int32_t>::max();
236
237
for (Shelf &E : shelves) {
238
y += E.h;
239
if (p_w > E.w) {
240
continue;
241
}
242
if (p_h == E.h) {
243
return E.alloc_shelf(p_id, p_w, p_h);
244
}
245
if (p_h > E.h) {
246
continue;
247
}
248
if (p_h < E.h) {
249
waste = (E.h - p_h) * p_w;
250
if (waste < best_waste) {
251
best_waste = waste;
252
best_shelf = &E;
253
}
254
}
255
}
256
if (best_shelf) {
257
return best_shelf->alloc_shelf(p_id, p_w, p_h);
258
}
259
if (p_h <= (texture_h - y) && p_w <= texture_w) {
260
List<Shelf>::Element *E = shelves.push_back(Shelf(0, y, texture_w, p_h));
261
return E->get().alloc_shelf(p_id, p_w, p_h);
262
}
263
return FontTexturePosition(-1, 0, 0);
264
}
265
266
ShelfPackTexture() {}
267
ShelfPackTexture(int32_t p_w, int32_t p_h) :
268
texture_w(p_w), texture_h(p_h) {}
269
};
270
271
struct FontGlyph {
272
bool found = false;
273
int texture_idx = -1;
274
Rect2 rect;
275
Rect2 uv_rect;
276
Vector2 advance;
277
bool from_svg = false;
278
};
279
280
struct FontAdvanced;
281
struct FontForSizeAdvanced {
282
double ascent = 0.0;
283
double descent = 0.0;
284
double underline_position = 0.0;
285
double underline_thickness = 0.0;
286
double scale = 1.0;
287
288
FontAdvanced *owner = nullptr;
289
uint32_t viewport_oversampling = 0;
290
291
Vector2i size;
292
293
Vector<ShelfPackTexture> textures;
294
HashMap<int64_t, int64_t> inv_glyph_map;
295
HashMap<int32_t, FontGlyph> glyph_map;
296
HashMap<Vector2i, Vector2> kerning_map;
297
hb_font_t *hb_handle = nullptr;
298
299
#ifdef MODULE_FREETYPE_ENABLED
300
FT_Face face = nullptr;
301
FT_StreamRec stream;
302
#endif
303
304
~FontForSizeAdvanced() {
305
if (hb_handle != nullptr) {
306
hb_font_destroy(hb_handle);
307
}
308
#ifdef MODULE_FREETYPE_ENABLED
309
if (face != nullptr) {
310
FT_Done_Face(face);
311
}
312
#endif
313
}
314
};
315
316
struct OversamplingLevel {
317
HashSet<FontForSizeAdvanced *> fonts;
318
int32_t refcount = 1;
319
};
320
321
mutable HashMap<uint32_t, OversamplingLevel> oversampling_levels;
322
323
struct FontAdvancedLinkedVariation {
324
RID base_font;
325
int extra_spacing[4] = { 0, 0, 0, 0 };
326
double baseline_offset = 0.0;
327
};
328
329
struct FontAdvanced {
330
Mutex mutex;
331
332
TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY;
333
bool disable_embedded_bitmaps = true;
334
bool mipmaps = false;
335
bool msdf = false;
336
int msdf_range = 14;
337
FixedSizeScaleMode fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE;
338
int msdf_source_size = 48;
339
int fixed_size = 0;
340
bool allow_system_fallback = true;
341
bool force_autohinter = false;
342
bool modulate_color_glyphs = false;
343
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
344
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
345
bool keep_rounding_remainders = true;
346
Dictionary variation_coordinates;
347
double oversampling_override = 0.0;
348
double embolden = 0.0;
349
Transform2D transform;
350
351
BitField<TextServer::FontStyle> style_flags = 0;
352
String font_name;
353
String style_name;
354
int weight = 400;
355
int stretch = 100;
356
int extra_spacing[4] = { 0, 0, 0, 0 };
357
double baseline_offset = 0.0;
358
359
HashMap<Vector2i, FontForSizeAdvanced *> cache;
360
361
bool face_init = false;
362
HashSet<uint32_t> supported_scripts;
363
Dictionary supported_features;
364
Dictionary supported_varaitions;
365
Dictionary feature_overrides;
366
367
// Language/script support override.
368
HashMap<String, bool> language_support_overrides;
369
HashMap<String, bool> script_support_overrides;
370
371
PackedByteArray data;
372
const uint8_t *data_ptr;
373
size_t data_size;
374
int face_index = 0;
375
376
~FontAdvanced() {
377
for (const KeyValue<Vector2i, FontForSizeAdvanced *> &E : cache) {
378
memdelete(E.value);
379
}
380
cache.clear();
381
}
382
};
383
384
_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;
385
#ifdef MODULE_MSDFGEN_ENABLED
386
_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;
387
#endif
388
#ifdef MODULE_FREETYPE_ENABLED
389
_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;
390
#endif
391
bool _ensure_glyph(FontAdvanced *p_font_data, const Vector2i &p_size, int32_t p_glyph, FontGlyph &r_glyph, uint32_t p_oversampling = 0) const;
392
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;
393
_FORCE_INLINE_ bool _font_validate(const RID &p_font_rid) const;
394
_FORCE_INLINE_ void _font_clear_cache(FontAdvanced *p_font_data);
395
static void _generateMTSDF_threaded(void *p_td, uint32_t p_y);
396
397
_FORCE_INLINE_ Vector2i _get_size(const FontAdvanced *p_font_data, int p_size) const {
398
if (p_font_data->msdf) {
399
return Vector2i(p_font_data->msdf_source_size * 64, 0);
400
} else if (p_font_data->fixed_size > 0) {
401
return Vector2i(p_font_data->fixed_size * 64, 0);
402
} else {
403
return Vector2i(p_size * 64, 0);
404
}
405
}
406
407
_FORCE_INLINE_ Vector2i _get_size_outline(const FontAdvanced *p_font_data, const Vector2i &p_size) const {
408
if (p_font_data->msdf) {
409
return Vector2i(p_font_data->msdf_source_size * 64, 0);
410
} else if (p_font_data->fixed_size > 0) {
411
return Vector2i(p_font_data->fixed_size * 64, MIN(p_size.y, 1));
412
} else {
413
return Vector2i(p_size.x * 64, p_size.y);
414
}
415
}
416
417
_FORCE_INLINE_ double _get_extra_advance(RID p_font_rid, int p_font_size) const;
418
_FORCE_INLINE_ Variant::Type _get_tag_type(int64_t p_tag) const;
419
_FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const;
420
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
421
String sty_name = p_sty_name.remove_chars(" -");
422
if (sty_name.contains("thin") || sty_name.contains("hairline")) {
423
return 100;
424
} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
425
return 200;
426
} else if (sty_name.contains("light")) {
427
return 300;
428
} else if (sty_name.contains("semilight")) {
429
return 350;
430
} else if (sty_name.contains("regular")) {
431
return 400;
432
} else if (sty_name.contains("medium")) {
433
return 500;
434
} else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {
435
return 600;
436
} else if (sty_name.contains("bold")) {
437
return 700;
438
} else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {
439
return 800;
440
} else if (sty_name.contains("black") || sty_name.contains("heavy")) {
441
return 900;
442
} else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {
443
return 950;
444
}
445
return 400;
446
}
447
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
448
String sty_name = p_sty_name.remove_chars(" -");
449
if (sty_name.contains("ultracondensed")) {
450
return 50;
451
} else if (sty_name.contains("extracondensed")) {
452
return 63;
453
} else if (sty_name.contains("condensed")) {
454
return 75;
455
} else if (sty_name.contains("semicondensed")) {
456
return 87;
457
} else if (sty_name.contains("semiexpanded")) {
458
return 113;
459
} else if (sty_name.contains("expanded")) {
460
return 125;
461
} else if (sty_name.contains("extraexpanded")) {
462
return 150;
463
} else if (sty_name.contains("ultraexpanded")) {
464
return 200;
465
}
466
return 100;
467
}
468
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {
469
return p_sty_name.contains("italic") || p_sty_name.contains("oblique");
470
}
471
472
// Shaped text cache data.
473
struct TrimData {
474
int trim_pos = -1;
475
int ellipsis_pos = -1;
476
Vector<Glyph> ellipsis_glyph_buf;
477
};
478
479
struct TextRun {
480
Vector2i 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
/* Source data */
491
RID parent; // Substring parent ShapedTextData.
492
493
int start = 0; // Substring start offset in the parent string.
494
int end = 0; // Substring end offset in the parent string.
495
496
String text;
497
String custom_punct;
498
TextServer::Direction direction = DIRECTION_LTR; // Desired text direction.
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; // First span in the parent ShapedTextData.
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, VariantHasher, VariantComparator> objects;
529
530
/* Shaped data */
531
TextServer::Direction para_direction = DIRECTION_LTR; // Detected text direction.
532
int base_para_direction = UBIDI_DEFAULT_LTR;
533
SafeFlag valid{ false }; // String is shaped.
534
bool line_breaks_valid = false; // Line and word break flags are populated (and virtual zero width spaces inserted).
535
bool justification_ops_valid = false; // Virtual elongation glyphs are added to the string.
536
bool sort_valid = false;
537
bool text_trimmed = false;
538
539
bool preserve_invalid = true; // Draw hex code box instead of missing characters.
540
bool preserve_control = false; // Draw control characters.
541
542
double ascent = 0.0; // Ascent for horizontal layout, 1/2 of width for vertical.
543
double descent = 0.0; // Descent for horizontal layout, 1/2 of width for vertical.
544
double width = 0.0; // Width for horizontal layout, height for vertical.
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
/* Intermediate data */
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
// Common data.
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
void _shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_end, hb_script_t p_script, hb_direction_t p_direction, TypedArray<RID> 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);
699
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);
700
_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);
701
702
_FORCE_INLINE_ void _add_features(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs);
703
704
Mutex ft_mutex;
705
706
// HarfBuzz bitmap font interface.
707
708
static hb_font_funcs_t *funcs;
709
710
struct bmp_font_t {
711
TextServerAdvanced::FontForSizeAdvanced *face = nullptr;
712
bool unref = false; /* Whether to destroy bm_face when done. */
713
};
714
715
static bmp_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref);
716
static void _bmp_font_destroy(void *p_data);
717
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);
718
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);
719
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);
720
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);
721
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);
722
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);
723
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);
724
static void _bmp_create_font_funcs();
725
static void _bmp_free_font_funcs();
726
static void _bmp_font_set_funcs(hb_font_t *p_font, TextServerAdvanced::FontForSizeAdvanced *p_face, bool p_unref);
727
static hb_font_t *_bmp_font_create(TextServerAdvanced::FontForSizeAdvanced *p_face, hb_destroy_func_t p_destroy);
728
729
hb_font_t *_font_get_hb_handle(const RID &p_font, int64_t p_font_size) const;
730
731
struct GlyphCompare { // For line breaking reordering.
732
_FORCE_INLINE_ bool operator()(const Glyph &l, const Glyph &r) const {
733
if (l.start == r.start) {
734
if (l.count == r.count) {
735
return (l.flags & TextServer::GRAPHEME_IS_VIRTUAL) < (r.flags & TextServer::GRAPHEME_IS_VIRTUAL);
736
}
737
return l.count > r.count; // Sort first glyph with count & flags, order of the rest are irrelevant.
738
} else {
739
return l.start < r.start;
740
}
741
}
742
};
743
744
protected:
745
static void _bind_methods() {}
746
747
void full_copy(ShapedTextDataAdvanced *p_shaped);
748
void invalidate(ShapedTextDataAdvanced *p_shaped, bool p_text = false);
749
750
public:
751
MODBIND1RC(bool, has_feature, Feature);
752
MODBIND0RC(String, get_name);
753
MODBIND0RC(int64_t, get_features);
754
755
MODBIND1(free_rid, const RID &);
756
MODBIND1R(bool, has, const RID &);
757
MODBIND1R(bool, load_support_data, const String &);
758
759
MODBIND0RC(String, get_support_data_filename);
760
MODBIND0RC(String, get_support_data_info);
761
MODBIND1RC(bool, save_support_data, const String &);
762
MODBIND0RC(PackedByteArray, get_support_data);
763
764
MODBIND1RC(bool, is_locale_right_to_left, const String &);
765
766
MODBIND1RC(int64_t, name_to_tag, const String &);
767
MODBIND1RC(String, tag_to_name, int64_t);
768
769
/* Font interface */
770
771
MODBIND0R(RID, create_font);
772
MODBIND1R(RID, create_font_linked_variation, const RID &);
773
774
MODBIND2(font_set_data, const RID &, const PackedByteArray &);
775
MODBIND3(font_set_data_ptr, const RID &, const uint8_t *, int64_t);
776
777
MODBIND2(font_set_face_index, const RID &, int64_t);
778
MODBIND1RC(int64_t, font_get_face_index, const RID &);
779
780
MODBIND1RC(int64_t, font_get_face_count, const RID &);
781
782
MODBIND2(font_set_style, const RID &, BitField<FontStyle>);
783
MODBIND1RC(BitField<FontStyle>, font_get_style, const RID &);
784
785
MODBIND2(font_set_style_name, const RID &, const String &);
786
MODBIND1RC(String, font_get_style_name, const RID &);
787
788
MODBIND2(font_set_weight, const RID &, int64_t);
789
MODBIND1RC(int64_t, font_get_weight, const RID &);
790
791
MODBIND2(font_set_stretch, const RID &, int64_t);
792
MODBIND1RC(int64_t, font_get_stretch, const RID &);
793
794
MODBIND2(font_set_name, const RID &, const String &);
795
MODBIND1RC(String, font_get_name, const RID &);
796
MODBIND1RC(Dictionary, font_get_ot_name_strings, const RID &);
797
798
MODBIND2(font_set_antialiasing, const RID &, TextServer::FontAntialiasing);
799
MODBIND1RC(TextServer::FontAntialiasing, font_get_antialiasing, const RID &);
800
801
MODBIND2(font_set_disable_embedded_bitmaps, const RID &, bool);
802
MODBIND1RC(bool, font_get_disable_embedded_bitmaps, const RID &);
803
804
MODBIND2(font_set_generate_mipmaps, const RID &, bool);
805
MODBIND1RC(bool, font_get_generate_mipmaps, const RID &);
806
807
MODBIND2(font_set_multichannel_signed_distance_field, const RID &, bool);
808
MODBIND1RC(bool, font_is_multichannel_signed_distance_field, const RID &);
809
810
MODBIND2(font_set_msdf_pixel_range, const RID &, int64_t);
811
MODBIND1RC(int64_t, font_get_msdf_pixel_range, const RID &);
812
813
MODBIND2(font_set_msdf_size, const RID &, int64_t);
814
MODBIND1RC(int64_t, font_get_msdf_size, const RID &);
815
816
MODBIND2(font_set_fixed_size, const RID &, int64_t);
817
MODBIND1RC(int64_t, font_get_fixed_size, const RID &);
818
819
MODBIND2(font_set_fixed_size_scale_mode, const RID &, FixedSizeScaleMode);
820
MODBIND1RC(FixedSizeScaleMode, font_get_fixed_size_scale_mode, const RID &);
821
822
MODBIND2(font_set_allow_system_fallback, const RID &, bool);
823
MODBIND1RC(bool, font_is_allow_system_fallback, const RID &);
824
MODBIND0(font_clear_system_fallback_cache);
825
826
MODBIND2(font_set_force_autohinter, const RID &, bool);
827
MODBIND1RC(bool, font_is_force_autohinter, const RID &);
828
829
MODBIND2(font_set_modulate_color_glyphs, const RID &, bool);
830
MODBIND1RC(bool, font_is_modulate_color_glyphs, const RID &);
831
832
MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning);
833
MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &);
834
835
MODBIND2(font_set_keep_rounding_remainders, const RID &, bool);
836
MODBIND1RC(bool, font_get_keep_rounding_remainders, const RID &);
837
838
MODBIND2(font_set_embolden, const RID &, double);
839
MODBIND1RC(double, font_get_embolden, const RID &);
840
841
MODBIND3(font_set_spacing, const RID &, SpacingType, int64_t);
842
MODBIND2RC(int64_t, font_get_spacing, const RID &, SpacingType);
843
844
MODBIND2(font_set_baseline_offset, const RID &, double);
845
MODBIND1RC(double, font_get_baseline_offset, const RID &);
846
847
MODBIND2(font_set_transform, const RID &, const Transform2D &);
848
MODBIND1RC(Transform2D, font_get_transform, const RID &);
849
850
MODBIND2(font_set_variation_coordinates, const RID &, const Dictionary &);
851
MODBIND1RC(Dictionary, font_get_variation_coordinates, const RID &);
852
853
MODBIND2(font_set_oversampling, const RID &, double);
854
MODBIND1RC(double, font_get_oversampling, const RID &);
855
856
MODBIND2(font_set_hinting, const RID &, TextServer::Hinting);
857
MODBIND1RC(TextServer::Hinting, font_get_hinting, const RID &);
858
859
MODBIND1RC(TypedArray<Vector2i>, font_get_size_cache_list, const RID &);
860
MODBIND1(font_clear_size_cache, const RID &);
861
MODBIND2(font_remove_size_cache, const RID &, const Vector2i &);
862
MODBIND1RC(TypedArray<Dictionary>, font_get_size_cache_info, const RID &);
863
864
MODBIND3(font_set_ascent, const RID &, int64_t, double);
865
MODBIND2RC(double, font_get_ascent, const RID &, int64_t);
866
867
MODBIND3(font_set_descent, const RID &, int64_t, double);
868
MODBIND2RC(double, font_get_descent, const RID &, int64_t);
869
870
MODBIND3(font_set_underline_position, const RID &, int64_t, double);
871
MODBIND2RC(double, font_get_underline_position, const RID &, int64_t);
872
873
MODBIND3(font_set_underline_thickness, const RID &, int64_t, double);
874
MODBIND2RC(double, font_get_underline_thickness, const RID &, int64_t);
875
876
MODBIND3(font_set_scale, const RID &, int64_t, double);
877
MODBIND2RC(double, font_get_scale, const RID &, int64_t);
878
879
MODBIND2RC(int64_t, font_get_texture_count, const RID &, const Vector2i &);
880
MODBIND2(font_clear_textures, const RID &, const Vector2i &);
881
MODBIND3(font_remove_texture, const RID &, const Vector2i &, int64_t);
882
883
MODBIND4(font_set_texture_image, const RID &, const Vector2i &, int64_t, const Ref<Image> &);
884
MODBIND3RC(Ref<Image>, font_get_texture_image, const RID &, const Vector2i &, int64_t);
885
886
MODBIND4(font_set_texture_offsets, const RID &, const Vector2i &, int64_t, const PackedInt32Array &);
887
MODBIND3RC(PackedInt32Array, font_get_texture_offsets, const RID &, const Vector2i &, int64_t);
888
889
MODBIND2RC(PackedInt32Array, font_get_glyph_list, const RID &, const Vector2i &);
890
MODBIND2(font_clear_glyphs, const RID &, const Vector2i &);
891
MODBIND3(font_remove_glyph, const RID &, const Vector2i &, int64_t);
892
893
MODBIND3RC(Vector2, font_get_glyph_advance, const RID &, int64_t, int64_t);
894
MODBIND4(font_set_glyph_advance, const RID &, int64_t, int64_t, const Vector2 &);
895
896
MODBIND3RC(Vector2, font_get_glyph_offset, const RID &, const Vector2i &, int64_t);
897
MODBIND4(font_set_glyph_offset, const RID &, const Vector2i &, int64_t, const Vector2 &);
898
899
MODBIND3RC(Vector2, font_get_glyph_size, const RID &, const Vector2i &, int64_t);
900
MODBIND4(font_set_glyph_size, const RID &, const Vector2i &, int64_t, const Vector2 &);
901
902
MODBIND3RC(Rect2, font_get_glyph_uv_rect, const RID &, const Vector2i &, int64_t);
903
MODBIND4(font_set_glyph_uv_rect, const RID &, const Vector2i &, int64_t, const Rect2 &);
904
905
MODBIND3RC(int64_t, font_get_glyph_texture_idx, const RID &, const Vector2i &, int64_t);
906
MODBIND4(font_set_glyph_texture_idx, const RID &, const Vector2i &, int64_t, int64_t);
907
908
MODBIND3RC(RID, font_get_glyph_texture_rid, const RID &, const Vector2i &, int64_t);
909
MODBIND3RC(Size2, font_get_glyph_texture_size, const RID &, const Vector2i &, int64_t);
910
911
MODBIND3RC(Dictionary, font_get_glyph_contours, const RID &, int64_t, int64_t);
912
913
MODBIND2RC(TypedArray<Vector2i>, font_get_kerning_list, const RID &, int64_t);
914
MODBIND2(font_clear_kerning_map, const RID &, int64_t);
915
MODBIND3(font_remove_kerning, const RID &, int64_t, const Vector2i &);
916
917
MODBIND4(font_set_kerning, const RID &, int64_t, const Vector2i &, const Vector2 &);
918
MODBIND3RC(Vector2, font_get_kerning, const RID &, int64_t, const Vector2i &);
919
920
MODBIND4RC(int64_t, font_get_glyph_index, const RID &, int64_t, int64_t, int64_t);
921
MODBIND3RC(int64_t, font_get_char_from_glyph_index, const RID &, int64_t, int64_t);
922
923
MODBIND2RC(bool, font_has_char, const RID &, int64_t);
924
MODBIND1RC(String, font_get_supported_chars, const RID &);
925
MODBIND1RC(PackedInt32Array, font_get_supported_glyphs, const RID &);
926
927
MODBIND4(font_render_range, const RID &, const Vector2i &, int64_t, int64_t);
928
MODBIND3(font_render_glyph, const RID &, const Vector2i &, int64_t);
929
930
MODBIND7C(font_draw_glyph, const RID &, const RID &, int64_t, const Vector2 &, int64_t, const Color &, float);
931
MODBIND8C(font_draw_glyph_outline, const RID &, const RID &, int64_t, int64_t, const Vector2 &, int64_t, const Color &, float);
932
933
MODBIND2RC(bool, font_is_language_supported, const RID &, const String &);
934
MODBIND3(font_set_language_support_override, const RID &, const String &, bool);
935
MODBIND2R(bool, font_get_language_support_override, const RID &, const String &);
936
MODBIND2(font_remove_language_support_override, const RID &, const String &);
937
MODBIND1R(PackedStringArray, font_get_language_support_overrides, const RID &);
938
939
MODBIND2RC(bool, font_is_script_supported, const RID &, const String &);
940
MODBIND3(font_set_script_support_override, const RID &, const String &, bool);
941
MODBIND2R(bool, font_get_script_support_override, const RID &, const String &);
942
MODBIND2(font_remove_script_support_override, const RID &, const String &);
943
MODBIND1R(PackedStringArray, font_get_script_support_overrides, const RID &);
944
945
MODBIND2(font_set_opentype_feature_overrides, const RID &, const Dictionary &);
946
MODBIND1RC(Dictionary, font_get_opentype_feature_overrides, const RID &);
947
948
MODBIND1RC(Dictionary, font_supported_feature_list, const RID &);
949
MODBIND1RC(Dictionary, font_supported_variation_list, const RID &);
950
951
MODBIND1(reference_oversampling_level, double);
952
MODBIND1(unreference_oversampling_level, double);
953
954
/* Shaped text buffer interface */
955
956
MODBIND2R(RID, create_shaped_text, Direction, Orientation);
957
958
MODBIND1(shaped_text_clear, const RID &);
959
960
MODBIND2(shaped_text_set_direction, const RID &, Direction);
961
MODBIND1RC(Direction, shaped_text_get_direction, const RID &);
962
MODBIND1RC(Direction, shaped_text_get_inferred_direction, const RID &);
963
964
MODBIND2(shaped_text_set_bidi_override, const RID &, const Array &);
965
966
MODBIND2(shaped_text_set_custom_punctuation, const RID &, const String &);
967
MODBIND1RC(String, shaped_text_get_custom_punctuation, const RID &);
968
969
MODBIND2(shaped_text_set_custom_ellipsis, const RID &, int64_t);
970
MODBIND1RC(int64_t, shaped_text_get_custom_ellipsis, const RID &);
971
972
MODBIND2(shaped_text_set_orientation, const RID &, Orientation);
973
MODBIND1RC(Orientation, shaped_text_get_orientation, const RID &);
974
975
MODBIND2(shaped_text_set_preserve_invalid, const RID &, bool);
976
MODBIND1RC(bool, shaped_text_get_preserve_invalid, const RID &);
977
978
MODBIND2(shaped_text_set_preserve_control, const RID &, bool);
979
MODBIND1RC(bool, shaped_text_get_preserve_control, const RID &);
980
981
MODBIND3(shaped_text_set_spacing, const RID &, SpacingType, int64_t);
982
MODBIND2RC(int64_t, shaped_text_get_spacing, const RID &, SpacingType);
983
984
MODBIND7R(bool, shaped_text_add_string, const RID &, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);
985
MODBIND6R(bool, shaped_text_add_object, const RID &, const Variant &, const Size2 &, InlineAlignment, int64_t, double);
986
MODBIND5R(bool, shaped_text_resize_object, const RID &, const Variant &, const Size2 &, InlineAlignment, double);
987
MODBIND1RC(String, shaped_get_text, const RID &);
988
989
MODBIND1RC(int64_t, shaped_get_span_count, const RID &);
990
MODBIND2RC(Variant, shaped_get_span_meta, const RID &, int64_t);
991
MODBIND2RC(Variant, shaped_get_span_embedded_object, const RID &, int64_t);
992
MODBIND2RC(String, shaped_get_span_text, const RID &, int64_t);
993
MODBIND2RC(Variant, shaped_get_span_object, const RID &, int64_t);
994
MODBIND5(shaped_set_span_update_font, const RID &, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &);
995
996
MODBIND1RC(int64_t, shaped_get_run_count, const RID &);
997
MODBIND2RC(String, shaped_get_run_text, const RID &, int64_t);
998
MODBIND2RC(Vector2i, shaped_get_run_range, const RID &, int64_t);
999
MODBIND2RC(RID, shaped_get_run_font_rid, const RID &, int64_t);
1000
MODBIND2RC(int, shaped_get_run_font_size, const RID &, int64_t);
1001
MODBIND2RC(String, shaped_get_run_language, const RID &, int64_t);
1002
MODBIND2RC(Direction, shaped_get_run_direction, const RID &, int64_t);
1003
MODBIND2RC(Variant, shaped_get_run_object, const RID &, int64_t);
1004
1005
MODBIND3RC(RID, shaped_text_substr, const RID &, int64_t, int64_t);
1006
MODBIND1RC(RID, shaped_text_get_parent, const RID &);
1007
1008
MODBIND3R(double, shaped_text_fit_to_width, const RID &, double, BitField<TextServer::JustificationFlag>);
1009
MODBIND2R(double, shaped_text_tab_align, const RID &, const PackedFloat32Array &);
1010
1011
MODBIND1R(bool, shaped_text_shape, const RID &);
1012
MODBIND1R(bool, shaped_text_update_breaks, const RID &);
1013
MODBIND1R(bool, shaped_text_update_justification_ops, const RID &);
1014
1015
MODBIND1RC(int64_t, shaped_text_get_trim_pos, const RID &);
1016
MODBIND1RC(int64_t, shaped_text_get_ellipsis_pos, const RID &);
1017
MODBIND1RC(const Glyph *, shaped_text_get_ellipsis_glyphs, const RID &);
1018
MODBIND1RC(int64_t, shaped_text_get_ellipsis_glyph_count, const RID &);
1019
1020
MODBIND3(shaped_text_overrun_trim_to_width, const RID &, double, BitField<TextServer::TextOverrunFlag>);
1021
1022
MODBIND1RC(bool, shaped_text_is_ready, const RID &);
1023
1024
MODBIND1RC(const Glyph *, shaped_text_get_glyphs, const RID &);
1025
MODBIND1R(const Glyph *, shaped_text_sort_logical, const RID &);
1026
MODBIND1RC(int64_t, shaped_text_get_glyph_count, const RID &);
1027
1028
MODBIND1RC(Vector2i, shaped_text_get_range, const RID &);
1029
1030
MODBIND1RC(Array, shaped_text_get_objects, const RID &);
1031
MODBIND2RC(Rect2, shaped_text_get_object_rect, const RID &, const Variant &);
1032
MODBIND2RC(Vector2i, shaped_text_get_object_range, const RID &, const Variant &);
1033
MODBIND2RC(int64_t, shaped_text_get_object_glyph, const RID &, const Variant &);
1034
1035
MODBIND1RC(Size2, shaped_text_get_size, const RID &);
1036
MODBIND1RC(double, shaped_text_get_ascent, const RID &);
1037
MODBIND1RC(double, shaped_text_get_descent, const RID &);
1038
MODBIND1RC(double, shaped_text_get_width, const RID &);
1039
MODBIND1RC(double, shaped_text_get_underline_position, const RID &);
1040
MODBIND1RC(double, shaped_text_get_underline_thickness, const RID &);
1041
1042
MODBIND1RC(PackedInt32Array, shaped_text_get_character_breaks, const RID &);
1043
1044
MODBIND2RC(String, format_number, const String &, const String &);
1045
MODBIND2RC(String, parse_number, const String &, const String &);
1046
MODBIND1RC(String, percent_sign, const String &);
1047
1048
MODBIND3RC(PackedInt32Array, string_get_word_breaks, const String &, const String &, int64_t);
1049
MODBIND2RC(PackedInt32Array, string_get_character_breaks, const String &, const String &);
1050
1051
MODBIND2RC(int64_t, is_confusable, const String &, const PackedStringArray &);
1052
MODBIND1RC(bool, spoof_check, const String &);
1053
1054
MODBIND1RC(String, strip_diacritics, const String &);
1055
MODBIND1RC(bool, is_valid_identifier, const String &);
1056
MODBIND1RC(bool, is_valid_letter, uint64_t);
1057
1058
MODBIND2RC(String, string_to_upper, const String &, const String &);
1059
MODBIND2RC(String, string_to_lower, const String &, const String &);
1060
MODBIND2RC(String, string_to_title, const String &, const String &);
1061
1062
MODBIND0(cleanup);
1063
1064
TextServerAdvanced();
1065
~TextServerAdvanced();
1066
};
1067
1068