You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #108769 from bruvzg/shy_fall
[TextServer] Fix soft hyphen font fallback.
This commit is contained in:
@@ -5282,6 +5282,28 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S
|
||||
}
|
||||
if (gl.end == p_start + p_length && ((gl.flags & GRAPHEME_IS_SOFT_HYPHEN) == GRAPHEME_IS_SOFT_HYPHEN)) {
|
||||
uint32_t index = font_get_glyph_index(gl.font_rid, gl.font_size, 0x00ad, 0);
|
||||
if (index == 0) { // Try other fonts in the span.
|
||||
const ShapedTextDataAdvanced::Span &span = p_sd->spans[gl.span_index + p_new_sd->first_span];
|
||||
for (int k = 0; k < span.fonts.size(); k++) {
|
||||
if (span.fonts[k] != gl.font_rid) {
|
||||
index = font_get_glyph_index(span.fonts[k], gl.font_size, 0x00ad, 0);
|
||||
if (index != 0) {
|
||||
gl.font_rid = span.fonts[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index == 0 && gl.font_rid.is_valid() && OS::get_singleton()->has_feature("system_fonts") && _font_is_allow_system_fallback(gl.font_rid)) { // Try system font fallback.
|
||||
const char32_t u32str[] = { 0x00ad, 0 };
|
||||
RID rid = const_cast<TextServerAdvanced *>(this)->_find_sys_font_for_text(gl.font_rid, String(), String(), u32str);
|
||||
if (rid.is_valid()) {
|
||||
index = font_get_glyph_index(rid, gl.font_size, 0x00ad, 0);
|
||||
if (index != 0) {
|
||||
gl.font_rid = rid;
|
||||
}
|
||||
}
|
||||
}
|
||||
float w = font_get_glyph_advance(gl.font_rid, gl.font_size, index)[(p_new_sd->orientation == ORIENTATION_HORIZONTAL) ? 0 : 1];
|
||||
gl.index = index;
|
||||
gl.advance = w;
|
||||
|
||||
Reference in New Issue
Block a user