Merge pull request #116196 from bruvzg/shy_b

Fix soft hyphen not working with small (or zero) line breaking width.
This commit is contained in:
Thaddeus Crews 2026-02-20 11:36:05 -06:00
commit a142c2218a
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -977,7 +977,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
if ((l_gl[i].flags & GRAPHEME_IS_SOFT_HYPHEN) == GRAPHEME_IS_SOFT_HYPHEN) {
uint32_t gl = font_get_glyph_index(l_gl[i].font_rid, l_gl[i].font_size, 0x00ad, 0);
float w = font_get_glyph_advance(l_gl[i].font_rid, l_gl[i].font_size, gl)[(orientation == ORIENTATION_HORIZONTAL) ? 0 : 1];
if (width + adv + w <= p_width[chunk]) {
if (width + adv + w <= p_width[chunk] || w >= p_width[chunk]) {
last_safe_break = i;
word_count++;
}
@ -1161,7 +1161,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
if ((l_gl[i].flags & GRAPHEME_IS_SOFT_HYPHEN) == GRAPHEME_IS_SOFT_HYPHEN) {
uint32_t gl = font_get_glyph_index(l_gl[i].font_rid, l_gl[i].font_size, 0x00AD, 0);
float w = font_get_glyph_advance(l_gl[i].font_rid, l_gl[i].font_size, gl)[(orientation == ORIENTATION_HORIZONTAL) ? 0 : 1];
if (width + adv + w <= p_width) {
if (width + adv + w <= p_width || w >= p_width) {
last_safe_break = i;
word_count++;
}