summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-08 00:49:56 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-07-08 00:49:56 +0000
commitf3aec778e817f685498e949663c67b72f27e0308 (patch)
treedba40945c71b083a96f23eaa3665020c11ecf452
parentcfbf6dc53a61e1665b69149bcc1e003760a49499 (diff)
parent21a90c02c40889e619c11101442d33ccf6f91e9a (diff)
downloadpango-f3aec778e817f685498e949663c67b72f27e0308.tar.gz
Merge branch 'tests-and-fixes' into 'master'
tests: Dump grapheme boundaries too See merge request GNOME/pango!362
-rw-r--r--pango/break.c7
-rw-r--r--tests/breaks/eight.expected6
-rw-r--r--tests/breaks/eleven.break2
-rw-r--r--tests/breaks/eleven.expected6
-rw-r--r--tests/breaks/five.expected6
-rw-r--r--tests/breaks/four.expected1
-rw-r--r--tests/breaks/nine.break6
-rw-r--r--tests/breaks/nine.expected6
-rw-r--r--tests/breaks/one.expected1
-rw-r--r--tests/breaks/seven.expected6
-rw-r--r--tests/breaks/six.expected6
-rw-r--r--tests/breaks/ten.break2
-rw-r--r--tests/breaks/ten.expected6
-rw-r--r--tests/breaks/three.expected1
-rw-r--r--tests/breaks/two.expected1
-rw-r--r--tests/layouts/valid-17.expected35
-rw-r--r--tests/layouts/valid-17.markup2
-rw-r--r--tests/layouts/valid-18.expected40
-rw-r--r--tests/layouts/valid-18.markup2
-rw-r--r--tests/layouts/valid-19.expected46
-rw-r--r--tests/layouts/valid-19.markup2
-rw-r--r--tests/test-break.c27
-rw-r--r--tests/test-font.c98
-rw-r--r--tests/test-layout.c30
-rw-r--r--tests/testiter.c17
25 files changed, 345 insertions, 17 deletions
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/eight.expected b/tests/breaks/eight.expected
new file mode 100644
index 00000000..083ebeef
--- /dev/null
+++ b/tests/breaks/eight.expected
@@ -0,0 +1,6 @@
+Text: 我 能 吞 下 玻 璃 而 不 傷 身 體 [0x0a]
+Breaks: c lc lc lc lc lc lc lc lc lc lc c c
+Whitespace: w w
+Words: bs b b b b b b b b b b be b
+Sentences: bs e b
+Graphemes: b b b b b b b b b b b b b
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/breaks/five.expected b/tests/breaks/five.expected
new file mode 100644
index 00000000..38dc88ff
--- /dev/null
+++ b/tests/breaks/five.expected
@@ -0,0 +1,6 @@
+Text: H e r e [ ] i s [ ] s o m e [ ] t e x t [ ] w i t h [ ] b r e a k - a f f e c t i n g [ ] a t t r i b u t e s . [0x0a]
+Breaks: c c c c c lc c c lc c c c c lc c c c c lc c
+Whitespace: x x x x x x w w
+Words: bs be bs be bs be bs be bs be bs be bs be bs be b b
+Sentences: bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/four.expected b/tests/breaks/four.expected
index 6d3d1ba4..100eae24 100644
--- a/tests/breaks/four.expected
+++ b/tests/breaks/four.expected
@@ -3,3 +3,4 @@ Breaks: c c c c lc c c c lc c c c lc c c c lc c c lc c c c c
Whitespace: x x x x x x x x x x x x x w w
Words: bs b b b bse b b be bse b b be bse b b b bse b b bse b b b be bse b b bse b b b bse b b b b b bse b b bse b b b bse b b b b bse b b bse b b bse b b b b b bse b b be bse b b b bse b b bse b b bse b b b bse b bse b b bse b b b bse b bse b bse b b bse b b bse b b bse b b bse b b b b bse b b b bse b b be bse b be bse b b b b b b bse b be bse b b b bse b bse b b b b bse bse bse b bse b b b b bse b b bse b b bse b b bse b bse b b bse b b b b b bse b be bse b b bse b bse b b b b b b b b bse b b bse b b bse b b b bse b be bse b b b bse b b bse b bse b bse bse b b b bse b b b bse b b bse b bse b b b b bse b b b bse b bse b b b be bse b b b b bse b be bse b b b b bse b b b bse b bse b b b b b b b b be bse b b bse b b b b bse b b b bse b be bse b b b be b
Sentences: bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/nine.break b/tests/breaks/nine.break
new file mode 100644
index 00000000..14f2e1da
--- /dev/null
+++ b/tests/breaks/nine.break
@@ -0,0 +1,6 @@
+# indic
+मी काच खाऊ शकतो, मला ते दुखत नाह
+मैं काँच खा सकता हूँ, मुझे उस से कोई पीडा नहीं होत
+நான் கண்ணாடி சாப்பிடுவேன், அதனால் எனக்கு ஒரு கேடும் வராத
+ﻢﯾں ﮎﺎﻨﭼ ﮎھﺍ ﺲﮑﺗﺍ ہﻭں ﺍﻭﺭ ﻢﺟھے ﺖﮑﻠﯿﻓ ﻥہﯼں ہﻮﺘﯾ
+ﺰﻫ ﺶﻴﺸﻫ ﺥﻭړﻝې ﺶﻣ، ﻪﻐﻫ ﻡﺍ ﻦﻫ ﺥﻭږﻮﻳ
diff --git a/tests/breaks/nine.expected b/tests/breaks/nine.expected
new file mode 100644
index 00000000..8ffac505
--- /dev/null
+++ b/tests/breaks/nine.expected
@@ -0,0 +1,6 @@
+Text: मी [ ] का च [ ] खा ऊ [ ] श क तो , [ ] म ला [ ] ते [ ] दु ख त [ ] ना ह [0x0a] मैं [ ] काँ च [ ] खा [ ] स क ता [ ] हूँ , [ ] मु झे [ ] उ स [ ] से [ ] को ई [ ] पी डा [ ] न हीं [ ] हो त [0x0a] நா ன் [ ] க ண் ணா டி [ ] சா ப் பி டு வே ன் , [ ] அ த னா ல் [ ] எ ன க் கு [ ] ஒ ரு [ ] கே டு ம் [ ] வ ரா த [0x0a] ﻢ ﯾ ں [ ] ﮎ ﺎ ﻨ ﭼ [ ] ﮎ ھ ﺍ [ ] ﺲ ﮑ ﺗ ﺍ [ ] ہ ﻭ ں [ ] ﺍ ﻭ ﺭ [ ] ﻢ ﺟ ھ ے [ ] ﺖ ﮑ ﻠ ﯿ ﻓ [ ] ﻥ ہ ﯼ ں [ ] ہ ﻮ ﺘ ﯾ [ ] [0x0a] ﺰ ﻫ [ ] ﺶ ﻴ ﺸ ﻫ [ ] ﺥ ﻭ ړ ﻝ ې [ ] ﺶ ﻣ ، [ ] ﻪ ﻐ ﻫ [ ] ﻡ ﺍ [ ] ﻦ ﻫ [ ] ﺥ ﻭ ږ ﻮ ﻳ [0x0a]
+Breaks: c c lc c c lc c c lc c c c c lc c c lc c lc c c c lc c c c c lc c c lc c lc c c c lc c c lc c c lc c c lc c lc c c lc c c lc c c lc c c c c c lc c c c c lc c c c c c c c lc c c c c lc c c c c lc c c lc c c c lc c c c c c c c lc c c c c lc c c c lc c c c c lc c c c lc c c c lc c c c c lc c c c c c lc c c c c lc c c c c c c c c lc c c c c lc c c c c c lc c c c lc c c c lc c c lc c c lc c c c c c c
+Whitespace: x x x x x x x w x x x x x x x x x x x w x x x x x x x w x x x x x x x x x x w x x x x x x x w w
+Words: bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be b bs be bs be bs be bs be b bs be bs be bs be bs be b
+Sentences: bs e bs e bs e bs e bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/one.expected b/tests/breaks/one.expected
index 66c6bd48..165e2d13 100644
--- a/tests/breaks/one.expected
+++ b/tests/breaks/one.expected
@@ -3,3 +3,4 @@ Breaks: c c c c lc c c c lc c c c lc c c c c lc c c c c
Whitespace: x x w w
Words: bs be bs be bs be b bs be b
Sentences: bs e bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/seven.expected b/tests/breaks/seven.expected
new file mode 100644
index 00000000..8cd411a6
--- /dev/null
+++ b/tests/breaks/seven.expected
@@ -0,0 +1,6 @@
+Text: 나 는 [ ] 유 리 를 [ ] 먹 을 [ ] 수 [ ] 있 어 요 . [ ] 그 래 도 [ ] 아 프 지 [ ] 않 아 요 [0x0a]
+Breaks: c lc c lc lc lc c lc lc c lc c lc lc lc c c lc lc lc c lc lc lc c lc lc lc c c
+Whitespace: x x x x x x x w w
+Words: bs be bs be bs be bs be bs be b bs be bs be bs be b
+Sentences: bs e bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/six.expected b/tests/breaks/six.expected
new file mode 100644
index 00000000..fba8e60d
--- /dev/null
+++ b/tests/breaks/six.expected
@@ -0,0 +1,6 @@
+Text: मी [ ] का च [ ] खा ऊ [ ] श क तो , [ ] म ला [ ] ते [ ] दु ख त [ ] ना ह [0x0a] मैं [ ] काँ च [ ] खा [ ] स क ता [ ] हूँ , [ ] मु झे [ ] उ स [ ] से [ ] को ई [ ] पी डा [ ] न हीं [ ] हो त [0x0a] நா ன் [ ] க ண் ணா டி [ ] சா ப் பி டு வே ன் , [ ] அ த னா ல் [ ] எ ன க் கு [ ] ஒ ரு [ ] கே டு ம் [ ] வ ரா த [0x0a] ﻢ ﯾ ں [ ] ﮎ ﺎ ﻨ ﭼ [ ] ﮎ ھ ﺍ [ ] ﺲ ﮑ ﺗ ﺍ [ ] ہ ﻭ ں [ ] ﺍ ﻭ ﺭ [ ] ﻢ ﺟ ھ ے [ ] ﺖ ﮑ ﻠ ﯿ ﻓ [ ] ﻥ ہ ﯼ ں [ ] ہ ﻮ ﺘ ﯾ [ ] ۔ [0x0a] ﺰ ﻫ [ ] ﺶ ﻴ ﺸ ﻫ [ ] ﺥ ﻭ ړ ﻝ ې [ ] ﺶ ﻣ ، [ ] ﻪ ﻐ ﻫ [ ] ﻡ ﺍ [ ] ﻦ ﻫ [ ] ﺥ ﻭ ږ ﻮ ﻳ [0x0a]
+Breaks: c c lc c c lc c c lc c c c c lc c c lc c lc c c c lc c c c c lc c c lc c lc c c c lc c c lc c c lc c c lc c lc c c lc c c lc c c lc c c c c c lc c c c c lc c c c c c c c lc c c c c lc c c c c lc c c lc c c c lc c c c c c c c lc c c c c lc c c c lc c c c c lc c c c lc c c c lc c c c c lc c c c c c lc c c c c lc c c c c c c c c c lc c c c c lc c c c c c lc c c c lc c c c lc c c lc c c lc c c c c c c
+Whitespace: x x x x x x x w x x x x x x x x x x x w x x x x x x x w x x x x x x x x x x w x x x x x x x w w
+Words: bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be b bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be bs be b b bs be bs be bs be bs be b bs be bs be bs be bs be b
+Sentences: bs e bs e bs e bs e bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/ten.break b/tests/breaks/ten.break
new file mode 100644
index 00000000..d3cbd982
--- /dev/null
+++ b/tests/breaks/ten.break
@@ -0,0 +1,2 @@
+# some special combinations to hit branches in break-indic.c
+iක්‍ක a‌a்
diff --git a/tests/breaks/ten.expected b/tests/breaks/ten.expected
new file mode 100644
index 00000000..6577c9fb
--- /dev/null
+++ b/tests/breaks/ten.expected
@@ -0,0 +1,6 @@
+Text: i ක්[0x200d]ක [ ] a[0x200c] a் [0x0a]
+Breaks: c c c lc c c c
+Whitespace: x w w
+Words: bs be bs be b
+Sentences: bs e b
+Graphemes: b b b b b b b
diff --git a/tests/breaks/three.expected b/tests/breaks/three.expected
index 0e60f876..2ff60a9c 100644
--- a/tests/breaks/three.expected
+++ b/tests/breaks/three.expected
@@ -3,3 +3,4 @@ Breaks: c c c c lc c c c Lc c c c lc c c c c c c c c
Whitespace: x w x w w
Words: bs be bs be bs be bs be b
Sentences: bs e bs e b
+Graphemes: b b b b b b b b b b b b b b b b b b b b b b b
diff --git a/tests/breaks/two.expected b/tests/breaks/two.expected
index 7ff48c28..c7f983ee 100644
--- a/tests/breaks/two.expected
+++ b/tests/breaks/two.expected
@@ -3,3 +3,4 @@ Breaks: c c c c c c c c c c c
Whitespace: w w
Words: bs e s be b
Sentences: bs e b
+Graphemes: b b b b b b b b b b b
diff --git a/tests/layouts/valid-17.expected b/tests/layouts/valid-17.expected
new file mode 100644
index 00000000..4b3192fb
--- /dev/null
+++ b/tests/layouts/valid-17.expected
@@ -0,0 +1,35 @@
+some|bla|bla|bla
+
+--- parameters
+
+wrapped: 1
+ellipsized: 0
+lines: 3
+width: 102400
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 12(1) 14(0) 15(0) 15(1) 17(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'some|bla|bla|'
+i=2, index=13, paragraph-start=0, dir=ltr 'bla
+'
+i=3, index=17, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=13, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'some|bla|bla|'
+i=2, index=13, no run, line end
+i=3, index=13, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'bla'
+i=4, index=16, no run, line end
+i=5, index=17, no run, line end
diff --git a/tests/layouts/valid-17.markup b/tests/layouts/valid-17.markup
new file mode 100644
index 00000000..d804c20a
--- /dev/null
+++ b/tests/layouts/valid-17.markup
@@ -0,0 +1,2 @@
+justify=true,width=100
+some|bla|bla|bla
diff --git a/tests/layouts/valid-18.expected b/tests/layouts/valid-18.expected
new file mode 100644
index 00000000..614321b3
--- /dev/null
+++ b/tests/layouts/valid-18.expected
@@ -0,0 +1,40 @@
+some line breaks
and mis­ce­llaneous ignora‌bles
+
+--- parameters
+
+wrapped: 1
+ellipsized: 0
+lines: 3
+
+--- attributes
+
+range 0 57
+[0,57]show=7
+range 57 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 16(1) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 28(0) 29(0) 30(0) 32(0) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 46(0) 47(0) 48(0) 49(0) 53(0) 54(0) 55(0) 56(0) 56(1) 58(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'some line breaks
'
+i=2, index=19, paragraph-start=0, dir=ltr 'and mis­ce­llaneous ignora‌bles
+'
+i=3, index=58, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=16, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'some line breaks'
+[0,57]show=7
+i=2, index=16, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
'
+[0,57]show=7
+i=3, index=19, no run, line end
+i=4, index=19, chars=32, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'and mis­ce­llaneous ignora‌bles'
+[0,57]show=7
+i=5, index=57, no run, line end
+i=6, index=58, no run, line end
diff --git a/tests/layouts/valid-18.markup b/tests/layouts/valid-18.markup
new file mode 100644
index 00000000..ab5f5f35
--- /dev/null
+++ b/tests/layouts/valid-18.markup
@@ -0,0 +1,2 @@
+
+<span show="spaces|line-breaks|ignorables">some line breaks
and mis­ce­llaneous ignora‌bles</span>
diff --git a/tests/layouts/valid-19.expected b/tests/layouts/valid-19.expected
new file mode 100644
index 00000000..1efc1d54
--- /dev/null
+++ b/tests/layouts/valid-19.expected
@@ -0,0 +1,46 @@
+ a⃠ 😊︎ 😊️ 🇩🇪 ✊ ✋🏾 0 # 🏴󠁵󠁳󠁣󠁡󠁿 ©
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 2
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- 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) 71(0) 72(0) 72(1) 75(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr ' a⃠ 😊︎ 😊️ 🇩🇪 ✊ ✋🏾 0 # 🏴󠁵󠁳󠁣󠁡󠁿 ©
+'
+i=2, index=75, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' a'
+i=2, index=2, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '⃠'
+i=3, index=5, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=4, index=6, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊︎'
+i=5, index=13, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=6, index=14, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '😊️'
+i=7, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=8, index=22, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '🇩🇪'
+i=9, index=30, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=10, index=31, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✊'
+i=11, index=34, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=12, index=35, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '✋🏾'
+i=13, index=42, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' 0 # '
+i=14, index=47, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '🏴󠁵󠁳󠁣󠁡󠁿'
+i=15, index=71, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=16, index=72, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '©'
+i=17, index=74, no run, line end
+i=18, index=75, no run, line end
diff --git a/tests/layouts/valid-19.markup b/tests/layouts/valid-19.markup
new file mode 100644
index 00000000..e48c9f0e
--- /dev/null
+++ b/tests/layouts/valid-19.markup
@@ -0,0 +1,2 @@
+# various Emoji segmentation cases
+ a⃠ 😊︎ 😊️ 🇩🇪 ✊ ✋🏾 0 # 🏴󠁵󠁳󠁣󠁡󠁿 ©
diff --git a/tests/test-break.c b/tests/test-break.c
index b06fb4c0..0158bd40 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -46,7 +46,7 @@ test_file (const gchar *filename, GString *string)
int len2;
char *p;
int i;
- GString *s1, *s2, *s3, *s4;
+ GString *s1, *s2, *s3, *s4, *s5;
int m;
char *test;
char *text;
@@ -73,6 +73,7 @@ test_file (const gchar *filename, GString *string)
pango_layout_set_text (layout, text, length);
pango_layout_set_attributes (layout, attributes);
+#if 0
if (pango_layout_get_unknown_glyphs_count (layout) > 0)
{
char *msg = g_strdup_printf ("Missing glyphs - skipping %s. Maybe fonts are missing?", filename);
@@ -87,6 +88,7 @@ test_file (const gchar *filename, GString *string)
g_free (text);
return FALSE;
}
+#endif
pango_layout_get_log_attrs (layout, &attrs, &len);
attrs2 = pango_layout_get_log_attrs_readonly (layout, &len2);
@@ -106,15 +108,17 @@ test_file (const gchar *filename, GString *string)
s2 = g_string_new ("Whitespace: ");
s3 = g_string_new ("Words:");
s4 = g_string_new ("Sentences:");
+ s5 = g_string_new ("Graphemes:");
g_string_append (string, "Text: ");
- m = MAX (MAX (s1->len, s2->len), MAX (s3->len, s4->len));
+ m = MAX (MAX (MAX (s1->len, s2->len), MAX (s3->len, s4->len)), s5->len);
g_string_append_printf (s1, "%*s", (int)(m - s1->len), "");
g_string_append_printf (s2, "%*s", (int)(m - s2->len), "");
g_string_append_printf (s3, "%*s", (int)(m - s3->len), "");
g_string_append_printf (s4, "%*s", (int)(m - s4->len), "");
+ g_string_append_printf (s5, "%*s", (int)(m - s5->len), "");
g_string_append_printf (string, "%*s", (int)(m - strlen ("Text: ")), "");
for (i = 0, p = text; i < len; i++, p = g_utf8_next_char (p))
@@ -124,6 +128,7 @@ test_file (const gchar *filename, GString *string)
int w = 0;
int o = 0;
int s = 0;
+ int g = 0;
if (log.is_mandatory_break)
{
@@ -183,14 +188,20 @@ test_file (const gchar *filename, GString *string)
g_string_append (s4, "e");
s++;
}
+ if (log.is_cursor_position)
+ {
+ g_string_append (s5, "b");
+ g++;
+ }
- m = MAX (MAX (b, w), MAX (o, s));
+ m = MAX (MAX (MAX (b, w), MAX (o, s)), g);
g_string_append_printf (string, "%*s", m, "");
g_string_append_printf (s1, "%*s", m - b, "");
g_string_append_printf (s2, "%*s", m - w, "");
g_string_append_printf (s3, "%*s", m - o, "");
g_string_append_printf (s4, "%*s", m - s, "");
+ g_string_append_printf (s5, "%*s", m - g, "");
if (i < len - 1)
{
@@ -202,6 +213,7 @@ test_file (const gchar *filename, GString *string)
g_string_append (s2, " ");
g_string_append (s3, " ");
g_string_append (s4, " ");
+ g_string_append (s5, " ");
}
else if (g_unichar_isgraph (ch) &&
!(g_unichar_type (ch) == G_UNICODE_LINE_SEPARATOR ||
@@ -212,6 +224,7 @@ test_file (const gchar *filename, GString *string)
g_string_append (s2, " ");
g_string_append (s3, " ");
g_string_append (s4, " ");
+ g_string_append (s5, " ");
}
else
{
@@ -221,6 +234,7 @@ test_file (const gchar *filename, GString *string)
g_string_append_printf (s2, "%*s", (int)strlen (str), "");
g_string_append_printf (s3, "%*s", (int)strlen (str), "");
g_string_append_printf (s4, "%*s", (int)strlen (str), "");
+ g_string_append_printf (s5, "%*s", (int)strlen (str), "");
g_free (str);
}
}
@@ -234,11 +248,14 @@ test_file (const gchar *filename, GString *string)
g_string_append (string, "\n");
g_string_append_len (string, s4->str, s4->len);
g_string_append (string, "\n");
+ g_string_append_len (string, s5->str, s5->len);
+ g_string_append (string, "\n");
g_string_free (s1, TRUE);
g_string_free (s2, TRUE);
g_string_free (s3, TRUE);
g_string_free (s4, TRUE);
+ g_string_free (s5, TRUE);
g_object_unref (layout);
g_free (attrs);
@@ -341,8 +358,8 @@ main (int argc, char *argv[])
if (strcmp (argv[1], "--legend") == 0)
{
g_print ("test-break uses the following symbols for log attrs\n\n");
- g_print ("Breaks: Words:\n"
- " L - mandatory break b - word boundary\n"
+ g_print ("Breaks: Words: Graphemes:\n"
+ " L - mandatory break b - word boundary b - grapheme boundary\n"
" l - line break s - word start\n"
" c - char break e - word end\n"
"\n"
diff --git a/tests/test-font.c b/tests/test-font.c
index d6ffc1a6..3c5f3070 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -31,9 +31,12 @@ static PangoContext *context;
static void
test_parse (void)
{
+ PangoFontDescription **descs;
PangoFontDescription *desc;
- desc = pango_font_description_from_string ("Cantarell 14");
+ descs = g_new (PangoFontDescription *, 2);
+
+ descs[0] = desc = pango_font_description_from_string ("Cantarell 14");
g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cantarell");
g_assert (!pango_font_description_get_size_is_absolute (desc));
@@ -45,9 +48,7 @@ test_parse (void)
g_assert_cmpint (pango_font_description_get_gravity (desc), ==, PANGO_GRAVITY_SOUTH);
g_assert_cmpint (pango_font_description_get_set_fields (desc), ==, PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_STYLE | PANGO_FONT_MASK_VARIANT | PANGO_FONT_MASK_WEIGHT | PANGO_FONT_MASK_STRETCH | PANGO_FONT_MASK_SIZE);
- pango_font_description_free (desc);
-
- desc = pango_font_description_from_string ("Sans Bold Italic Condensed 22.5px");
+ descs[1] = desc = pango_font_description_from_string ("Sans Bold Italic Condensed 22.5px");
g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Sans");
g_assert (pango_font_description_get_size_is_absolute (desc));
@@ -58,25 +59,25 @@ test_parse (void)
g_assert_cmpint (pango_font_description_get_stretch (desc), ==, PANGO_STRETCH_CONDENSED);
g_assert_cmpint (pango_font_description_get_gravity (desc), ==, PANGO_GRAVITY_SOUTH); g_assert_cmpint (pango_font_description_get_set_fields (desc), ==, PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_STYLE | PANGO_FONT_MASK_VARIANT | PANGO_FONT_MASK_WEIGHT | PANGO_FONT_MASK_STRETCH | PANGO_FONT_MASK_SIZE);
- pango_font_description_free (desc);
+ pango_font_descriptions_free (descs, 2);
}
static void
test_roundtrip (void)
{
PangoFontDescription *desc;
- gchar *str;
+ char *str;
desc = pango_font_description_from_string ("Cantarell 14");
str = pango_font_description_to_string (desc);
g_assert_cmpstr (str, ==, "Cantarell 14");
- pango_font_description_free (desc);
+ pango_font_description_free (desc);
g_free (str);
desc = pango_font_description_from_string ("Sans Bold Italic Condensed 22.5px");
str = pango_font_description_to_string (desc);
g_assert_cmpstr (str, ==, "Sans Bold Italic Condensed 22.5px");
- pango_font_description_free (desc);
+ pango_font_description_free (desc);
g_free (str);
}
@@ -319,6 +320,10 @@ static void
test_font_models (void)
{
PangoFontMap *map = pango_cairo_font_map_get_default ();
+ gboolean monospace_found = FALSE;
+ int n_families = 0;
+ int n_variable_families = 0;
+ int n_monospace_families = 0;
g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (map)) == PANGO_TYPE_FONT_FAMILY);
@@ -335,6 +340,14 @@ test_font_models (void)
g_assert_true (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)));
}
+ n_families++;
+
+ if (pango_font_family_is_variable (PANGO_FONT_FAMILY (obj)))
+ n_variable_families++;
+
+ if (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)))
+ n_monospace_families++;
+
for (guint j = 0; j < g_list_model_get_n_items (G_LIST_MODEL (obj)); j++)
{
GObject *obj2 = g_list_model_get_item (G_LIST_MODEL (obj), j);
@@ -349,11 +362,24 @@ test_font_models (void)
g_assert_true ((sizes == NULL) == (n_sizes == 0));
g_free (sizes);
+ if (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)))
+ {
+ if (pango_font_face_is_synthesized (PANGO_FONT_FACE (obj2)))
+ {
+ monospace_found = TRUE;
+ }
+ }
+
g_object_unref (obj2);
}
g_object_unref (obj);
}
+
+ g_assert_true (monospace_found);
+
+ g_print ("# %d font families, %d monospace, %d variable\n",
+ n_families, n_monospace_families, n_variable_families);
}
static void
@@ -381,6 +407,59 @@ test_font_metrics (void)
pango_font_metrics_unref (metrics);
}
+static void
+test_to_filename (void)
+{
+ PangoFontDescription *desc;
+ char *str;
+
+ desc = pango_font_description_from_string ("Futura Medium Italic 14");
+ str = pango_font_description_to_filename (desc);
+
+ g_assert_nonnull (strstr (str, "futura"));
+ g_assert_nonnull (strstr (str, "medium"));
+ g_assert_nonnull (strstr (str, "italic"));
+
+ g_free (str);
+
+ pango_font_description_free (desc);
+}
+
+static void
+test_set_gravity (void)
+{
+ PangoFontDescription *desc;
+
+ desc = pango_font_description_from_string ("Futura Medium Italic 14");
+ pango_font_description_set_gravity (desc, PANGO_GRAVITY_SOUTH);
+ g_assert_true (pango_font_description_get_set_fields (desc) & PANGO_FONT_MASK_GRAVITY);
+
+ pango_font_description_set_gravity (desc, PANGO_GRAVITY_AUTO);
+ g_assert_false (pango_font_description_get_set_fields (desc) & PANGO_FONT_MASK_GRAVITY);
+
+ pango_font_description_free (desc);
+}
+
+static void
+test_match (void)
+{
+ PangoFontDescription *desc;
+ PangoFontDescription *desc1;
+ PangoFontDescription *desc2;
+
+ desc = pango_font_description_from_string ("Futura Medium Italic 14");
+ desc1 = pango_font_description_from_string ("Futura Bold 16");
+ pango_font_description_set_style (desc1, PANGO_STYLE_OBLIQUE);
+ desc2 = pango_font_description_from_string ("Futura Medium 16");
+ pango_font_description_set_style (desc2, PANGO_STYLE_ITALIC);
+
+ g_assert_true (pango_font_description_better_match (desc, desc1, desc2));
+
+ pango_font_description_free (desc);
+ pango_font_description_free (desc1);
+ pango_font_description_free (desc2);
+}
+
int
main (int argc, char *argv[])
{
@@ -395,6 +474,9 @@ main (int argc, char *argv[])
g_test_add_func ("/pango/fontdescription/parse", test_parse);
g_test_add_func ("/pango/fontdescription/roundtrip", test_roundtrip);
g_test_add_func ("/pango/fontdescription/variation", test_variation);
+ g_test_add_func ("/pango/fontdescription/to-filename", test_to_filename);
+ g_test_add_func ("/pango/fontdescription/set-gravity", test_set_gravity);
+ g_test_add_func ("/pango/fontdescription/match", test_match);
g_test_add_func ("/pango/font/extents", test_extents);
g_test_add_func ("/pango/font/enumerate", test_enumerate);
g_test_add_func ("/pango/font/roundtrip/plain", test_roundtrip_plain);
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 0d71ab54..4c27585e 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -545,6 +545,13 @@ test_file (const char *filename, GString *string)
prev_index = run->item->offset;
next_index = run->item->offset + run->item->length;
+ {
+ PangoGlyphItem *run2 = pango_glyph_item_copy (run);
+ g_assert_cmpint (run2->item->offset, ==, run->item->offset);
+ g_assert_cmpint (run2->item->length, ==, run->item->length);
+ pango_glyph_item_free (run2);
+ }
+
pango_layout_line_get_x_ranges (line, prev_index, next_index, &ranges, &n_ranges);
/* The index is within the run, so the x should be in one of the ranges */
@@ -580,6 +587,7 @@ test_file (const char *filename, GString *string)
PangoRectangle line_ink, line_logical;
int baseline;
PangoLayoutLine *line;
+ PangoLayoutRun *run;
line = pango_layout_iter_get_line (iter);
@@ -602,6 +610,28 @@ test_file (const char *filename, GString *string)
{
g_assert_cmpint (line->start_index + line->length, <=, strlen (pango_layout_get_text (layout)));
}
+
+ run = pango_layout_iter_get_run (iter);
+
+ if (run)
+ {
+ const char *text;
+ int *widths;
+ int *widths2;
+
+ text = pango_layout_get_text (layout);
+
+ widths = g_new (int, run->item->num_chars);
+ pango_glyph_item_get_logical_widths (run, text, widths);
+
+ widths2 = g_new (int, run->item->num_chars);
+ pango_glyph_string_get_logical_widths (run->glyphs, text + run->item->offset, run->item->length, run->item->analysis.level, widths2);
+
+ g_assert_true (memcmp (widths, widths2, sizeof (int) * run->item->num_chars) == 0);
+
+ g_free (widths);
+ g_free (widths2);
+ }
}
while (pango_layout_iter_next_line (iter));
diff --git a/tests/testiter.c b/tests/testiter.c
index 653c4bec..c948c29f 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -278,7 +278,7 @@ test_glyphitem_iter (void)
{
PangoGlyphItemIter iter;
gboolean have_cluster;
-
+ PangoGlyphItemIter *iter2;
for (have_cluster = direction ?
pango_glyph_item_iter_init_start (&iter, run, text) :
@@ -289,9 +289,18 @@ test_glyphitem_iter (void)
pango_glyph_item_iter_prev_cluster (&iter))
{
verbose ("start index %d end index %d\n", iter.start_index, iter.end_index);
- g_assert (iter.start_index < iter.end_index);
- g_assert (iter.start_index + 2 >= iter.end_index);
- g_assert (iter.start_char + 1 == iter.end_char);
+ g_assert_true (iter.start_index < iter.end_index);
+ g_assert_true (iter.start_index + 2 >= iter.end_index);
+ g_assert_true (iter.start_char + 1 == iter.end_char);
+
+ iter2 = pango_glyph_item_iter_copy (&iter);
+ g_assert_true (iter2->start_glyph == iter.start_glyph);
+ g_assert_true (iter2->start_index == iter.start_index);
+ g_assert_true (iter2->start_char == iter.start_char);
+ g_assert_true (iter2->end_glyph == iter.end_glyph);
+ g_assert_true (iter2->end_index == iter.end_index);
+ g_assert_true (iter2->end_char == iter.end_char);
+ pango_glyph_item_iter_free (iter2);
}
}
}