[pango/tests-and-fixes: 7/7] break: Fix handling of tag sequences




commit 21a90c02c40889e619c11101442d33ccf6f91e9a
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jul 7 20:31:54 2021 -0400

    break: Fix handling of tag sequences
    
    Correctly classify tag characters as Grapheme_Extend,
    so that we don't end up putting grapheme boundaries
    in the middle of tag sequences.
    
    Includes a test.

 pango/break.c                   | 7 +++++++
 tests/breaks/eleven.break       | 2 ++
 tests/breaks/eleven.expected    | 6 ++++++
 tests/layouts/valid-19.expected | 2 +-
 4 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/pango/break.c b/pango/break.c
index 7d204fa3..58e039e5 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -409,6 +409,12 @@ pango_default_break (const gchar   *text,
                 GB_type = GB_Prepend;
                 break;
               }
+            /* Tag chars */
+            if (wc >= 0xE0020 && wc <= 0xE00FF)
+              {
+                GB_type = GB_Extend;
+                break;
+              }
             G_GNUC_FALLTHROUGH;
          case G_UNICODE_CONTROL:
          case G_UNICODE_LINE_SEPARATOR:
@@ -473,6 +479,7 @@ pango_default_break (const gchar   *text,
             break;
 
           case G_UNICODE_MODIFIER_SYMBOL:
+            /* Fitzpatrick modifiers */
             if (wc >= 0x1F3FB && wc <= 0x1F3FF)
               GB_type = GB_Extend;
             break;
diff --git a/tests/breaks/eleven.break b/tests/breaks/eleven.break
new file mode 100644
index 00000000..d674e3df
--- /dev/null
+++ b/tests/breaks/eleven.break
@@ -0,0 +1,2 @@
+# Various Emoji sequences
+β€οΈοΈŽοΈŽπŸ‘¨β€πŸ¦°πŸ‘¨πŸΏβ€πŸ¦±0οΈβƒ£πŸ΄σ ΅σ ³σ £σ ‘σ ΏπŸ‡©πŸ‡ͺ️
diff --git a/tests/breaks/eleven.expected b/tests/breaks/eleven.expected
new file mode 100644
index 00000000..533c9c14
--- /dev/null
+++ b/tests/breaks/eleven.expected
@@ -0,0 +1,6 @@
+Text:         ❀️︎︎  πŸ‘¨[0x200d]🦰  πŸ‘¨πŸΏ[0x200d]🦱  0️⃣  🏴[0xe0075][0xe0073][0xe0063][0xe0061][0xe007f]  πŸ‡©πŸ‡ͺ️ [0x0a] 
+Breaks:     c     lc          lc           lc   lc                                              lc   c      c
+Whitespace:                                                                                          w      w
+Words:      b     b           b            bs   be                                              b    b      b
+Sentences:  bs                                                                                       e      b
+Graphemes:  b     b           b            b    b                                               b    b      b
diff --git a/tests/layouts/valid-19.expected b/tests/layouts/valid-19.expected
index cf7f3820..1efc1d54 100644
--- a/tests/layouts/valid-19.expected
+++ b/tests/layouts/valid-19.expected
@@ -16,7 +16,7 @@ range 0 2147483647
 
 --- cursor positions
 
-0(0) 1(0) 5(0) 6(0) 13(0) 14(0) 21(0) 22(0) 30(0) 31(0) 34(0) 35(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 
51(0) 55(0) 59(0) 63(0) 67(0) 71(0) 72(0) 72(1) 75(0) 
+0(0) 1(0) 5(0) 6(0) 13(0) 14(0) 21(0) 22(0) 30(0) 31(0) 34(0) 35(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 
71(0) 72(0) 72(1) 75(0) 
 
 --- lines
 


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