mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix font fallback for lines with only non-visual/control characters.
This commit is contained in:
parent
967e2d499a
commit
6c34f48c90
2 changed files with 23 additions and 3 deletions
|
@ -4998,6 +4998,7 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V
|
|||
|
||||
int sd_size = sd->glyphs.size();
|
||||
int span_size = spans.size();
|
||||
const char32_t *ch = sd->text.ptr();
|
||||
|
||||
for (int i = 0; i < sd_size; i++) {
|
||||
Glyph gl = sd->glyphs[i];
|
||||
|
@ -5026,7 +5027,7 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V
|
|||
}
|
||||
sd->upos = MAX(sd->upos, _font_get_underline_position(gl.font_rid, gl.font_size));
|
||||
sd->uthk = MAX(sd->uthk, _font_get_underline_thickness(gl.font_rid, gl.font_size));
|
||||
} else if (sd->preserve_invalid || (sd->preserve_control && is_control(gl.index))) {
|
||||
} else if (sd->preserve_invalid || (sd->preserve_control && is_control(ch[gl.start - sd->start]))) {
|
||||
// Glyph not found, replace with hex code box.
|
||||
if (sd->orientation == ORIENTATION_HORIZONTAL) {
|
||||
sd->ascent = MAX(sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.85);
|
||||
|
@ -5200,6 +5201,7 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S
|
|||
|
||||
int sd_size = p_sd->glyphs.size();
|
||||
const Glyph *sd_glyphs = p_sd->glyphs.ptr();
|
||||
const char32_t *ch = p_sd->text.ptr();
|
||||
for (int ov = 0; ov < bidi_ranges.size(); ov++) {
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
|
||||
|
@ -5330,7 +5332,7 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S
|
|||
p_new_sd->ascent = MAX(p_new_sd->ascent, Math::round(_font_get_glyph_advance(gl.font_rid, gl.font_size, gl.index).x * 0.5));
|
||||
p_new_sd->descent = MAX(p_new_sd->descent, Math::round(_font_get_glyph_advance(gl.font_rid, gl.font_size, gl.index).x * 0.5));
|
||||
}
|
||||
} else if (p_new_sd->preserve_invalid || (p_new_sd->preserve_control && is_control(gl.index))) {
|
||||
} else if (p_new_sd->preserve_invalid || (p_new_sd->preserve_control && is_control(ch[gl.start - p_sd->start]))) {
|
||||
// Glyph not found, replace with hex code box.
|
||||
if (p_new_sd->orientation == ORIENTATION_HORIZONTAL) {
|
||||
p_new_sd->ascent = MAX(p_new_sd->ascent, get_hex_code_box_size(gl.font_size, gl.index).y * 0.85);
|
||||
|
@ -6936,6 +6938,24 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star
|
|||
p_sd->descent = MAX(p_sd->descent, _font_get_descent(f, fs) + _font_get_spacing(f, SPACING_BOTTOM));
|
||||
p_sd->upos = MAX(p_sd->upos, _font_get_underline_position(f, fs));
|
||||
p_sd->uthk = MAX(p_sd->uthk, _font_get_underline_thickness(f, fs));
|
||||
} else if (p_start != p_end) {
|
||||
if (p_fb_index >= p_fonts.size()) {
|
||||
Glyph gl;
|
||||
gl.start = p_start;
|
||||
gl.end = p_end;
|
||||
gl.span_index = p_span;
|
||||
gl.font_rid = f;
|
||||
gl.font_size = fs;
|
||||
gl.flags = GRAPHEME_IS_VALID;
|
||||
p_sd->glyphs.push_back(gl);
|
||||
|
||||
p_sd->ascent = MAX(p_sd->ascent, _font_get_ascent(f, fs) + _font_get_spacing(f, SPACING_TOP));
|
||||
p_sd->descent = MAX(p_sd->descent, _font_get_descent(f, fs) + _font_get_spacing(f, SPACING_BOTTOM));
|
||||
p_sd->upos = MAX(p_sd->upos, _font_get_underline_position(f, fs));
|
||||
p_sd->uthk = MAX(p_sd->uthk, _font_get_underline_thickness(f, fs));
|
||||
} else {
|
||||
_shape_run(p_sd, p_start, p_end, p_script, p_direction, p_fonts, p_span, p_fb_index + 1, p_start, p_end, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue