[pango/test-branch] Insert hyphens in more places



commit 501ef92c803f244c8889102477fdbe15277d5109
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 15 23:15:35 2019 -0400

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]