Fix soft hyphen not working with small (or zero) line breaking width.

This commit is contained in:
Pāvels Nadtočajevs 2026-02-12 08:16:32 +02:00
parent 92a90a8e6f
commit f9f164f7ca
No known key found for this signature in database
GPG key ID: 8413210218EF35D2

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++;
}