summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatt Fellenz <matt@felle.nz>2024-04-30 05:18:19 -0700
committerGitHub <noreply@github.com>2024-04-30 12:18:19 +0000
commit97de0a0595d28e29d944112ab6e06700d9c9d73d (patch)
tree220ffef576722553b311526258e23070b8a8ce95 /tests
parent0bb45b335fb8b34af9ce33e1684e58c046ee5e45 (diff)
Various text layout config improvements (#3787)
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/costs-hyphenation-avoid.pngbin0 -> 1642 bytes
-rw-r--r--tests/ref/costs-runt-allow.pngbin0 -> 607 bytes
-rw-r--r--tests/ref/costs-runt-avoid.pngbin0 -> 1265 bytes
-rw-r--r--tests/ref/costs-widow-orphan.pngbin0 -> 2676 bytes
-rw-r--r--tests/suite/layout/inline/hyphenate.typ56
5 files changed, 56 insertions, 0 deletions
diff --git a/tests/ref/costs-hyphenation-avoid.png b/tests/ref/costs-hyphenation-avoid.png
new file mode 100644
index 00000000..8efaef63
--- /dev/null
+++ b/tests/ref/costs-hyphenation-avoid.png
Binary files differ
diff --git a/tests/ref/costs-runt-allow.png b/tests/ref/costs-runt-allow.png
new file mode 100644
index 00000000..31a348ff
--- /dev/null
+++ b/tests/ref/costs-runt-allow.png
Binary files differ
diff --git a/tests/ref/costs-runt-avoid.png b/tests/ref/costs-runt-avoid.png
new file mode 100644
index 00000000..e45de59e
--- /dev/null
+++ b/tests/ref/costs-runt-avoid.png
Binary files differ
diff --git a/tests/ref/costs-widow-orphan.png b/tests/ref/costs-widow-orphan.png
new file mode 100644
index 00000000..30e459de
--- /dev/null
+++ b/tests/ref/costs-widow-orphan.png
Binary files differ
diff --git a/tests/suite/layout/inline/hyphenate.typ b/tests/suite/layout/inline/hyphenate.typ
index aaabe816..bcad4d93 100644
--- a/tests/suite/layout/inline/hyphenate.typ
+++ b/tests/suite/layout/inline/hyphenate.typ
@@ -49,3 +49,59 @@ It's a #emph[Tree]beard.
#set page(width: 60pt)
#set text(hyphenate: true)
#h(6pt) networks, the rest.
+
+--- costs-widow-orphan ---
+#set page(height: 60pt)
+
+#let sample = lorem(12)
+
+#sample
+#pagebreak()
+#set text(costs: (widow: 0%, orphan: 0%))
+#sample
+
+--- costs-runt-avoid ---
+#set par(justify: true)
+
+#let sample = [please avoid runts in this text.]
+
+#sample
+#pagebreak()
+#set text(costs: (runt: 10000%))
+#sample
+
+--- costs-runt-allow ---
+#set par(justify: true)
+#set text(size: 6pt)
+
+#let sample = [a a a a a a a a a a a a a a a a a a a a a a a a a]
+
+#sample
+#pagebreak()
+#set text(costs: (runt: 0%))
+#sample
+
+--- costs-hyphenation-avoid ---
+#set par(justify: true)
+
+#let sample = [we've increased the hyphenation cost.]
+
+#sample
+#pagebreak()
+#set text(costs: (hyphenation: 10000%))
+#sample
+
+--- costs-invalid-type ---
+// Error: 18-37 expected ratio, found auto
+#set text(costs: (hyphenation: auto))
+
+--- costs-invalid-key ---
+// Error: 18-52 unexpected key "invalid-key", valid keys are "hyphenation", "runt", "widow", and "orphan"
+#set text(costs: (hyphenation: 1%, invalid-key: 3%))
+
+--- costs-access ---
+#set text(costs: (hyphenation: 1%, runt: 2%))
+#set text(costs: (widow: 3%))
+#context {
+ assert.eq(text.costs, (hyphenation: 1%, runt: 2%, widow: 3%, orphan: 100%))
+}