From bfbbe8dcf8881d276c3db05aea99f7da915edde2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 3 Apr 2021 20:54:18 +0200 Subject: =?UTF-8?q?Better=20paragraph=20layout=20tests=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/ref/text/align.png | Bin 0 -> 4008 bytes tests/ref/text/basic.png | Bin 37041 -> 37172 bytes tests/ref/text/bidi.png | Bin 14920 -> 14839 bytes tests/ref/text/chinese.png | Bin 0 -> 16068 bytes tests/ref/text/linebreaks.png | Bin 33881 -> 10111 bytes tests/ref/text/shaping.png | Bin 12565 -> 12609 bytes tests/ref/text/whitespace.png | Bin 0 -> 2084 bytes tests/typ/text/align.typ | 28 ++++++++++++++++++++++++++++ tests/typ/text/basic.typ | 3 ++- tests/typ/text/chinese.typ | 9 +++++++++ tests/typ/text/linebreaks.typ | 35 ++++++++++++++--------------------- tests/typ/text/whitespace.typ | 17 +++++++++++++++++ 12 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 tests/ref/text/align.png create mode 100644 tests/ref/text/chinese.png create mode 100644 tests/ref/text/whitespace.png create mode 100644 tests/typ/text/align.typ create mode 100644 tests/typ/text/chinese.typ create mode 100644 tests/typ/text/whitespace.typ (limited to 'tests') diff --git a/tests/ref/text/align.png b/tests/ref/text/align.png new file mode 100644 index 00000000..9415214b Binary files /dev/null and b/tests/ref/text/align.png differ diff --git a/tests/ref/text/basic.png b/tests/ref/text/basic.png index a06c8763..aa5d9664 100644 Binary files a/tests/ref/text/basic.png and b/tests/ref/text/basic.png differ diff --git a/tests/ref/text/bidi.png b/tests/ref/text/bidi.png index c3ad156b..829fba0c 100644 Binary files a/tests/ref/text/bidi.png and b/tests/ref/text/bidi.png differ diff --git a/tests/ref/text/chinese.png b/tests/ref/text/chinese.png new file mode 100644 index 00000000..fa905df6 Binary files /dev/null and b/tests/ref/text/chinese.png differ diff --git a/tests/ref/text/linebreaks.png b/tests/ref/text/linebreaks.png index 6b512bcb..c5a826bd 100644 Binary files a/tests/ref/text/linebreaks.png and b/tests/ref/text/linebreaks.png differ diff --git a/tests/ref/text/shaping.png b/tests/ref/text/shaping.png index 676a67ff..76058b2e 100644 Binary files a/tests/ref/text/shaping.png and b/tests/ref/text/shaping.png differ diff --git a/tests/ref/text/whitespace.png b/tests/ref/text/whitespace.png new file mode 100644 index 00000000..35a21320 Binary files /dev/null and b/tests/ref/text/whitespace.png differ diff --git a/tests/typ/text/align.typ b/tests/typ/text/align.typ new file mode 100644 index 00000000..27c650a4 --- /dev/null +++ b/tests/typ/text/align.typ @@ -0,0 +1,28 @@ +// Test text alignment. + +--- +// Test that alignment depends on the paragraph's full width. +#rect[ + Hello World \ + #align(right)[World] +] + +--- +// Test that a line with multiple alignments respects the paragraph's full +// width. +#rect[ + Hello #align(center)[World] \ + Hello from the World +] + +--- +// Test that `start` alignment after `end` alignment doesn't do anything until +// the next line break ... +L #align(right)[R] R + +// ... but make sure it resets to left after the line break. +L #align(right)[R] \ L + +--- +// FIXME: There should be a line break opportunity on alignment change. +LLLLLLLLLLLLL#align(center)[CCCC] diff --git a/tests/typ/text/basic.typ b/tests/typ/text/basic.typ index b424cee8..d5f0de05 100644 --- a/tests/typ/text/basic.typ +++ b/tests/typ/text/basic.typ @@ -1,6 +1,7 @@ // Test simple text. -#page(width: 250pt) +--- +#page(width: 250pt, height: 110pt) But, soft! what light through yonder window breaks? It is the east, and Juliet is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and diff --git a/tests/typ/text/chinese.typ b/tests/typ/text/chinese.typ new file mode 100644 index 00000000..0800a220 --- /dev/null +++ b/tests/typ/text/chinese.typ @@ -0,0 +1,9 @@ +// Test chinese text from Wikipedia. + +--- +#font("Noto Serif CJK SC") + +是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集 +由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德 +节目于2007年5月23日在美国和加拿大首播,共计吸引了1400万美国观众收看 +本集加上插播广告一共也持续有两个小时 diff --git a/tests/typ/text/linebreaks.typ b/tests/typ/text/linebreaks.typ index 6647c2cd..4d57834a 100644 --- a/tests/typ/text/linebreaks.typ +++ b/tests/typ/text/linebreaks.typ @@ -1,35 +1,28 @@ -// Test line breaking. +// Test line breaking special cases. --- -// Test normal line breaking. -But, soft! what light through yonder window breaks? It is the east, and Juliet -is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and -pale with grief hard. +// Test overlong word that is not directly after a hard break. +This is a spaceexceedinglylongishy. -// From Wikipedia: -#font("Noto Serif CJK SC") -是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集 -由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德 -节目于2007年5月23日在美国和加拿大首播,共计吸引了1400万美国观众收看 -本集加上插播广告一共也持续有两个小时 +--- +// Test two overlong words in a row. +Supercalifragilisticexpialidocious Expialigoricmetrioxidation. --- -// Test hard break directly after normal break. -But, soft! What light through \ yonder window breaks? +// Test that there are no unwanted line break opportunities on run change. +This is partly emph_as_ized. --- -// Test consecutive breaks. -But, soft! Whatlightdoyoueveryonderthrough window breaks? Why did the window -even \ break \ \ in the first place. +Hard \ break. --- -// Test two superlong words in a row. -Supercalifragilisticousalogy Expialigoricmetrioxidationreagent. +// Test hard break directly after normal break. +Hard break directly after \ normal break. --- -// Test run change after space. -Left #font("PT Sans")[Right]. +// Test consecutive breaks. +Two consecutive \ \ breaks and three \ \ \ more. --- // Test trailing newline. -Trailing newline{"\n"} +Trailing break \ diff --git a/tests/typ/text/whitespace.typ b/tests/typ/text/whitespace.typ new file mode 100644 index 00000000..3d7dd2e2 --- /dev/null +++ b/tests/typ/text/whitespace.typ @@ -0,0 +1,17 @@ +// Test whitespace handling. + +--- +// Test that a run consisting only of whitespace isn't trimmed. +A#font("PT Sans")[ ]B + +--- +// Test font change after space. +Left #font("PT Sans")[Right]. + +--- +// Test that space at start of line is not trimmed. +A{"\n"} B + +--- +// Test that trailing space does not force a line break. +LLLLLLLLLLLLLL R _L_ -- cgit v1.2.3