|
@@ -5264,42 +5264,44 @@ void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_
|
|
|
|
|
|
// Find usable fonts, if fonts from the last glyph do not have required chars.
|
|
|
RID dot_gl_font_rid = sd_glyphs[sd_size - 1].font_rid;
|
|
|
- if (!_font_has_char(dot_gl_font_rid, sd->el_char)) {
|
|
|
- const Array &fonts = spans[spans.size() - 1].fonts;
|
|
|
- for (int i = 0; i < fonts.size(); i++) {
|
|
|
- if (_font_has_char(fonts[i], sd->el_char)) {
|
|
|
- dot_gl_font_rid = fonts[i];
|
|
|
- found_el_char = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!found_el_char && OS::get_singleton()->has_feature("system_fonts") && fonts.size() > 0 && _font_is_allow_system_fallback(fonts[0])) {
|
|
|
- const char32_t u32str[] = { sd->el_char, 0 };
|
|
|
- RID rid = _find_sys_font_for_text(fonts[0], String(), spans[spans.size() - 1].language, u32str);
|
|
|
- if (rid.is_valid()) {
|
|
|
- dot_gl_font_rid = rid;
|
|
|
- found_el_char = true;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- found_el_char = true;
|
|
|
- }
|
|
|
- if (!found_el_char) {
|
|
|
- bool found_dot_char = false;
|
|
|
- dot_gl_font_rid = sd_glyphs[sd_size - 1].font_rid;
|
|
|
- if (!_font_has_char(dot_gl_font_rid, '.')) {
|
|
|
+ if (add_ellipsis || enforce_ellipsis) {
|
|
|
+ if (!_font_has_char(dot_gl_font_rid, sd->el_char)) {
|
|
|
const Array &fonts = spans[spans.size() - 1].fonts;
|
|
|
for (int i = 0; i < fonts.size(); i++) {
|
|
|
- if (_font_has_char(fonts[i], '.')) {
|
|
|
+ if (_font_has_char(fonts[i], sd->el_char)) {
|
|
|
dot_gl_font_rid = fonts[i];
|
|
|
- found_dot_char = true;
|
|
|
+ found_el_char = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (!found_dot_char && OS::get_singleton()->has_feature("system_fonts") && fonts.size() > 0 && _font_is_allow_system_fallback(fonts[0])) {
|
|
|
- RID rid = _find_sys_font_for_text(fonts[0], String(), spans[spans.size() - 1].language, ".");
|
|
|
+ if (!found_el_char && OS::get_singleton()->has_feature("system_fonts") && fonts.size() > 0 && _font_is_allow_system_fallback(fonts[0])) {
|
|
|
+ const char32_t u32str[] = { sd->el_char, 0 };
|
|
|
+ RID rid = _find_sys_font_for_text(fonts[0], String(), spans[spans.size() - 1].language, u32str);
|
|
|
if (rid.is_valid()) {
|
|
|
dot_gl_font_rid = rid;
|
|
|
+ found_el_char = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ found_el_char = true;
|
|
|
+ }
|
|
|
+ if (!found_el_char) {
|
|
|
+ bool found_dot_char = false;
|
|
|
+ dot_gl_font_rid = sd_glyphs[sd_size - 1].font_rid;
|
|
|
+ if (!_font_has_char(dot_gl_font_rid, '.')) {
|
|
|
+ const Array &fonts = spans[spans.size() - 1].fonts;
|
|
|
+ for (int i = 0; i < fonts.size(); i++) {
|
|
|
+ if (_font_has_char(fonts[i], '.')) {
|
|
|
+ dot_gl_font_rid = fonts[i];
|
|
|
+ found_dot_char = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!found_dot_char && OS::get_singleton()->has_feature("system_fonts") && fonts.size() > 0 && _font_is_allow_system_fallback(fonts[0])) {
|
|
|
+ RID rid = _find_sys_font_for_text(fonts[0], String(), spans[spans.size() - 1].language, ".");
|
|
|
+ if (rid.is_valid()) {
|
|
|
+ dot_gl_font_rid = rid;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5315,8 +5317,8 @@ void TextServerAdvanced::_shaped_text_overrun_trim_to_width(const RID &p_shaped_
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
- 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();
|
|
|
+ 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;
|
|
|
+ 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();
|
|
|
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;
|
|
|
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();
|
|
|
|