diff options
28 files changed, 867 insertions, 29 deletions
diff --git a/tests/layouts/valid-1.expected b/tests/layouts/valid-1.expected index 292d6f43..411c7560 100644 --- a/tests/layouts/valid-1.expected +++ b/tests/layouts/valid-1.expected @@ -15,6 +15,14 @@ range 22 41 [22,41]underline=1 range 41 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 + +--- 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 47(1) 49(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr 'This is a test of the automatic emergency brake! diff --git a/tests/layouts/valid-10.expected b/tests/layouts/valid-10.expected new file mode 100644 index 00000000..137024b7 --- /dev/null +++ b/tests/layouts/valid-10.expected @@ -0,0 +1,37 @@ +Hello שלום Γειά σας + +--- parameters + +wrapped: 0 +ellipsized: 1 +lines: 2 +width: 102400 + +--- attributes + +range 0 2147483647 + +--- directions + +0 0 0 0 0 0 1 1 1 1 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) 12(0) 10(0) 8(0) 14(0) 15(0) 17(0) 19(0) 21(0) 23(0) 24(0) 26(0) 28(0) 28(1) 31(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלום Γειά σας +' +i=2, index=31, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello ' +i=2, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום' +i=3, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' ' +i=4, index=15, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γ' +i=5, index=17, chars=7, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'ειά σας' +[0,2147483647]fallback=0 +i=6, index=30, no run, line end +i=7, index=31, no run, line end diff --git a/tests/layouts/valid-10.markup b/tests/layouts/valid-10.markup new file mode 100644 index 00000000..15bf693d --- /dev/null +++ b/tests/layouts/valid-10.markup @@ -0,0 +1,2 @@ +width=100,justify=true,ellipsize=end +Hello שלום Γειά σας diff --git a/tests/layouts/valid-11.expected b/tests/layouts/valid-11.expected new file mode 100644 index 00000000..a1fafc31 --- /dev/null +++ b/tests/layouts/valid-11.expected @@ -0,0 +1,53 @@ +double low error + +--- parameters + +wrapped: 0 +ellipsized: 0 +lines: 2 +width: 225280 + +--- attributes + +range 0 6 +[0,6]underline=2 +[0,6]overline=1 +range 6 7 +range 7 10 +[7,10]underline=3 +[7,10]strikethrough=1 +range 10 11 +range 11 16 +[11,16]underline=4 +[11,16]rise=1024 +range 16 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) 13(0) 14(0) 15(0) 15(1) 17(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'double low error +' +i=2, index=17, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'double' +[0,6]underline=2 +[0,6]overline=1 +i=2, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' ' +i=3, index=7, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'low' +[7,10]underline=3 +[7,10]strikethrough=1 +i=4, index=10, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' ' +i=5, index=11, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'error' +[11,16]rise=1024 +[11,16]underline=4 +i=6, index=16, no run, line end +i=7, index=17, no run, line end diff --git a/tests/layouts/valid-11.markup b/tests/layouts/valid-11.markup new file mode 100644 index 00000000..fbf1abd2 --- /dev/null +++ b/tests/layouts/valid-11.markup @@ -0,0 +1,2 @@ +width=220,wrap=char +<span underline='double' overline='single'>double</span> <span underline='low' strikethrough='true'>low</span> <span underline='error' rise='1024'>error</span> diff --git a/tests/layouts/valid-12.expected b/tests/layouts/valid-12.expected new file mode 100644 index 00000000..d66ae134 --- /dev/null +++ b/tests/layouts/valid-12.expected @@ -0,0 +1,35 @@ +a b c d
e f g h + +--- parameters + +wrapped: 1 +ellipsized: 0 +lines: 3 + +--- 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 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 25(1) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 50(1) 52(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'a b c d
' +i=2, index=28, paragraph-start=0, dir=ltr 'e f g h +' +i=3, index=52, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'a b c d' +i=2, index=25, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
' +i=3, index=28, no run, line end +i=4, index=28, chars=23, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e f g h' +i=5, index=51, no run, line end +i=6, index=52, no run, line end diff --git a/tests/layouts/valid-12.markup b/tests/layouts/valid-12.markup new file mode 100644 index 00000000..b7306cc6 --- /dev/null +++ b/tests/layouts/valid-12.markup @@ -0,0 +1,2 @@ +wrap=word,tabs=0 50 100 150 200 +a b c d
e f g h diff --git a/tests/layouts/valid-13.expected b/tests/layouts/valid-13.expected new file mode 100644 index 00000000..3064610d --- /dev/null +++ b/tests/layouts/valid-13.expected @@ -0,0 +1,35 @@ +a b c d
e f g h + +--- parameters + +wrapped: 0 +ellipsized: 0 +lines: 1 + +--- 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 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 28(0) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 51(1) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'a b c d
e f g h +' + +--- runs + +i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'a b c d' +[0,-1]show=2 +i=2, index=25, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
' +[0,-1]show=2 +i=3, index=28, chars=24, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e f g h +' +[0,-1]show=2 +i=4, index=52, no run, line end diff --git a/tests/layouts/valid-13.markup b/tests/layouts/valid-13.markup new file mode 100644 index 00000000..be2345d1 --- /dev/null +++ b/tests/layouts/valid-13.markup @@ -0,0 +1,2 @@ +wrap=word,tabs=0 50 100 150 200,single_paragraph=true +a b c d
e f g h diff --git a/tests/layouts/valid-14.expected b/tests/layouts/valid-14.expected new file mode 100644 index 00000000..9c4d5111 --- /dev/null +++ b/tests/layouts/valid-14.expected @@ -0,0 +1,39 @@ +你好 Hello שלום Γειά σας + +--- parameters + +wrapped: 0 +ellipsized: 1 +lines: 2 +width: 166912 + +--- attributes + +range 0 2147483647 + +--- directions + +0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + +--- cursor positions + +0(0) 3(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 19(0) 17(0) 15(0) 21(0) 22(0) 24(0) 26(0) 28(0) 30(0) 31(0) 33(0) 35(0) 35(1) 38(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr '你好 Hello שלום Γειά σας +' +i=2, index=38, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=1, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, '你' +[0,2147483647]fallback=1 +i=2, index=3, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, '好' +i=3, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, ' ' +i=4, index=7, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello ' +i=5, index=19, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום' +i=6, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' ' +i=7, index=22, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας' +i=8, index=37, no run, line end +i=9, index=38, no run, line end diff --git a/tests/layouts/valid-14.markup b/tests/layouts/valid-14.markup new file mode 100644 index 00000000..48412c04 --- /dev/null +++ b/tests/layouts/valid-14.markup @@ -0,0 +1,2 @@ +line_spacing=1.5,width=163,ellipsize=start +你好 Hello שלום Γειά σας diff --git a/tests/layouts/valid-15.expected b/tests/layouts/valid-15.expected new file mode 100644 index 00000000..2711dfd8 --- /dev/null +++ b/tests/layouts/valid-15.expected @@ -0,0 +1,36 @@ +Lets see if this text is long enough to wrap due to height limitations. It might, or it might not. + +--- parameters + +wrapped: 1 +ellipsized: 1 +lines: 2 +width: 153600 +height: 40960 + +--- 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 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 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 24(1) 26(0) 27(0) 28(0) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0) 55(0) 56(0) 57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 63(0) 64(0) 65(0) 66(0) 67(0) 68(0) 69(0) 70(0) 71(0) 72(0) 73(0) 74(0) 75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 86(0) 87(0) 88(0) 89(0) 90(0) 91(0) 92(0) 93(0) 94(0) 95(0) 96(0) 97(0) 97(1) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'Lets see if this text is ' +i=2, index=25, paragraph-start=0, dir=ltr 'long enough to wrap due to height limitations. It might, or it might not. +' + +--- runs + +i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Lets see if this text is ' +i=2, index=25, no run, line end +i=3, index=25, chars=20, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'long enough to wrap ' +i=4, index=45, chars=53, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'due to height limitations. It might, or it might not.' +[0,2147483647]fallback=0 +i=5, index=98, no run, line end diff --git a/tests/layouts/valid-15.markup b/tests/layouts/valid-15.markup new file mode 100644 index 00000000..e3081c81 --- /dev/null +++ b/tests/layouts/valid-15.markup @@ -0,0 +1,2 @@ +ellipsize=end,height=40,width=150 +Lets see if this text is long enough to wrap due to height limitations. It might, or it might not. diff --git a/tests/layouts/valid-16.expected b/tests/layouts/valid-16.expected new file mode 100644 index 00000000..7ae3ae62 --- /dev/null +++ b/tests/layouts/valid-16.expected @@ -0,0 +1,37 @@ +Lets see if this text is long enough to wrap due to height limitations. It might, or it might not. + +--- parameters + +wrapped: 1 +ellipsized: 1 +lines: 3 +width: 153600 + +--- 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 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 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 24(1) 26(0) 27(0) 28(0) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0) 55(0) 56(0) 57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 63(0) 64(0) 65(0) 66(0) 67(0) 68(0) 69(0) 70(0) 71(0) 72(0) 73(0) 74(0) 75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 86(0) 87(0) 88(0) 89(0) 90(0) 91(0) 92(0) 93(0) 94(0) 95(0) 96(0) 97(0) 97(1) 99(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'Lets see if this text is ' +i=2, index=25, paragraph-start=0, dir=ltr 'long enough to wrap due to height limitations. It might, or it might not. +' +i=3, index=99, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Lets see if this text is ' +i=2, index=25, no run, line end +i=3, index=25, chars=20, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'long enough to wrap ' +i=4, index=45, chars=53, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'due to height limitations. It might, or it might not.' +[0,2147483647]fallback=0 +i=5, index=98, no run, line end +i=6, index=99, no run, line end diff --git a/tests/layouts/valid-16.markup b/tests/layouts/valid-16.markup new file mode 100644 index 00000000..91a8ae37 --- /dev/null +++ b/tests/layouts/valid-16.markup @@ -0,0 +1,2 @@ +wrap=word-char,ellipsize=end,width=150,height=-2 +Lets see if this text is long enough to wrap due to height limitations. It might, or it might not. diff --git a/tests/layouts/valid-2.expected b/tests/layouts/valid-2.expected index 2efc56fe..b71f5da3 100644 --- a/tests/layouts/valid-2.expected +++ b/tests/layouts/valid-2.expected @@ -16,6 +16,14 @@ range 20 25 [20,25]underline=1 range 25 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 + +--- 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 31(1) 33(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr 'test the blue drink after dinner diff --git a/tests/layouts/valid-3.expected b/tests/layouts/valid-3.expected index 247c61bf..d090bac0 100644 --- a/tests/layouts/valid-3.expected +++ b/tests/layouts/valid-3.expected @@ -10,6 +10,14 @@ lines: 2 range 0 2147483647 +--- directions + +0 0 0 0 0 0 0 + +--- cursor positions + +0(0) 1(0) 2(0) 3(0) 10(0) 10(1) 12(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr 'ABC😀️D diff --git a/tests/layouts/valid-4.expected b/tests/layouts/valid-4.expected index 66796cb5..49688492 100644 --- a/tests/layouts/valid-4.expected +++ b/tests/layouts/valid-4.expected @@ -11,6 +11,14 @@ width: 192512 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 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 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 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 26(0) 27(0) 28(0) 29(0) 30(0) 30(1) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0) 55(0) 56(0) 57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 62(1) 64(0) 65(0) 66(0) 67(0) 68(0) 69(0) 70(0) 71(0) 72(0) 73(0) 74(0) 75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 87(0) 89(0) 91(0) 92(0) 93(0) 94(0) 94(1) 97(0) 98(0) 100(0) 101(0) 102(0) 103(0) 104(0) 105(0) 106(0) 107(0) 108(0) 109(0) 110(0) 111(0) 112(0) 113(0) 114(0) 115(0) 116(0) 117(0) 118(0) 119(0) 120(0) 121(0) 122(0) 123(0) 123(1) 125(0) 126(0) 127(0) 128(0) 129(0) 130(0) 131(0) 132(0) 133(0) 134(0) 135(0) 136(0) 137(0) 138(0) 139(0) 140(0) 141(0) 142(0) 143(0) 144(0) 145(0) 146(0) 147(0) 148(0) 149(0) 150(0) 150(1) 152(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr 'This paragraph should actual' diff --git a/tests/layouts/valid-5.expected b/tests/layouts/valid-5.expected index 5c6fa749..ce4ff215 100644 --- a/tests/layouts/valid-5.expected +++ b/tests/layouts/valid-5.expected @@ -15,6 +15,14 @@ range 21 31 [21,31]font-features=tnum=1 range 31 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 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 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) 17(0) 18(0) 19(0) 20(0) 20(1) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(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) 43(1) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0) 55(0) 56(0) 57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 63(0) 64(0) 65(0) 66(0) 67(0) 67(1) 69(0) 70(0) 71(0) 72(0) 73(0) 74(0) 75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 86(0) 87(0) 88(0) 89(0) 89(1) 91(0) 92(0) 93(0) 94(0) 95(0) 96(0) 97(0) 98(0) 99(0) 100(0) 101(0) 102(0) 103(0) 104(0) 105(0) 106(0) 107(0) 108(0) 109(0) 110(0) 111(0) 112(0) 113(0) 114(0) 115(0) 116(0) 116(1) 118(0) 119(0) 120(0) 121(0) 122(0) 123(0) 123(1) 125(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr 'A test with multiple ' diff --git a/tests/layouts/valid-6.expected b/tests/layouts/valid-6.expected index b8f90c34..040e0fa4 100644 --- a/tests/layouts/valid-6.expected +++ b/tests/layouts/valid-6.expected @@ -10,6 +10,14 @@ lines: 2 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 + +--- cursor positions + +0(0) 1(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 25(1) 27(0) + --- lines i=1, index=0, paragraph-start=1, dir=ltr ' 0️⃣ Keycap Digit Zero diff --git a/tests/layouts/valid-7.expected b/tests/layouts/valid-7.expected new file mode 100644 index 00000000..7560a9cc --- /dev/null +++ b/tests/layouts/valid-7.expected @@ -0,0 +1,43 @@ +This is a test of the automatic emergency brake! + +--- parameters + +wrapped: 0 +ellipsized: 1 +lines: 2 +width: 204800 +indent: 51200 + +--- attributes + +range 0 22 +range 22 41 +[22,41]foreground=#00000000ffff +[22,41]underline=1 +range 41 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 + +--- 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) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(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) 44(0) 45(0) 46(0) 47(0) 47(1) 49(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'This is a test of the automatic emergency brake! +' +i=2, index=49, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=12, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This is a te' +i=2, index=12, chars=26, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'st of the automatic emerge' +[0,2147483647]fallback=0 +i=3, index=38, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ncy' +[22,41]foreground=#00000000ffff +[22,41]underline=1 +i=4, index=41, chars=7, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' brake!' +i=5, index=48, no run, line end +i=6, index=49, no run, line end diff --git a/tests/layouts/valid-7.markup b/tests/layouts/valid-7.markup new file mode 100644 index 00000000..d5f9821e --- /dev/null +++ b/tests/layouts/valid-7.markup @@ -0,0 +1,2 @@ +width=200,indent=50,ellipsize=middle +This is a test of the <span foreground="#0000ff" underline="single">automatic emergency</span> brake! diff --git a/tests/layouts/valid-8.expected b/tests/layouts/valid-8.expected new file mode 100644 index 00000000..185ba373 --- /dev/null +++ b/tests/layouts/valid-8.expected @@ -0,0 +1,34 @@ +Hello שלום Γειά σας + +--- parameters + +wrapped: 0 +ellipsized: 0 +lines: 2 + +--- attributes + +range 0 2147483647 + +--- directions + +0 0 0 0 0 0 1 1 1 1 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) 12(0) 10(0) 8(0) 14(0) 15(0) 17(0) 19(0) 21(0) 23(0) 24(0) 26(0) 28(0) 28(1) 31(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלום Γειά σας +' +i=2, index=31, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello ' +i=2, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום' +i=3, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' ' +i=4, index=15, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας' +i=5, index=30, no run, line end +i=6, index=31, no run, line end diff --git a/tests/layouts/valid-8.markup b/tests/layouts/valid-8.markup new file mode 100644 index 00000000..3272ea2b --- /dev/null +++ b/tests/layouts/valid-8.markup @@ -0,0 +1,2 @@ +spacing=50,auto_dir=false,alignment=center +Hello שלום Γειά σας diff --git a/tests/layouts/valid-9.expected b/tests/layouts/valid-9.expected new file mode 100644 index 00000000..d1388f62 --- /dev/null +++ b/tests/layouts/valid-9.expected @@ -0,0 +1,49 @@ +Hello שלום Γειά σας + +--- parameters + +wrapped: 1 +ellipsized: 0 +lines: 5 +width: 102400 + +--- attributes + +range 0 30 +[0,30]letter-spacing=8888 +range 30 2147483647 + +--- directions + +0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + +--- cursor positions + +0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 5(1) 12(0) 10(0) 8(0) 14(0) 14(1) 17(0) 19(0) 21(0) 23(0) 23(1) 26(0) 28(0) 28(1) 31(0) + +--- lines + +i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלו' +i=2, index=12, paragraph-start=0, dir=ltr 'ם ' +i=3, index=15, paragraph-start=0, dir=ltr 'Γειά ' +i=4, index=24, paragraph-start=0, dir=ltr 'σας +' +i=5, index=31, paragraph-start=1, dir=ltr '' + +--- runs + +i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello ' +[0,30]letter-spacing=8888 +i=2, index=6, no run, line end +i=3, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום' +[0,30]letter-spacing=8888 +i=4, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' ' +[0,30]letter-spacing=8888 +i=5, index=15, no run, line end +i=6, index=15, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά ' +[0,30]letter-spacing=8888 +i=7, index=24, no run, line end +i=8, index=24, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'σας' +[0,30]letter-spacing=8888 +i=9, index=30, no run, line end +i=10, index=31, no run, line end diff --git a/tests/layouts/valid-9.markup b/tests/layouts/valid-9.markup new file mode 100644 index 00000000..ced8f8e5 --- /dev/null +++ b/tests/layouts/valid-9.markup @@ -0,0 +1,2 @@ +width=100 +<span letter_spacing="8888">Hello שלום Γειά σας</span> diff --git a/tests/test-break.c b/tests/test-break.c index b906a7e2..319805df 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -41,7 +41,9 @@ test_file (const gchar *filename, GString *string) gsize length; GError *error = NULL; PangoLogAttr *attrs; + const PangoLogAttr *attrs2; int len; + int len2; char *p; int i; GString *s1, *s2, *s3, *s4; @@ -84,6 +86,10 @@ test_file (const gchar *filename, GString *string) } pango_layout_get_log_attrs (layout, &attrs, &len); + attrs2 = pango_layout_get_log_attrs_readonly (layout, &len2); + + g_assert_cmpint (len, ==, len2); + g_assert_true (memcmp (attrs, attrs2, sizeof (PangoLogAttr) * len) == 0); layout2 = pango_layout_copy (layout); attrs2 = pango_layout_get_log_attrs_readonly (layout2, &len2); diff --git a/tests/test-layout.c b/tests/test-layout.c index 9c5d13a0..0d71ab54 100644 --- a/tests/test-layout.c +++ b/tests/test-layout.c @@ -178,26 +178,100 @@ dump_runs (PangoLayout *layout, GString *string) } static void -parse_params (const gchar *str, - gint *width, - gint *ellipsize_at, - PangoEllipsizeMode *ellipsize, - PangoWrapMode *wrap) +dump_directions (PangoLayout *layout, GString *string) { - gchar **strings; - gchar **str2; - gint i; + const char *text, *p; + + text = pango_layout_get_text (layout); + for (p = text; *p; p = g_utf8_next_char (p)) + { + g_string_append_printf (string, "%d ", pango_layout_get_direction (layout, p - text)); + } + g_string_append (string, "\n"); +} + +static void +dump_cursor_positions (PangoLayout *layout, GString *string) +{ + int index, trailing; + + index = 0; + trailing = 0; + + while (index < G_MAXINT) + { + g_string_append_printf (string, "%d(%d) ", index, trailing); + pango_layout_move_cursor_visually (layout, TRUE, index, trailing, 1, &index, &trailing); + } + + g_string_append (string, "\n"); +} + +typedef struct { + int width; + int height; + int indent; + int spacing; + float line_spacing; + PangoEllipsizeMode ellipsize; + PangoWrapMode wrap; + PangoAlignment alignment; + gboolean justify; + gboolean auto_dir; + gboolean single_paragraph; + PangoTabArray *tabs; +} LayoutParams; + +static void +init_params (LayoutParams *params) +{ + params->width = -1; + params->height = -1; + params->indent = 0; + params->spacing = 0; + params->line_spacing = 0.0; + params->ellipsize = PANGO_ELLIPSIZE_NONE; + params->wrap = PANGO_WRAP_WORD; + params->alignment = PANGO_ALIGN_LEFT; + params->justify = FALSE; + params->auto_dir = TRUE; + params->single_paragraph = FALSE; + params->tabs = NULL; +} + +static void +parse_params (const char *str, + LayoutParams *params) +{ + char **strings; + int i; GEnumClass *eclass; GEnumValue *ev; strings = g_strsplit (str, ",", -1); for (i = 0; strings[i]; i++) { - str2 = g_strsplit (strings[i], "=", -1); + char **str2 = g_strsplit (strings[i], "=", -1); if (strcmp (str2[0], "width") == 0) - *width = (gint) g_ascii_strtoll (str2[1], NULL, 10); - else if (strcmp (str2[0], "ellipsize-at") == 0) - *ellipsize_at = (gint) g_ascii_strtoll (str2[1], NULL, 10); + { + params->width = (int) g_ascii_strtoll (str2[1], NULL, 10); + } + else if (strcmp (str2[0], "height") == 0) + { + params->height = (int) g_ascii_strtoll (str2[1], NULL, 10); + } + else if (strcmp (str2[0], "indent") == 0) + { + params->indent = (int) g_ascii_strtoll (str2[1], NULL, 10); + } + else if (strcmp (str2[0], "spacing") == 0) + { + params->spacing = (int) g_ascii_strtoll (str2[1], NULL, 10); + } + else if (strcmp (str2[0], "line_spacing") == 0) + { + params->line_spacing = (float) g_ascii_strtod (str2[1], NULL); + } else if (strcmp (str2[0], "ellipsize") == 0) { eclass = g_type_class_ref (PANGO_TYPE_ELLIPSIZE_MODE); @@ -205,7 +279,7 @@ parse_params (const gchar *str, if (!ev) ev = g_enum_get_value_by_nick (eclass, str2[1]); if (ev) - *ellipsize = ev->value; + params->ellipsize = ev->value; g_type_class_unref (eclass); } else if (strcmp (str2[0], "wrap") == 0) @@ -215,28 +289,89 @@ parse_params (const gchar *str, if (!ev) ev = g_enum_get_value_by_nick (eclass, str2[1]); if (ev) - *wrap = ev->value; + params->wrap = ev->value; g_type_class_unref (eclass); } + else if (strcmp (str2[0], "alignment") == 0) + { + eclass = g_type_class_ref (PANGO_TYPE_ALIGNMENT); + ev = g_enum_get_value_by_name (eclass, str2[1]); + if (!ev) + ev = g_enum_get_value_by_nick (eclass, str2[1]); + if (ev) + params->alignment = ev->value; + g_type_class_unref (eclass); + } + else if (strcmp (str2[0], "justify") == 0) + { + params->justify = g_str_equal (str2[1], "true"); + } + else if (strcmp (str2[0], "auto_dir") == 0) + { + params->auto_dir = g_str_equal (str2[1], "true"); + } + else if (strcmp (str2[0], "single_paragraph") == 0) + { + params->single_paragraph = g_str_equal (str2[1], "true"); + } + else if (strcmp (str2[0], "tabs") == 0) + { + char **str3 = g_strsplit (strings[i], " ", -1); + params->tabs = pango_tab_array_new (g_strv_length (str3), TRUE); + for (int j = 0; str3[j]; j++) + { + int tab = (int) g_ascii_strtoll (str3[j], NULL, 10); + pango_tab_array_set_tab (params->tabs, j, PANGO_TAB_LEFT, tab); + } + g_strfreev (str3); + } + g_strfreev (str2); } g_strfreev (strings); } +#define assert_layout_changed(layout) \ + g_assert_cmpuint (pango_layout_get_serial (layout), !=, serial); \ + serial = pango_layout_get_serial (layout); + +#define assert_rectangle_equal(r1, r2) \ + g_assert_true((r1)->x == (r2)->x && \ + (r1)->y == (r2)->y && \ + (r1)->width == (r2)->width && \ + (r1)->height == (r2)->height) + +#define assert_rectangle_contained(r1, r2) \ + g_assert_true ((r1)->x >= (r2)->x && \ + (r1)->y >= (r2)->y && \ + (r1)->x + (r1)->width <= (r2)->x + (r2)->width && \ + (r1)->y + (r1)->height <= (r2)->y + (r2)->height) + +#define assert_rectangle_size_contained(r1, r2) \ + g_assert_true ((r1)->width <= (r2)->width && \ + (r1)->height <= (r2)->height) + static void -test_file (const gchar *filename, GString *string) +test_file (const char *filename, GString *string) { - gchar *contents; - gchar *markup; + char *contents; + char *markup; gsize length; GError *error = NULL; PangoLayout *layout; - gchar *p; - gint width = 0; - gint ellipsize_at = 0; - PangoEllipsizeMode ellipsize = PANGO_ELLIPSIZE_NONE; - PangoWrapMode wrap = PANGO_WRAP_WORD; + char *p; + LayoutParams params; PangoFontDescription *desc; + PangoFontDescription *desc2; + guint serial; + PangoRectangle ink_rect, logical_rect; + PangoRectangle ink_rect1, logical_rect1; + int width, height; + int width1, height1; + PangoTabArray *tabs; + GSList *lines, *l; + PangoLayoutIter *iter; + PangoLayoutIter *iter2; if (context == NULL) context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); @@ -250,36 +385,266 @@ test_file (const gchar *filename, GString *string) *p = '\0'; length = strlen (markup); - parse_params (contents, &width, &ellipsize_at, &ellipsize, &wrap); + init_params (¶ms); layout = pango_layout_new (context); + + serial = pango_layout_get_serial (layout); + g_assert_cmpuint (serial, !=, 0); + + /* Check initial values */ + g_assert_cmpint (pango_layout_get_width (layout), ==, params.width); + g_assert_cmpint (pango_layout_get_height (layout), ==, params.height); + g_assert_cmpint (pango_layout_get_indent (layout), ==, params.indent); + g_assert_cmpint (pango_layout_get_spacing (layout), ==, params.spacing); + g_assert_cmpfloat (pango_layout_get_line_spacing (layout), ==, params.line_spacing); + g_assert_cmpint (pango_layout_get_ellipsize (layout), ==, params.ellipsize); + g_assert_cmpint (pango_layout_get_wrap (layout), ==, params.wrap); + g_assert_cmpint (pango_layout_get_alignment (layout), ==, params.alignment); + g_assert_cmpint (pango_layout_get_justify (layout), ==, params.justify); + g_assert_cmpint (pango_layout_get_auto_dir (layout), ==, params.auto_dir); + g_assert_cmpint (pango_layout_get_single_paragraph_mode (layout), ==, params.single_paragraph); + + g_assert_cmpstr (pango_layout_get_text (layout), ==, ""); + g_assert_null (pango_layout_get_attributes (layout)); + g_assert_null (pango_layout_get_tabs (layout)); + g_assert_null (pango_layout_get_font_description (layout)); + g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, FALSE); + g_assert_cmpint (pango_layout_is_wrapped (layout), ==, FALSE); + desc = pango_font_description_from_string ("Cantarell 11"); pango_layout_set_font_description (layout, desc); + desc2 = pango_layout_get_font_description (layout); + g_assert_true (pango_font_description_equal (desc, desc2)); pango_font_description_free (desc); + assert_layout_changed (layout); pango_layout_set_markup (layout, markup, length); - g_free (contents); + assert_layout_changed (layout); + + parse_params (contents, ¶ms); + + pango_layout_set_width (layout, params.width > 0 ? params.width * PANGO_SCALE : -1); + pango_layout_set_height (layout, params.height > 0 ? params.height * PANGO_SCALE : params.height); + pango_layout_set_indent (layout, params.indent * PANGO_SCALE); + pango_layout_set_spacing (layout, params.spacing * PANGO_SCALE); + pango_layout_set_line_spacing (layout, params.line_spacing); + pango_layout_set_ellipsize (layout, params.ellipsize); + pango_layout_set_wrap (layout, params.wrap); + pango_layout_set_alignment (layout, params.alignment); + pango_layout_set_justify (layout, params.justify); + pango_layout_set_auto_dir (layout, params.auto_dir); + pango_layout_set_single_paragraph_mode (layout, params.single_paragraph); + pango_layout_set_tabs (layout, params.tabs); + + /* Check the values we set */ + g_assert_cmpint (pango_layout_get_width (layout), ==, params.width > 0 ? params.width * PANGO_SCALE : -1); + g_assert_cmpint (pango_layout_get_height (layout), ==, params.height > 0 ? params.height * PANGO_SCALE : params.height); + g_assert_cmpint (pango_layout_get_indent (layout), ==, params.indent * PANGO_SCALE); + g_assert_cmpint (pango_layout_get_spacing (layout), ==, params.spacing * PANGO_SCALE); + g_assert_cmpfloat (pango_layout_get_line_spacing (layout), ==, params.line_spacing); + g_assert_cmpint (pango_layout_get_ellipsize (layout), ==, params.ellipsize); + g_assert_cmpint (pango_layout_get_wrap (layout), ==, params.wrap); + g_assert_cmpint (pango_layout_get_alignment (layout), ==, params.alignment); + g_assert_cmpint (pango_layout_get_justify (layout), ==, params.justify); + g_assert_cmpint (pango_layout_get_auto_dir (layout), ==, params.auto_dir); + g_assert_cmpint (pango_layout_get_single_paragraph_mode (layout), ==, params.single_paragraph); + + tabs = pango_layout_get_tabs (layout); + g_assert_true ((tabs == NULL) == (params.tabs == NULL)); + if (tabs) + pango_tab_array_free (tabs); + + g_assert_cmpint (pango_layout_get_character_count (layout), ==, g_utf8_strlen (pango_layout_get_text (layout), -1)); + + /* Some checks on extents - we have to be careful here, since we + * don't want to depend on font metrics. + */ + pango_layout_get_extents (layout, &ink_rect, &logical_rect); + pango_extents_to_pixels (&ink_rect, NULL); + pango_extents_to_pixels (&logical_rect, NULL); + pango_layout_get_pixel_extents (layout, &ink_rect1, &logical_rect1); + pango_layout_get_size (layout, &width, &height); + pango_layout_get_pixel_size (layout, &width1, &height1); + + assert_rectangle_equal (&ink_rect, &ink_rect1); + assert_rectangle_equal (&logical_rect, &logical_rect1); + g_assert_cmpint (PANGO_PIXELS (width), ==, logical_rect.width); + g_assert_cmpint (PANGO_PIXELS (height), ==, logical_rect.height); + g_assert_cmpint (width1, ==, logical_rect1.width); + g_assert_cmpint (height1, ==, logical_rect1.height); + + lines = pango_layout_get_lines (layout); + for (l = lines; l; l = l->next) + { + PangoLayoutLine *line = l->data; + int line_height, line_width; + int line_x; + PangoRectangle line_ink, line_logical; + PangoRectangle line_ink1, line_logical1; + gboolean done; + + pango_layout_line_get_height (line, &line_height); + g_assert_cmpint (line_height, <=, height); + + pango_layout_line_get_extents (line, &line_ink, &line_logical); + line_x = line_logical.x; + line_width = line_logical.width; + pango_extents_to_pixels (&line_ink, NULL); + pango_extents_to_pixels (&line_logical, NULL); + pango_layout_line_get_pixel_extents (line, &line_ink1, &line_logical1); + + /* Not in layout coordinates, so just compare sizes */ + assert_rectangle_size_contained (&line_ink, &ink_rect); + assert_rectangle_size_contained (&line_logical, &logical_rect); + assert_rectangle_size_contained (&line_ink1, &ink_rect1); + assert_rectangle_size_contained (&line_logical1, &logical_rect1); + + if (pango_layout_is_ellipsized (layout)) + continue; + + /* FIXME: should have a way to position iters */ + iter = pango_layout_get_iter (layout); + while (pango_layout_iter_get_line_readonly (iter) != line) + pango_layout_iter_next_line (iter); + + done = FALSE; + while (!done && pango_layout_iter_get_line_readonly (iter) == line) + { + int prev_index, index, next_index; + int x, index2, trailing; + int *ranges; + int n_ranges; + gboolean found_range; + PangoLayoutRun *run; + + index = pango_layout_iter_get_index (iter); + run = pango_layout_iter_get_run_readonly (iter); + + if (!pango_layout_iter_next_cluster (iter)) + done = TRUE; + + pango_layout_line_index_to_x (line, index, 0, &x); + pango_layout_line_x_to_index (line, x, &index2, &trailing); + +#if 0 + /* FIXME: why doesn't this hold true? */ + g_assert_cmpint (index2, ==, index); + g_assert_cmpint (trailing, ==, 0); +#endif + + g_assert_cmpint (0, <=, x); + g_assert_cmpint (x, <=, line_width); - if (width != 0) - pango_layout_set_width (layout, width * PANGO_SCALE); - pango_layout_set_ellipsize (layout, ellipsize); - pango_layout_set_wrap (layout, wrap); + g_assert_cmpint (line->start_index, <=, index2); + g_assert_cmpint (index2, <=, line->start_index + line->length); + + if (!run) + break; + + prev_index = run->item->offset; + next_index = run->item->offset + run->item->length; + + 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 */ + if (n_ranges > 0) + { + found_range = FALSE; + for (int k = 0; k < n_ranges; k++) + { + if (x + line_x >= ranges[2*k] && x + line_x <= ranges[2*k + 1]) + { + found_range = TRUE; + break; + } + } + } + + g_assert_true (found_range); + g_free (ranges); + } + + pango_layout_iter_free (iter); + } + + iter = pango_layout_get_iter (layout); + g_assert_true (pango_layout_iter_get_layout (iter) == layout); + g_assert_cmpint (pango_layout_iter_get_index (iter), ==, 0); + pango_layout_iter_get_layout_extents (iter, &ink_rect, &logical_rect); + + iter2 = pango_layout_iter_copy (iter); + + do + { + PangoRectangle line_ink, line_logical; + int baseline; + PangoLayoutLine *line; + line = pango_layout_iter_get_line (iter); + + pango_layout_iter_get_line_extents (iter, &line_ink, &line_logical); + baseline = pango_layout_iter_get_baseline (iter); + + assert_rectangle_contained (&line_ink, &ink_rect); + assert_rectangle_contained (&line_logical, &logical_rect); + + g_assert_cmpint (line_logical.y, <=, baseline); + g_assert_cmpint (baseline, <=, line_logical.y + line_logical.height); + + if (pango_layout_iter_get_index (iter) == pango_layout_iter_get_index (iter2)) + { + g_assert_cmpint (baseline, ==, pango_layout_get_baseline (layout)); + g_assert_true (line->is_paragraph_start); + } + + if (pango_layout_iter_at_last_line (iter)) + { + g_assert_cmpint (line->start_index + line->length, <=, strlen (pango_layout_get_text (layout))); + } + } + while (pango_layout_iter_next_line (iter)); + + pango_layout_iter_free (iter); + pango_layout_iter_free (iter2); + + /* generate the dumps */ g_string_append (string, pango_layout_get_text (layout)); + g_string_append (string, "\n--- parameters\n\n"); + g_string_append_printf (string, "wrapped: %d\n", pango_layout_is_wrapped (layout)); g_string_append_printf (string, "ellipsized: %d\n", pango_layout_is_ellipsized (layout)); g_string_append_printf (string, "lines: %d\n", pango_layout_get_line_count (layout)); - if (width != 0) + if (params.width > 0) g_string_append_printf (string, "width: %d\n", pango_layout_get_width (layout)); + + if (params.height > 0) + g_string_append_printf (string, "height: %d\n", pango_layout_get_height (layout)); + + if (params.indent != 0) + g_string_append_printf (string, "indent: %d\n", pango_layout_get_indent (layout)); + g_string_append (string, "\n--- attributes\n\n"); print_attr_list (pango_layout_get_attributes (layout), string); + + g_string_append (string, "\n--- directions\n\n"); + dump_directions (layout, string); + + g_string_append (string, "\n--- cursor positions\n\n"); + dump_cursor_positions (layout, string); + g_string_append (string, "\n--- lines\n\n"); dump_lines (layout, string); + g_string_append (string, "\n--- runs\n\n"); dump_runs (layout, string); g_object_unref (layout); + g_free (contents); + + if (params.tabs) + pango_tab_array_free (params.tabs); } static gchar * @@ -369,6 +734,7 @@ main (int argc, char *argv[]) string = g_string_sized_new (0); test_file (argv[1], string); g_print ("%s", string->str); + g_string_free (string, TRUE); return 0; } |