Better paragraph layout tests ✅
BIN
tests/ref/text/align.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 14 KiB |
BIN
tests/ref/text/chinese.png
Normal file
After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
BIN
tests/ref/text/whitespace.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
28
tests/typ/text/align.typ
Normal file
@ -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]
|
@ -1,6 +1,7 @@
|
|||||||
// Test simple text.
|
// 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
|
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
|
is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and
|
||||||
|
9
tests/typ/text/chinese.typ
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Test chinese text from Wikipedia.
|
||||||
|
|
||||||
|
---
|
||||||
|
#font("Noto Serif CJK SC")
|
||||||
|
|
||||||
|
是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集
|
||||||
|
由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德
|
||||||
|
节目于2007年5月23日在美国和加拿大首播,共计吸引了1400万美国观众收看
|
||||||
|
本集加上插播广告一共也持续有两个小时
|
@ -1,35 +1,28 @@
|
|||||||
// Test line breaking.
|
// Test line breaking special cases.
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test normal line breaking.
|
// Test overlong word that is not directly after a hard break.
|
||||||
But, soft! what light through yonder window breaks? It is the east, and Juliet
|
This is a spaceexceedinglylongishy.
|
||||||
is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and
|
|
||||||
pale with grief hard.
|
|
||||||
|
|
||||||
// From Wikipedia:
|
---
|
||||||
#font("Noto Serif CJK SC")
|
// Test two overlong words in a row.
|
||||||
是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集
|
Supercalifragilisticexpialidocious Expialigoricmetrioxidation.
|
||||||
由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德
|
|
||||||
节目于2007年5月23日在美国和加拿大首播,共计吸引了1400万美国观众收看
|
---
|
||||||
本集加上插播广告一共也持续有两个小时
|
// Test that there are no unwanted line break opportunities on run change.
|
||||||
|
This is partly emph_as_ized.
|
||||||
|
|
||||||
|
---
|
||||||
|
Hard \ break.
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test hard break directly after normal break.
|
// Test hard break directly after normal break.
|
||||||
But, soft! What light through \ yonder window breaks?
|
Hard break directly after \ normal break.
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test consecutive breaks.
|
// Test consecutive breaks.
|
||||||
But, soft! Whatlightdoyoueveryonderthrough window breaks? Why did the window
|
Two consecutive \ \ breaks and three \ \ \ more.
|
||||||
even \ break \ \ in the first place.
|
|
||||||
|
|
||||||
---
|
|
||||||
// Test two superlong words in a row.
|
|
||||||
Supercalifragilisticousalogy Expialigoricmetrioxidationreagent.
|
|
||||||
|
|
||||||
---
|
|
||||||
// Test run change after space.
|
|
||||||
Left #font("PT Sans")[Right].
|
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test trailing newline.
|
// Test trailing newline.
|
||||||
Trailing newline{"\n"}
|
Trailing break \
|
||||||
|
17
tests/typ/text/whitespace.typ
Normal file
@ -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_
|