@@ -5264,42 +5264,44 @@ void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_
52645264
52655265 // Find usable fonts, if fonts from the last glyph do not have required chars.
52665266 RID dot_gl_font_rid = sd_glyphs[sd_size - 1 ].font_rid ;
5267- if (!_font_has_char (dot_gl_font_rid, sd->el_char )) {
5268- const Array &fonts = spans[spans.size () - 1 ].fonts ;
5269- for (int i = 0 ; i < fonts.size (); i++) {
5270- if (_font_has_char (fonts[i], sd->el_char )) {
5271- dot_gl_font_rid = fonts[i];
5272- found_el_char = true ;
5273- break ;
5274- }
5275- }
5276- if (!found_el_char && OS::get_singleton ()->has_feature (" system_fonts" ) && fonts.size () > 0 && _font_is_allow_system_fallback (fonts[0 ])) {
5277- const char32_t u32str[] = { sd->el_char , 0 };
5278- RID rid = _find_sys_font_for_text (fonts[0 ], String (), spans[spans.size () - 1 ].language , u32str);
5279- if (rid.is_valid ()) {
5280- dot_gl_font_rid = rid;
5281- found_el_char = true ;
5282- }
5283- }
5284- } else {
5285- found_el_char = true ;
5286- }
5287- if (!found_el_char) {
5288- bool found_dot_char = false ;
5289- dot_gl_font_rid = sd_glyphs[sd_size - 1 ].font_rid ;
5290- if (!_font_has_char (dot_gl_font_rid, ' .' )) {
5267+ if (add_ellipsis || enforce_ellipsis) {
5268+ if (!_font_has_char (dot_gl_font_rid, sd->el_char )) {
52915269 const Array &fonts = spans[spans.size () - 1 ].fonts ;
52925270 for (int i = 0 ; i < fonts.size (); i++) {
5293- if (_font_has_char (fonts[i], ' . ' )) {
5271+ if (_font_has_char (fonts[i], sd-> el_char )) {
52945272 dot_gl_font_rid = fonts[i];
5295- found_dot_char = true ;
5273+ found_el_char = true ;
52965274 break ;
52975275 }
52985276 }
5299- if (!found_dot_char && OS::get_singleton ()->has_feature (" system_fonts" ) && fonts.size () > 0 && _font_is_allow_system_fallback (fonts[0 ])) {
5300- RID rid = _find_sys_font_for_text (fonts[0 ], String (), spans[spans.size () - 1 ].language , " ." );
5277+ if (!found_el_char && OS::get_singleton ()->has_feature (" system_fonts" ) && fonts.size () > 0 && _font_is_allow_system_fallback (fonts[0 ])) {
5278+ const char32_t u32str[] = { sd->el_char , 0 };
5279+ RID rid = _find_sys_font_for_text (fonts[0 ], String (), spans[spans.size () - 1 ].language , u32str);
53015280 if (rid.is_valid ()) {
53025281 dot_gl_font_rid = rid;
5282+ found_el_char = true ;
5283+ }
5284+ }
5285+ } else {
5286+ found_el_char = true ;
5287+ }
5288+ if (!found_el_char) {
5289+ bool found_dot_char = false ;
5290+ dot_gl_font_rid = sd_glyphs[sd_size - 1 ].font_rid ;
5291+ if (!_font_has_char (dot_gl_font_rid, ' .' )) {
5292+ const Array &fonts = spans[spans.size () - 1 ].fonts ;
5293+ for (int i = 0 ; i < fonts.size (); i++) {
5294+ if (_font_has_char (fonts[i], ' .' )) {
5295+ dot_gl_font_rid = fonts[i];
5296+ found_dot_char = true ;
5297+ break ;
5298+ }
5299+ }
5300+ if (!found_dot_char && OS::get_singleton ()->has_feature (" system_fonts" ) && fonts.size () > 0 && _font_is_allow_system_fallback (fonts[0 ])) {
5301+ RID rid = _find_sys_font_for_text (fonts[0 ], String (), spans[spans.size () - 1 ].language , " ." );
5302+ if (rid.is_valid ()) {
5303+ dot_gl_font_rid = rid;
5304+ }
53035305 }
53045306 }
53055307 }
@@ -5315,8 +5317,8 @@ void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_
53155317 }
53165318 }
53175319
5318- int32_t dot_gl_idx = dot_gl_font_rid.is_valid () ? _font_get_glyph_index (dot_gl_font_rid, last_gl_font_size, (found_el_char ? sd->el_char : ' .' ), 0 ) : -1 ;
5319- Vector2 dot_adv = dot_gl_font_rid.is_valid () ? _font_get_glyph_advance (dot_gl_font_rid, last_gl_font_size, dot_gl_idx) : Vector2 ();
5320+ int32_t dot_gl_idx = ((add_ellipsis || enforce_ellipsis) && dot_gl_font_rid.is_valid () ) ? _font_get_glyph_index (dot_gl_font_rid, last_gl_font_size, (found_el_char ? sd->el_char : ' .' ), 0 ) : -1 ;
5321+ Vector2 dot_adv = ((add_ellipsis || enforce_ellipsis) && dot_gl_font_rid.is_valid () ) ? _font_get_glyph_advance (dot_gl_font_rid, last_gl_font_size, dot_gl_idx) : Vector2 ();
53205322 int32_t whitespace_gl_idx = whitespace_gl_font_rid.is_valid () ? _font_get_glyph_index (whitespace_gl_font_rid, last_gl_font_size, ' ' , 0 ) : -1 ;
53215323 Vector2 whitespace_adv = whitespace_gl_font_rid.is_valid () ? _font_get_glyph_advance (whitespace_gl_font_rid, last_gl_font_size, whitespace_gl_idx) : Vector2 ();
53225324
0 commit comments