From 3e9751f21e4d4410f74f2f656b59fcc58d34cb09 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 15 Jul 2019 23:15:35 -0400 Subject: Insert hyphens in more places Look for whether the char before the break is not whitespace and doesn't look like a hyphen. --- pango/pango-layout.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 00c78584..f79a73ad 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3482,8 +3482,27 @@ get_need_hyphen (PangoItem *item, for (i = 0, p = text + item->offset; i < item->num_chars; i++, p = g_utf8_next_char (p)) { - gunichar ch = g_utf8_get_char (p); - need_hyphen[i] = ch == 0xad; + gunichar wc = g_utf8_get_char (p); + switch (g_unichar_type(wc)) + { + case G_UNICODE_SPACE_SEPARATOR: + case G_UNICODE_LINE_SEPARATOR: + case G_UNICODE_PARAGRAPH_SEPARATOR: + need_hyphen[i] = FALSE; + break; + case G_UNICODE_CONTROL: + if (wc == '\t' || wc == '\n' || wc == '\r' || wc == '\f') + need_hyphen[i] = FALSE; + else + need_hyphen[i] = TRUE; + break; + default: + if (wc == '-' || wc == 0x2010 || wc == 0x2027) + need_hyphen[i] = FALSE; + else + need_hyphen[i] = TRUE; + break; + } } } -- cgit v1.2.1