diff options
Diffstat (limited to 'modules/text_server_adv/text_server_adv.cpp')
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 726 |
1 files changed, 435 insertions, 291 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index fd8b2caa0c..6d0a398218 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -338,6 +338,7 @@ _FORCE_INLINE_ bool is_connected_to_prev(char32_t p_chr, char32_t p_pchr) { /*************************************************************************/ bool TextServerAdvanced::icu_data_loaded = false; +PackedByteArray TextServerAdvanced::icu_data; bool TextServerAdvanced::_has_feature(Feature p_feature) const { switch (p_feature) { @@ -397,6 +398,14 @@ void TextServerAdvanced::_free_rid(const RID &p_rid) { font_owner.free(p_rid); } memdelete(fd); + } else if (font_var_owner.owns(p_rid)) { + MutexLock ftlock(ft_mutex); + + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_rid); + { + font_var_owner.free(p_rid); + } + memdelete(fdv); } else if (shaped_owner.owns(p_rid)) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_rid); { @@ -409,7 +418,7 @@ void TextServerAdvanced::_free_rid(const RID &p_rid) { bool TextServerAdvanced::_has(const RID &p_rid) { _THREAD_SAFE_METHOD_ - return font_owner.owns(p_rid) || shaped_owner.owns(p_rid); + return font_owner.owns(p_rid) || font_var_owner.owns(p_rid) || shaped_owner.owns(p_rid); } bool TextServerAdvanced::_load_support_data(const String &p_filename) { @@ -430,7 +439,7 @@ bool TextServerAdvanced::_load_support_data(const String &p_filename) { return false; } uint64_t len = f->get_length(); - PackedByteArray icu_data = f->get_buffer(len); + icu_data = f->get_buffer(len); UErrorCode err = U_ZERO_ERROR; udata_setCommonData(icu_data.ptr(), &err); @@ -468,10 +477,10 @@ bool TextServerAdvanced::_save_support_data(const String &p_filename) const { return false; } - PackedByteArray icu_data; - icu_data.resize(U_ICUDATA_SIZE); - memcpy(icu_data.ptrw(), U_ICUDATA_ENTRY_POINT, U_ICUDATA_SIZE); - f->store_buffer(icu_data); + PackedByteArray icu_data_static; + icu_data_static.resize(U_ICUDATA_SIZE); + memcpy(icu_data_static.ptrw(), U_ICUDATA_ENTRY_POINT, U_ICUDATA_SIZE); + f->store_buffer(icu_data_static); return true; #else @@ -1809,8 +1818,8 @@ _FORCE_INLINE_ void TextServerAdvanced::_font_clear_cache(FontAdvanced *p_font_d } hb_font_t *TextServerAdvanced::_font_get_hb_handle(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, nullptr); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, nullptr); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -1828,9 +1837,25 @@ RID TextServerAdvanced::_create_font() { return font_owner.make_rid(fd); } +RID TextServerAdvanced::_create_font_linked_variation(const RID &p_font_rid) { + _THREAD_SAFE_METHOD_ + + RID rid = p_font_rid; + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(rid); + if (unlikely(fdv)) { + rid = fdv->base_font; + } + ERR_FAIL_COND_V(!font_owner.owns(rid), RID()); + + FontAdvancedLinkedVariation *new_fdv = memnew(FontAdvancedLinkedVariation); + new_fdv->base_font = rid; + + return font_var_owner.make_rid(new_fdv); +} + void TextServerAdvanced::_font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); _font_clear_cache(fd); @@ -1840,8 +1865,8 @@ void TextServerAdvanced::_font_set_data(const RID &p_font_rid, const PackedByteA } void TextServerAdvanced::_font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); _font_clear_cache(fd); @@ -1854,8 +1879,8 @@ void TextServerAdvanced::_font_set_face_index(const RID &p_font_rid, int64_t p_f ERR_FAIL_COND(p_face_index < 0); ERR_FAIL_COND(p_face_index >= 0x7FFF); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->face_index != p_face_index) { @@ -1865,16 +1890,16 @@ void TextServerAdvanced::_font_set_face_index(const RID &p_font_rid, int64_t p_f } int64_t TextServerAdvanced::_font_get_face_index(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); return fd->face_index; } int64_t TextServerAdvanced::_font_get_face_count(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); int face_count = 0; @@ -1919,8 +1944,8 @@ int64_t TextServerAdvanced::_font_get_face_count(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1929,8 +1954,8 @@ void TextServerAdvanced::_font_set_style(const RID &p_font_rid, BitField<FontSty } BitField<TextServer::FontStyle> TextServerAdvanced::_font_get_style(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1939,8 +1964,8 @@ BitField<TextServer::FontStyle> TextServerAdvanced::_font_get_style(const RID &p } void TextServerAdvanced::_font_set_style_name(const RID &p_font_rid, const String &p_name) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1949,8 +1974,8 @@ void TextServerAdvanced::_font_set_style_name(const RID &p_font_rid, const Strin } String TextServerAdvanced::_font_get_style_name(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, String()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1959,8 +1984,8 @@ String TextServerAdvanced::_font_get_style_name(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_weight(const RID &p_font_rid, int64_t p_weight) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1969,8 +1994,8 @@ void TextServerAdvanced::_font_set_weight(const RID &p_font_rid, int64_t p_weigh } int64_t TextServerAdvanced::_font_get_weight(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 400); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 400); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1979,8 +2004,8 @@ int64_t TextServerAdvanced::_font_get_weight(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_stretch(const RID &p_font_rid, int64_t p_stretch) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1989,8 +2014,8 @@ void TextServerAdvanced::_font_set_stretch(const RID &p_font_rid, int64_t p_stre } int64_t TextServerAdvanced::_font_get_stretch(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 100); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 100); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -1999,8 +2024,8 @@ int64_t TextServerAdvanced::_font_get_stretch(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_name(const RID &p_font_rid, const String &p_name) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -2009,8 +2034,8 @@ void TextServerAdvanced::_font_set_name(const RID &p_font_rid, const String &p_n } String TextServerAdvanced::_font_get_name(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, String()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -2019,8 +2044,8 @@ String TextServerAdvanced::_font_get_name(const RID &p_font_rid) const { } Dictionary TextServerAdvanced::_font_get_ot_name_strings(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -2132,8 +2157,8 @@ Dictionary TextServerAdvanced::_font_get_ot_name_strings(const RID &p_font_rid) } void TextServerAdvanced::_font_set_antialiasing(const RID &p_font_rid, TextServer::FontAntialiasing p_antialiasing) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->antialiasing != p_antialiasing) { @@ -2143,16 +2168,16 @@ void TextServerAdvanced::_font_set_antialiasing(const RID &p_font_rid, TextServe } TextServer::FontAntialiasing TextServerAdvanced::_font_get_antialiasing(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, TextServer::FONT_ANTIALIASING_NONE); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, TextServer::FONT_ANTIALIASING_NONE); MutexLock lock(fd->mutex); return fd->antialiasing; } void TextServerAdvanced::_font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->mipmaps != p_generate_mipmaps) { @@ -2167,16 +2192,16 @@ void TextServerAdvanced::_font_set_generate_mipmaps(const RID &p_font_rid, bool } bool TextServerAdvanced::_font_get_generate_mipmaps(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->mipmaps; } void TextServerAdvanced::_font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->msdf != p_msdf) { @@ -2186,16 +2211,16 @@ void TextServerAdvanced::_font_set_multichannel_signed_distance_field(const RID } bool TextServerAdvanced::_font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->msdf; } void TextServerAdvanced::_font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->msdf_range != p_msdf_pixel_range) { @@ -2205,16 +2230,16 @@ void TextServerAdvanced::_font_set_msdf_pixel_range(const RID &p_font_rid, int64 } int64_t TextServerAdvanced::_font_get_msdf_pixel_range(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->msdf_range; } void TextServerAdvanced::_font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->msdf_source_size != p_msdf_size) { @@ -2224,48 +2249,64 @@ void TextServerAdvanced::_font_set_msdf_size(const RID &p_font_rid, int64_t p_ms } int64_t TextServerAdvanced::_font_get_msdf_size(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); return fd->msdf_source_size; } void TextServerAdvanced::_font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->fixed_size = p_fixed_size; } int64_t TextServerAdvanced::_font_get_fixed_size(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); return fd->fixed_size; } +void TextServerAdvanced::_font_set_fixed_size_scale_mode(const RID &p_font_rid, TextServer::FixedSizeScaleMode p_fixed_size_scale_mode) { + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); + + MutexLock lock(fd->mutex); + fd->fixed_size_scale_mode = p_fixed_size_scale_mode; +} + +TextServer::FixedSizeScaleMode TextServerAdvanced::_font_get_fixed_size_scale_mode(const RID &p_font_rid) const { + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, FIXED_SIZE_SCALE_DISABLE); + + MutexLock lock(fd->mutex); + return fd->fixed_size_scale_mode; +} + void TextServerAdvanced::_font_set_allow_system_fallback(const RID &p_font_rid, bool p_allow_system_fallback) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->allow_system_fallback = p_allow_system_fallback; } bool TextServerAdvanced::_font_is_allow_system_fallback(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->allow_system_fallback; } void TextServerAdvanced::_font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->force_autohinter != p_force_autohinter) { @@ -2275,16 +2316,16 @@ void TextServerAdvanced::_font_set_force_autohinter(const RID &p_font_rid, bool } bool TextServerAdvanced::_font_is_force_autohinter(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->force_autohinter; } void TextServerAdvanced::_font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->hinting != p_hinting) { @@ -2294,32 +2335,32 @@ void TextServerAdvanced::_font_set_hinting(const RID &p_font_rid, TextServer::Hi } TextServer::Hinting TextServerAdvanced::_font_get_hinting(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, HINTING_NONE); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, HINTING_NONE); MutexLock lock(fd->mutex); return fd->hinting; } void TextServerAdvanced::_font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->subpixel_positioning = p_subpixel; } TextServer::SubpixelPositioning TextServerAdvanced::_font_get_subpixel_positioning(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, SUBPIXEL_POSITIONING_DISABLED); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, SUBPIXEL_POSITIONING_DISABLED); MutexLock lock(fd->mutex); return fd->subpixel_positioning; } void TextServerAdvanced::_font_set_embolden(const RID &p_font_rid, double p_strength) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->embolden != p_strength) { @@ -2329,8 +2370,8 @@ void TextServerAdvanced::_font_set_embolden(const RID &p_font_rid, double p_stre } double TextServerAdvanced::_font_get_embolden(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); return fd->embolden; @@ -2338,30 +2379,39 @@ double TextServerAdvanced::_font_get_embolden(const RID &p_font_rid) const { void TextServerAdvanced::_font_set_spacing(const RID &p_font_rid, SpacingType p_spacing, int64_t p_value) { ERR_FAIL_INDEX((int)p_spacing, 4); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + if (fdv->extra_spacing[p_spacing] != p_value) { + fdv->extra_spacing[p_spacing] = p_value; + } + } else { + FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL(fd); - MutexLock lock(fd->mutex); - if (fd->extra_spacing[p_spacing] != p_value) { - _font_clear_cache(fd); - fd->extra_spacing[p_spacing] = p_value; + MutexLock lock(fd->mutex); + if (fd->extra_spacing[p_spacing] != p_value) { + fd->extra_spacing[p_spacing] = p_value; + } } } int64_t TextServerAdvanced::_font_get_spacing(const RID &p_font_rid, SpacingType p_spacing) const { ERR_FAIL_INDEX_V((int)p_spacing, 4, 0); + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + return fdv->extra_spacing[p_spacing]; + } else { + FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); - - MutexLock lock(fd->mutex); - - return fd->extra_spacing[p_spacing]; + MutexLock lock(fd->mutex); + return fd->extra_spacing[p_spacing]; + } } void TextServerAdvanced::_font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->transform != p_transform) { @@ -2371,33 +2421,35 @@ void TextServerAdvanced::_font_set_transform(const RID &p_font_rid, const Transf } Transform2D TextServerAdvanced::_font_get_transform(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Transform2D()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Transform2D()); MutexLock lock(fd->mutex); return fd->transform; } void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); - _font_clear_cache(fd); - fd->variation_coordinates = p_variation_coordinates; + if (!fd->variation_coordinates.recursive_equal(p_variation_coordinates, 1)) { + _font_clear_cache(fd); + fd->variation_coordinates = p_variation_coordinates.duplicate(); + } } Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); return fd->variation_coordinates; } void TextServerAdvanced::_font_set_oversampling(const RID &p_font_rid, double p_oversampling) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); if (fd->oversampling != p_oversampling) { @@ -2407,16 +2459,16 @@ void TextServerAdvanced::_font_set_oversampling(const RID &p_font_rid, double p_ } double TextServerAdvanced::_font_get_oversampling(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); return fd->oversampling; } TypedArray<Vector2i> TextServerAdvanced::_font_get_size_cache_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, TypedArray<Vector2i>()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); TypedArray<Vector2i> ret; @@ -2427,8 +2479,8 @@ TypedArray<Vector2i> TextServerAdvanced::_font_get_size_cache_list(const RID &p_ } void TextServerAdvanced::_font_clear_size_cache(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); MutexLock ftlock(ft_mutex); @@ -2439,8 +2491,8 @@ void TextServerAdvanced::_font_clear_size_cache(const RID &p_font_rid) { } void TextServerAdvanced::_font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); MutexLock ftlock(ft_mutex); @@ -2451,8 +2503,8 @@ void TextServerAdvanced::_font_remove_size_cache(const RID &p_font_rid, const Ve } void TextServerAdvanced::_font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2462,8 +2514,8 @@ void TextServerAdvanced::_font_set_ascent(const RID &p_font_rid, int64_t p_size, } double TextServerAdvanced::_font_get_ascent(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2472,14 +2524,20 @@ double TextServerAdvanced::_font_get_ascent(const RID &p_font_rid, int64_t p_siz if (fd->msdf) { return fd->cache[size]->ascent * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return fd->cache[size]->ascent * (double)p_size / (double)fd->fixed_size; + } else { + return fd->cache[size]->ascent * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return fd->cache[size]->ascent; } } void TextServerAdvanced::_font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); Vector2i size = _get_size(fd, p_size); @@ -2488,8 +2546,8 @@ void TextServerAdvanced::_font_set_descent(const RID &p_font_rid, int64_t p_size } double TextServerAdvanced::_font_get_descent(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2498,14 +2556,20 @@ double TextServerAdvanced::_font_get_descent(const RID &p_font_rid, int64_t p_si if (fd->msdf) { return fd->cache[size]->descent * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return fd->cache[size]->descent * (double)p_size / (double)fd->fixed_size; + } else { + return fd->cache[size]->descent * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return fd->cache[size]->descent; } } void TextServerAdvanced::_font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2515,8 +2579,8 @@ void TextServerAdvanced::_font_set_underline_position(const RID &p_font_rid, int } double TextServerAdvanced::_font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2525,14 +2589,20 @@ double TextServerAdvanced::_font_get_underline_position(const RID &p_font_rid, i if (fd->msdf) { return fd->cache[size]->underline_position * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return fd->cache[size]->underline_position * (double)p_size / (double)fd->fixed_size; + } else { + return fd->cache[size]->underline_position * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return fd->cache[size]->underline_position; } } void TextServerAdvanced::_font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2542,8 +2612,8 @@ void TextServerAdvanced::_font_set_underline_thickness(const RID &p_font_rid, in } double TextServerAdvanced::_font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2552,14 +2622,20 @@ double TextServerAdvanced::_font_get_underline_thickness(const RID &p_font_rid, if (fd->msdf) { return fd->cache[size]->underline_thickness * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return fd->cache[size]->underline_thickness * (double)p_size / (double)fd->fixed_size; + } else { + return fd->cache[size]->underline_thickness * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return fd->cache[size]->underline_thickness; } } void TextServerAdvanced::_font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2574,8 +2650,8 @@ void TextServerAdvanced::_font_set_scale(const RID &p_font_rid, int64_t p_size, } double TextServerAdvanced::_font_get_scale(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2584,14 +2660,20 @@ double TextServerAdvanced::_font_get_scale(const RID &p_font_rid, int64_t p_size if (fd->msdf) { return fd->cache[size]->scale * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return fd->cache[size]->scale * (double)p_size / (double)fd->fixed_size; + } else { + return fd->cache[size]->scale * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return fd->cache[size]->scale / fd->cache[size]->oversampling; } } int64_t TextServerAdvanced::_font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2602,8 +2684,8 @@ int64_t TextServerAdvanced::_font_get_texture_count(const RID &p_font_rid, const } void TextServerAdvanced::_font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2612,8 +2694,8 @@ void TextServerAdvanced::_font_clear_textures(const RID &p_font_rid, const Vecto } void TextServerAdvanced::_font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2624,8 +2706,8 @@ void TextServerAdvanced::_font_remove_texture(const RID &p_font_rid, const Vecto } void TextServerAdvanced::_font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref<Image> &p_image) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); ERR_FAIL_COND(p_image.is_null()); MutexLock lock(fd->mutex); @@ -2653,8 +2735,8 @@ void TextServerAdvanced::_font_set_texture_image(const RID &p_font_rid, const Ve } Ref<Image> TextServerAdvanced::_font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Ref<Image>()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Ref<Image>()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2667,8 +2749,8 @@ Ref<Image> TextServerAdvanced::_font_get_texture_image(const RID &p_font_rid, co void TextServerAdvanced::_font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offsets) { ERR_FAIL_COND(p_offsets.size() % 4 != 0); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2686,8 +2768,8 @@ void TextServerAdvanced::_font_set_texture_offsets(const RID &p_font_rid, const } PackedInt32Array TextServerAdvanced::_font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, PackedInt32Array()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2711,8 +2793,8 @@ PackedInt32Array TextServerAdvanced::_font_get_texture_offsets(const RID &p_font } PackedInt32Array TextServerAdvanced::_font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, PackedInt32Array()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2727,8 +2809,8 @@ PackedInt32Array TextServerAdvanced::_font_get_glyph_list(const RID &p_font_rid, } void TextServerAdvanced::_font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2738,8 +2820,8 @@ void TextServerAdvanced::_font_clear_glyphs(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2749,8 +2831,8 @@ void TextServerAdvanced::_font_remove_glyph(const RID &p_font_rid, const Vector2 } double TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) const { - const FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0.0); + const FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_font_size); @@ -2763,8 +2845,8 @@ double TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) c } Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2793,6 +2875,12 @@ Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64 double scale = _font_get_scale(p_font_rid, p_size); if (fd->msdf) { return (gl[p_glyph | mod].advance + ea) * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return (gl[p_glyph | mod].advance + ea) * (double)p_size / (double)fd->fixed_size; + } else { + return (gl[p_glyph | mod].advance + ea) * Math::round((double)p_size / (double)fd->fixed_size); + } } else if ((scale == 1.0) && ((fd->subpixel_positioning == SUBPIXEL_POSITIONING_DISABLED) || (fd->subpixel_positioning == SUBPIXEL_POSITIONING_AUTO && size.x > SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE))) { return (gl[p_glyph | mod].advance + ea).round(); } else { @@ -2801,8 +2889,8 @@ Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64 } void TextServerAdvanced::_font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -2816,8 +2904,8 @@ void TextServerAdvanced::_font_set_glyph_advance(const RID &p_font_rid, int64_t } Vector2 TextServerAdvanced::_font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2840,14 +2928,20 @@ Vector2 TextServerAdvanced::_font_get_glyph_offset(const RID &p_font_rid, const if (fd->msdf) { return gl[p_glyph | mod].rect.position * (double)p_size.x / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size.x) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return gl[p_glyph | mod].rect.position * (double)p_size.x / (double)fd->fixed_size; + } else { + return gl[p_glyph | mod].rect.position * Math::round((double)p_size.x / (double)fd->fixed_size); + } } else { return gl[p_glyph | mod].rect.position; } } void TextServerAdvanced::_font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2861,8 +2955,8 @@ void TextServerAdvanced::_font_set_glyph_offset(const RID &p_font_rid, const Vec } Vector2 TextServerAdvanced::_font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2885,14 +2979,20 @@ Vector2 TextServerAdvanced::_font_get_glyph_size(const RID &p_font_rid, const Ve if (fd->msdf) { return gl[p_glyph | mod].rect.size * (double)p_size.x / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size.x) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return gl[p_glyph | mod].rect.size * (double)p_size.x / (double)fd->fixed_size; + } else { + return gl[p_glyph | mod].rect.size * Math::round((double)p_size.x / (double)fd->fixed_size); + } } else { return gl[p_glyph | mod].rect.size; } } void TextServerAdvanced::_font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2906,8 +3006,8 @@ void TextServerAdvanced::_font_set_glyph_size(const RID &p_font_rid, const Vecto } Rect2 TextServerAdvanced::_font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Rect2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Rect2()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2931,8 +3031,8 @@ Rect2 TextServerAdvanced::_font_get_glyph_uv_rect(const RID &p_font_rid, const V } void TextServerAdvanced::_font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2946,8 +3046,8 @@ void TextServerAdvanced::_font_set_glyph_uv_rect(const RID &p_font_rid, const Ve } int64_t TextServerAdvanced::_font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, -1); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, -1); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2971,8 +3071,8 @@ int64_t TextServerAdvanced::_font_get_glyph_texture_idx(const RID &p_font_rid, c } void TextServerAdvanced::_font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2986,8 +3086,8 @@ void TextServerAdvanced::_font_set_glyph_texture_idx(const RID &p_font_rid, cons } RID TextServerAdvanced::_font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, RID()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, RID()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -3032,8 +3132,8 @@ RID TextServerAdvanced::_font_get_glyph_texture_rid(const RID &p_font_rid, const } Size2 TextServerAdvanced::_font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Size2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Size2()); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -3078,8 +3178,8 @@ Size2 TextServerAdvanced::_font_get_glyph_texture_size(const RID &p_font_rid, co } Dictionary TextServerAdvanced::_font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3108,6 +3208,12 @@ Dictionary TextServerAdvanced::_font_get_glyph_contours(const RID &p_font_rid, i double scale = (1.0 / 64.0) / fd->cache[size]->oversampling * fd->cache[size]->scale; if (fd->msdf) { scale = scale * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + scale = scale * (double)p_size / (double)fd->fixed_size; + } else { + scale = scale * Math::round((double)p_size / (double)fd->fixed_size); + } } for (short i = 0; i < fd->cache[size]->face->glyph->outline.n_points; i++) { points.push_back(Vector3(fd->cache[size]->face->glyph->outline.points[i].x * scale, -fd->cache[size]->face->glyph->outline.points[i].y * scale, FT_CURVE_TAG(fd->cache[size]->face->glyph->outline.tags[i]))); @@ -3128,8 +3234,8 @@ Dictionary TextServerAdvanced::_font_get_glyph_contours(const RID &p_font_rid, i } TypedArray<Vector2i> TextServerAdvanced::_font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, TypedArray<Vector2i>()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3144,8 +3250,8 @@ TypedArray<Vector2i> TextServerAdvanced::_font_get_kerning_list(const RID &p_fon } void TextServerAdvanced::_font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3155,8 +3261,8 @@ void TextServerAdvanced::_font_clear_kerning_map(const RID &p_font_rid, int64_t } void TextServerAdvanced::_font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3166,8 +3272,8 @@ void TextServerAdvanced::_font_remove_kerning(const RID &p_font_rid, int64_t p_s } void TextServerAdvanced::_font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3177,8 +3283,8 @@ void TextServerAdvanced::_font_set_kerning(const RID &p_font_rid, int64_t p_size } Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Vector2()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3190,6 +3296,12 @@ Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_s if (kern.has(p_glyph_pair)) { if (fd->msdf) { return kern[p_glyph_pair] * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return kern[p_glyph_pair] * (double)p_size / (double)fd->fixed_size; + } else { + return kern[p_glyph_pair] * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return kern[p_glyph_pair]; } @@ -3200,6 +3312,12 @@ Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_s FT_Get_Kerning(fd->cache[size]->face, p_glyph_pair.x, p_glyph_pair.y, FT_KERNING_DEFAULT, &delta); if (fd->msdf) { return Vector2(delta.x, delta.y) * (double)p_size / (double)fd->msdf_source_size; + } else if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + return Vector2(delta.x, delta.y) * (double)p_size / (double)fd->fixed_size; + } else { + return Vector2(delta.x, delta.y) * Math::round((double)p_size / (double)fd->fixed_size); + } } else { return Vector2(delta.x, delta.y); } @@ -3210,8 +3328,8 @@ Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_s } int64_t TextServerAdvanced::_font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); ERR_FAIL_COND_V_MSG((p_variation_selector >= 0xd800 && p_variation_selector <= 0xdfff) || (p_variation_selector > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_variation_selector, 16) + "."); @@ -3235,8 +3353,8 @@ int64_t TextServerAdvanced::_font_get_glyph_index(const RID &p_font_rid, int64_t } int64_t TextServerAdvanced::_font_get_char_from_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_glyph_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, 0); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3266,7 +3384,7 @@ int64_t TextServerAdvanced::_font_get_char_from_glyph_index(const RID &p_font_ri } bool TextServerAdvanced::_font_has_char(const RID &p_font_rid, int64_t p_char) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), false, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); if (!fd) { return false; @@ -3287,8 +3405,8 @@ bool TextServerAdvanced::_font_has_char(const RID &p_font_rid, int64_t p_char) c } String TextServerAdvanced::_font_get_supported_chars(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, String()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); if (fd->cache.is_empty()) { @@ -3320,8 +3438,8 @@ String TextServerAdvanced::_font_get_supported_chars(const RID &p_font_rid) cons } void TextServerAdvanced::_font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); ERR_FAIL_COND_MSG((p_start >= 0xd800 && p_start <= 0xdfff) || (p_start > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_start, 16) + "."); ERR_FAIL_COND_MSG((p_end >= 0xd800 && p_end <= 0xdfff) || (p_end > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_end, 16) + "."); @@ -3355,8 +3473,8 @@ void TextServerAdvanced::_font_render_range(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -3386,8 +3504,8 @@ void TextServerAdvanced::_font_render_glyph(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, p_size); @@ -3464,8 +3582,20 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca cpos.y = Math::floor(cpos.y); cpos.x = Math::floor(cpos.x); } - cpos += gl.rect.position; + Vector2 gpos = gl.rect.position; Size2 csize = gl.rect.size; + if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + double gl_scale = (double)p_size / (double)fd->fixed_size; + gpos *= gl_scale; + csize *= gl_scale; + } else { + double gl_scale = Math::round((double)p_size / (double)fd->fixed_size); + gpos *= gl_scale; + csize *= gl_scale; + } + } + cpos += gpos; if (lcd_aa) { RenderingServer::get_singleton()->canvas_item_add_lcd_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate); } else { @@ -3478,8 +3608,8 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca } void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, Vector2i(p_size, p_outline_size)); @@ -3556,8 +3686,20 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R cpos.y = Math::floor(cpos.y); cpos.x = Math::floor(cpos.x); } - cpos += gl.rect.position; + Vector2 gpos = gl.rect.position; Size2 csize = gl.rect.size; + if (fd->fixed_size > 0 && fd->fixed_size_scale_mode != FIXED_SIZE_SCALE_DISABLE && size.x != p_size) { + if (fd->fixed_size_scale_mode == FIXED_SIZE_SCALE_ENABLED) { + double gl_scale = (double)p_size / (double)fd->fixed_size; + gpos *= gl_scale; + csize *= gl_scale; + } else { + double gl_scale = Math::round((double)p_size / (double)fd->fixed_size); + gpos *= gl_scale; + csize *= gl_scale; + } + } + cpos += gpos; if (lcd_aa) { RenderingServer::get_singleton()->canvas_item_add_lcd_texture_rect_region(p_canvas, Rect2(cpos, csize), texture, gl.uv_rect, modulate); } else { @@ -3570,8 +3712,8 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R } bool TextServerAdvanced::_font_is_language_supported(const RID &p_font_rid, const String &p_language) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); if (fd->language_support_overrides.has(p_language)) { @@ -3582,32 +3724,32 @@ bool TextServerAdvanced::_font_is_language_supported(const RID &p_font_rid, cons } void TextServerAdvanced::_font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->language_support_overrides[p_language] = p_supported; } bool TextServerAdvanced::_font_get_language_support_override(const RID &p_font_rid, const String &p_language) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->language_support_overrides[p_language]; } void TextServerAdvanced::_font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->language_support_overrides.erase(p_language); } PackedStringArray TextServerAdvanced::_font_get_language_support_overrides(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, PackedStringArray()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); PackedStringArray out; @@ -3618,8 +3760,8 @@ PackedStringArray TextServerAdvanced::_font_get_language_support_overrides(const } bool TextServerAdvanced::_font_is_script_supported(const RID &p_font_rid, const String &p_script) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); if (fd->script_support_overrides.has(p_script)) { @@ -3632,32 +3774,32 @@ bool TextServerAdvanced::_font_is_script_supported(const RID &p_font_rid, const } void TextServerAdvanced::_font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->script_support_overrides[p_script] = p_supported; } bool TextServerAdvanced::_font_get_script_support_override(const RID &p_font_rid, const String &p_script) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, false); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); return fd->script_support_overrides[p_script]; } void TextServerAdvanced::_font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); fd->script_support_overrides.erase(p_script); } PackedStringArray TextServerAdvanced::_font_get_script_support_overrides(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, PackedStringArray()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); PackedStringArray out; @@ -3668,8 +3810,8 @@ PackedStringArray TextServerAdvanced::_font_get_script_support_overrides(const R } void TextServerAdvanced::_font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -3678,16 +3820,16 @@ void TextServerAdvanced::_font_set_opentype_feature_overrides(const RID &p_font_ } Dictionary TextServerAdvanced::_font_get_opentype_feature_overrides(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); return fd->feature_overrides; } Dictionary TextServerAdvanced::_font_supported_feature_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -3696,8 +3838,8 @@ Dictionary TextServerAdvanced::_font_supported_feature_list(const RID &p_font_ri } Dictionary TextServerAdvanced::_font_supported_variation_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_COND_V(!fd, Dictionary()); + FontAdvanced *fd = _get_font_data(p_font_rid); + ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); Vector2i size = _get_size(fd, 16); @@ -3841,7 +3983,7 @@ RID TextServerAdvanced::_create_shaped_text(TextServer::Direction p_direction, T void TextServerAdvanced::_shaped_text_clear(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); sd->parent = RID(); @@ -3857,7 +3999,7 @@ void TextServerAdvanced::_shaped_text_clear(const RID &p_shaped) { void TextServerAdvanced::_shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); ERR_FAIL_COND_MSG(p_direction == DIRECTION_INHERITED, "Invalid text direction."); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); if (sd->direction != p_direction) { @@ -3871,7 +4013,7 @@ void TextServerAdvanced::_shaped_text_set_direction(const RID &p_shaped, TextSer TextServer::Direction TextServerAdvanced::_shaped_text_get_direction(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, TextServer::DIRECTION_LTR); + ERR_FAIL_NULL_V(sd, TextServer::DIRECTION_LTR); MutexLock lock(sd->mutex); return sd->direction; @@ -3879,7 +4021,7 @@ TextServer::Direction TextServerAdvanced::_shaped_text_get_direction(const RID & TextServer::Direction TextServerAdvanced::_shaped_text_get_inferred_direction(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, TextServer::DIRECTION_LTR); + ERR_FAIL_NULL_V(sd, TextServer::DIRECTION_LTR); MutexLock lock(sd->mutex); return sd->para_direction; @@ -3888,7 +4030,7 @@ TextServer::Direction TextServerAdvanced::_shaped_text_get_inferred_direction(co void TextServerAdvanced::_shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) { _THREAD_SAFE_METHOD_ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); if (sd->custom_punct != p_punct) { if (sd->parent != RID()) { @@ -3902,13 +4044,13 @@ void TextServerAdvanced::_shaped_text_set_custom_punctuation(const RID &p_shaped String TextServerAdvanced::_shaped_text_get_custom_punctuation(const RID &p_shaped) const { _THREAD_SAFE_METHOD_ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, String()); + ERR_FAIL_NULL_V(sd, String()); return sd->custom_punct; } void TextServerAdvanced::_shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); if (sd->parent != RID()) { @@ -3929,7 +4071,7 @@ void TextServerAdvanced::_shaped_text_set_bidi_override(const RID &p_shaped, con void TextServerAdvanced::_shaped_text_set_orientation(const RID &p_shaped, TextServer::Orientation p_orientation) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); if (sd->orientation != p_orientation) { @@ -3943,7 +4085,7 @@ void TextServerAdvanced::_shaped_text_set_orientation(const RID &p_shaped, TextS void TextServerAdvanced::_shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); ERR_FAIL_COND(sd->parent != RID()); @@ -3955,7 +4097,7 @@ void TextServerAdvanced::_shaped_text_set_preserve_invalid(const RID &p_shaped, bool TextServerAdvanced::_shaped_text_get_preserve_invalid(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); return sd->preserve_invalid; @@ -3963,7 +4105,7 @@ bool TextServerAdvanced::_shaped_text_get_preserve_invalid(const RID &p_shaped) void TextServerAdvanced::_shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); if (sd->preserve_control != p_enabled) { @@ -3977,7 +4119,7 @@ void TextServerAdvanced::_shaped_text_set_preserve_control(const RID &p_shaped, bool TextServerAdvanced::_shaped_text_get_preserve_control(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); return sd->preserve_control; @@ -3986,7 +4128,7 @@ bool TextServerAdvanced::_shaped_text_get_preserve_control(const RID &p_shaped) void TextServerAdvanced::_shaped_text_set_spacing(const RID &p_shaped, SpacingType p_spacing, int64_t p_value) { ERR_FAIL_INDEX((int)p_spacing, 4); ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); MutexLock lock(sd->mutex); if (sd->extra_spacing[p_spacing] != p_value) { @@ -4002,7 +4144,7 @@ int64_t TextServerAdvanced::_shaped_text_get_spacing(const RID &p_shaped, Spacin ERR_FAIL_INDEX_V((int)p_spacing, 4, 0); const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0); + ERR_FAIL_NULL_V(sd, 0); MutexLock lock(sd->mutex); return sd->extra_spacing[p_spacing]; @@ -4010,7 +4152,7 @@ int64_t TextServerAdvanced::_shaped_text_get_spacing(const RID &p_shaped, Spacin TextServer::Orientation TextServerAdvanced::_shaped_text_get_orientation(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, TextServer::ORIENTATION_HORIZONTAL); + ERR_FAIL_NULL_V(sd, TextServer::ORIENTATION_HORIZONTAL); MutexLock lock(sd->mutex); return sd->orientation; @@ -4018,20 +4160,20 @@ TextServer::Orientation TextServerAdvanced::_shaped_text_get_orientation(const R int64_t TextServerAdvanced::_shaped_get_span_count(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0); + ERR_FAIL_NULL_V(sd, 0); return sd->spans.size(); } Variant TextServerAdvanced::_shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, Variant()); + ERR_FAIL_NULL_V(sd, Variant()); ERR_FAIL_INDEX_V(p_index, sd->spans.size(), Variant()); return sd->spans[p_index].meta; } void TextServerAdvanced::_shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND(!sd); + ERR_FAIL_NULL(sd); ERR_FAIL_INDEX(p_index, sd->spans.size()); ShapedTextDataAdvanced::Span &span = sd->spans.ptrw()[p_index]; @@ -4044,12 +4186,12 @@ void TextServerAdvanced::_shaped_set_span_update_font(const RID &p_shaped, int64 bool TextServerAdvanced::_shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features, const String &p_language, const Variant &p_meta) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); ERR_FAIL_COND_V(p_size <= 0, false); MutexLock lock(sd->mutex); for (int i = 0; i < p_fonts.size(); i++) { - ERR_FAIL_COND_V(!font_owner.get_or_null(p_fonts[i]), false); + ERR_FAIL_NULL_V(_get_font_data(p_fonts[i]), false); } if (p_text.is_empty()) { @@ -4080,7 +4222,7 @@ bool TextServerAdvanced::_shaped_text_add_string(const RID &p_shaped, const Stri bool TextServerAdvanced::_shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, int64_t p_length, double p_baseline) { _THREAD_SAFE_METHOD_ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); ERR_FAIL_COND_V(p_key == Variant(), false); ERR_FAIL_COND_V(sd->objects.has(p_key), false); @@ -4110,7 +4252,7 @@ bool TextServerAdvanced::_shaped_text_add_object(const RID &p_shaped, const Vari bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, double p_baseline) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); ERR_FAIL_COND_V(!sd->objects.has(p_key), false); @@ -4170,6 +4312,8 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V sd->width += gl.advance * gl.repeat; } } + sd->sort_valid = false; + sd->glyphs_logical.clear(); _realign(sd); } return true; @@ -4253,7 +4397,7 @@ void TextServerAdvanced::_realign(ShapedTextDataAdvanced *p_sd) const { RID TextServerAdvanced::_shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const { _THREAD_SAFE_METHOD_ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, RID()); + ERR_FAIL_NULL_V(sd, RID()); MutexLock lock(sd->mutex); if (sd->parent != RID()) { @@ -4437,7 +4581,7 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S RID TextServerAdvanced::_shaped_text_get_parent(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, RID()); + ERR_FAIL_NULL_V(sd, RID()); MutexLock lock(sd->mutex); return sd->parent; @@ -4445,7 +4589,7 @@ RID TextServerAdvanced::_shaped_text_get_parent(const RID &p_shaped) const { double TextServerAdvanced::_shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -4602,7 +4746,7 @@ double TextServerAdvanced::_shaped_text_fit_to_width(const RID &p_shaped, double double TextServerAdvanced::_shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -4658,7 +4802,7 @@ double TextServerAdvanced::_shaped_text_tab_align(const RID &p_shaped, const Pac void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_line, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped_line); - ERR_FAIL_COND_MSG(!sd, "ShapedTextDataAdvanced invalid."); + ERR_FAIL_NULL_MSG(sd, "ShapedTextDataAdvanced invalid."); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -4825,7 +4969,7 @@ void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_ int64_t TextServerAdvanced::_shaped_text_get_trim_pos(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataAdvanced invalid."); + ERR_FAIL_NULL_V_MSG(sd, -1, "ShapedTextDataAdvanced invalid."); MutexLock lock(sd->mutex); return sd->overrun_trim_data.trim_pos; @@ -4833,7 +4977,7 @@ int64_t TextServerAdvanced::_shaped_text_get_trim_pos(const RID &p_shaped) const int64_t TextServerAdvanced::_shaped_text_get_ellipsis_pos(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V_MSG(!sd, -1, "ShapedTextDataAdvanced invalid."); + ERR_FAIL_NULL_V_MSG(sd, -1, "ShapedTextDataAdvanced invalid."); MutexLock lock(sd->mutex); return sd->overrun_trim_data.ellipsis_pos; @@ -4841,7 +4985,7 @@ int64_t TextServerAdvanced::_shaped_text_get_ellipsis_pos(const RID &p_shaped) c const Glyph *TextServerAdvanced::_shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V_MSG(!sd, nullptr, "ShapedTextDataAdvanced invalid."); + ERR_FAIL_NULL_V_MSG(sd, nullptr, "ShapedTextDataAdvanced invalid."); MutexLock lock(sd->mutex); return sd->overrun_trim_data.ellipsis_glyph_buf.ptr(); @@ -4849,7 +4993,7 @@ const Glyph *TextServerAdvanced::_shaped_text_get_ellipsis_glyphs(const RID &p_s int64_t TextServerAdvanced::_shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V_MSG(!sd, 0, "ShapedTextDataAdvanced invalid."); + ERR_FAIL_NULL_V_MSG(sd, 0, "ShapedTextDataAdvanced invalid."); MutexLock lock(sd->mutex); return sd->overrun_trim_data.ellipsis_glyph_buf.size(); @@ -4912,7 +5056,7 @@ void TextServerAdvanced::_update_chars(ShapedTextDataAdvanced *p_sd) const { PackedInt32Array TextServerAdvanced::_shaped_text_get_character_breaks(const RID &p_shaped) const { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, PackedInt32Array()); + ERR_FAIL_NULL_V(sd, PackedInt32Array()); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -4926,7 +5070,7 @@ PackedInt32Array TextServerAdvanced::_shaped_text_get_character_breaks(const RID bool TextServerAdvanced::_shaped_text_update_breaks(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5191,7 +5335,7 @@ _FORCE_INLINE_ int64_t _generate_kashida_justification_opportunies(const String bool TextServerAdvanced::_shaped_text_update_justification_ops(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -5345,7 +5489,7 @@ Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char hb_font_t *hb_font = _font_get_hb_handle(p_font, p_font_size); double scale = _font_get_scale(p_font, p_font_size); bool subpos = (scale != 1.0) || (_font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_ONE_HALF) || (_font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (_font_get_subpixel_positioning(p_font) == SUBPIXEL_POSITIONING_AUTO && p_font_size <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE); - ERR_FAIL_COND_V(hb_font == nullptr, Glyph()); + ERR_FAIL_NULL_V(hb_font, Glyph()); hb_buffer_clear_contents(p_sd->hb_buffer); hb_buffer_set_direction(p_sd->hb_buffer, p_direction); @@ -5631,8 +5775,8 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star return; } - FontAdvanced *fd = font_owner.get_or_null(f); - ERR_FAIL_COND(!fd); + FontAdvanced *fd = _get_font_data(f); + ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i fss = _get_size(fd, fs); @@ -5643,7 +5787,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star bool last_run = (p_sd->end == p_end); double ea = _get_extra_advance(f, fs); bool subpos = (scale != 1.0) || (_font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_ONE_HALF) || (_font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (_font_get_subpixel_positioning(f) == SUBPIXEL_POSITIONING_AUTO && fs <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE); - ERR_FAIL_COND(hb_font == nullptr); + ERR_FAIL_NULL(hb_font); hb_buffer_clear_contents(p_sd->hb_buffer); hb_buffer_set_direction(p_sd->hb_buffer, p_direction); @@ -5834,7 +5978,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star bool TextServerAdvanced::_shaped_text_shape(const RID &p_shaped) { _THREAD_SAFE_METHOD_ ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); if (sd->valid) { @@ -6050,7 +6194,7 @@ bool TextServerAdvanced::_shaped_text_shape(const RID &p_shaped) { bool TextServerAdvanced::_shaped_text_is_ready(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, false); + ERR_FAIL_NULL_V(sd, false); MutexLock lock(sd->mutex); return sd->valid; @@ -6058,7 +6202,7 @@ bool TextServerAdvanced::_shaped_text_is_ready(const RID &p_shaped) const { const Glyph *TextServerAdvanced::_shaped_text_get_glyphs(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, nullptr); + ERR_FAIL_NULL_V(sd, nullptr); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6069,7 +6213,7 @@ const Glyph *TextServerAdvanced::_shaped_text_get_glyphs(const RID &p_shaped) co int64_t TextServerAdvanced::_shaped_text_get_glyph_count(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0); + ERR_FAIL_NULL_V(sd, 0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6080,7 +6224,7 @@ int64_t TextServerAdvanced::_shaped_text_get_glyph_count(const RID &p_shaped) co const Glyph *TextServerAdvanced::_shaped_text_sort_logical(const RID &p_shaped) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, nullptr); + ERR_FAIL_NULL_V(sd, nullptr); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6098,7 +6242,7 @@ const Glyph *TextServerAdvanced::_shaped_text_sort_logical(const RID &p_shaped) Vector2i TextServerAdvanced::_shaped_text_get_range(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, Vector2i()); + ERR_FAIL_NULL_V(sd, Vector2i()); MutexLock lock(sd->mutex); return Vector2(sd->start, sd->end); @@ -6107,7 +6251,7 @@ Vector2i TextServerAdvanced::_shaped_text_get_range(const RID &p_shaped) const { Array TextServerAdvanced::_shaped_text_get_objects(const RID &p_shaped) const { Array ret; const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, ret); + ERR_FAIL_NULL_V(sd, ret); MutexLock lock(sd->mutex); for (const KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : sd->objects) { @@ -6119,7 +6263,7 @@ Array TextServerAdvanced::_shaped_text_get_objects(const RID &p_shaped) const { Rect2 TextServerAdvanced::_shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, Rect2()); + ERR_FAIL_NULL_V(sd, Rect2()); MutexLock lock(sd->mutex); ERR_FAIL_COND_V(!sd->objects.has(p_key), Rect2()); @@ -6131,7 +6275,7 @@ Rect2 TextServerAdvanced::_shaped_text_get_object_rect(const RID &p_shaped, cons Size2 TextServerAdvanced::_shaped_text_get_size(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, Size2()); + ERR_FAIL_NULL_V(sd, Size2()); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6146,7 +6290,7 @@ Size2 TextServerAdvanced::_shaped_text_get_size(const RID &p_shaped) const { double TextServerAdvanced::_shaped_text_get_ascent(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6157,7 +6301,7 @@ double TextServerAdvanced::_shaped_text_get_ascent(const RID &p_shaped) const { double TextServerAdvanced::_shaped_text_get_descent(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6168,7 +6312,7 @@ double TextServerAdvanced::_shaped_text_get_descent(const RID &p_shaped) const { double TextServerAdvanced::_shaped_text_get_width(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6179,7 +6323,7 @@ double TextServerAdvanced::_shaped_text_get_width(const RID &p_shaped) const { double TextServerAdvanced::_shaped_text_get_underline_position(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { @@ -6191,7 +6335,7 @@ double TextServerAdvanced::_shaped_text_get_underline_position(const RID &p_shap double TextServerAdvanced::_shaped_text_get_underline_thickness(const RID &p_shaped) const { const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped); - ERR_FAIL_COND_V(!sd, 0.0); + ERR_FAIL_NULL_V(sd, 0.0); MutexLock lock(sd->mutex); if (!sd->valid) { |