diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-03-14 20:28:28 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-03-14 20:52:32 +0100 |
| commit | 288a926feae1e73dff5a6b103aa920d6f7eb0f35 (patch) | |
| tree | 186be7eb8260c7a30938bf14c52bbf75e9b40bff /tests/typ/text | |
| parent | 9c7067bce3a4e683411dacc8653976b055570b39 (diff) | |
Knuth-Plass and MicroType
Diffstat (limited to 'tests/typ/text')
| -rw-r--r-- | tests/typ/text/hyphenate.typ | 20 | ||||
| -rw-r--r-- | tests/typ/text/knuth.typ | 29 | ||||
| -rw-r--r-- | tests/typ/text/microtype.typ | 35 |
3 files changed, 82 insertions, 2 deletions
diff --git a/tests/typ/text/hyphenate.typ b/tests/typ/text/hyphenate.typ index d6f44477..67711ac3 100644 --- a/tests/typ/text/hyphenate.typ +++ b/tests/typ/text/hyphenate.typ @@ -1,14 +1,30 @@ // Test hyphenation. --- +// Hyphenate english. #set page(width: 70pt) #set par(lang: "en", hyphenate: true) Warm welcomes to Typst. -#h(6pt) networks, the rest. - --- +// Hyphenate greek. #set page(width: 60pt) #set par(lang: "el", hyphenate: true) διαμερίσματα. \ λατρευτός + +--- +// Hyphenate between shape runs. +#set par(lang: "en", hyphenate: true) +#set page(width: 80pt) + +It's a #emph[Tree]beard. + +--- +// This sequence would confuse hypher if we passed trailing / leading +// punctuation instead of just the words. So this tests that we don't +// do that. The test passes if there's just one hyphenation between +// "net" and "works". +#set page(width: 70pt) +#set par(lang: "en", hyphenate: true) +#h(6pt) networks, the rest. diff --git a/tests/typ/text/knuth.typ b/tests/typ/text/knuth.typ new file mode 100644 index 00000000..63b7c50d --- /dev/null +++ b/tests/typ/text/knuth.typ @@ -0,0 +1,29 @@ +#set page(width: auto, height: auto) +#set par(lang: "en", leading: 3pt, justify: true) +#set text(family: "CMU Serif") + +#let story = [ + In olden times when wishing still helped one, there lived a king whose + daughters were all beautiful; and the youngest was so beautiful that the sun + itself, which has seen so much, was astonished whenever it shone in her face. + Close by the king’s castle lay a great dark forest, and under an old lime-tree + in the forest was a well, and when the day was very warm, the king’s child + went out into the forest and sat down by the side of the cool fountain; and + when she was bored she took a golden ball, and threw it up on high and caught + it; and this ball was her favorite plaything. +] + +#let column(title, linebreaks, hyphenate) = { + rect(width: 132pt, fill: rgb("eee"))[ + #strong(title) + #par(linebreaks: linebreaks, hyphenate: hyphenate, story) + ] +} + +#grid( + columns: 3, + gutter: 10pt, + column([Simple without hyphens], "simple", false), + column([Simple with hyphens], "simple", true), + column([Optimized with hyphens], "optimized", true), +) diff --git a/tests/typ/text/microtype.typ b/tests/typ/text/microtype.typ new file mode 100644 index 00000000..add5e501 --- /dev/null +++ b/tests/typ/text/microtype.typ @@ -0,0 +1,35 @@ +// Test micro-typographical shenanigans. + +--- +// Test that overhang is off by default in boxes. +A#box["]B + +--- +// Test justified quotes. +#set par(justify: true) +“A quote that hangs a bit into the margin.” \ + --- somebody + +--- +// Test fancy quotes in the left margin. +#set par(align: right) +»Book quotes are even smarter.« \ +›Book quotes are even smarter.‹ \ + +--- +// Test fancy quotes in the right margin. +#set par(align: left) +«Book quotes are even smarter.» \ +‹Book quotes are even smarter.› \ + +--- +#set par(lang: "ar") +#set text("Noto Sans Arabic") +"المطر هو الحياة" \ +المطر هو الحياة + +--- +// Test that lone punctuation doesn't overhang into the margin. +#set page(margins: 0pt) +#set par(align: right) +: |
