diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-15 23:15:35 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-16 21:59:24 -0400 |
commit | 3e9751f21e4d4410f74f2f656b59fcc58d34cb09 (patch) | |
tree | d209cc8d6bb2a46f7f883ab77e7b0816efcf9912 | |
parent | 1ae643836c477b36683739b998161d116f799073 (diff) | |
download | pango-3e9751f21e4d4410f74f2f656b59fcc58d34cb09.tar.gz |
Insert hyphens in more places
Look for whether the char before the break
is not whitespace and doesn't look like a
hyphen.
-rw-r--r-- | pango/pango-layout.c | 23 |
1 files 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; + } } } |