From 97de0a0595d28e29d944112ab6e06700d9c9d73d Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Tue, 30 Apr 2024 05:18:19 -0700 Subject: Various text layout config improvements (#3787) --- tests/ref/costs-hyphenation-avoid.png | Bin 0 -> 1642 bytes tests/ref/costs-runt-allow.png | Bin 0 -> 607 bytes tests/ref/costs-runt-avoid.png | Bin 0 -> 1265 bytes tests/ref/costs-widow-orphan.png | Bin 0 -> 2676 bytes tests/suite/layout/inline/hyphenate.typ | 56 ++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 tests/ref/costs-hyphenation-avoid.png create mode 100644 tests/ref/costs-runt-allow.png create mode 100644 tests/ref/costs-runt-avoid.png create mode 100644 tests/ref/costs-widow-orphan.png (limited to 'tests') diff --git a/tests/ref/costs-hyphenation-avoid.png b/tests/ref/costs-hyphenation-avoid.png new file mode 100644 index 00000000..8efaef63 Binary files /dev/null and b/tests/ref/costs-hyphenation-avoid.png differ diff --git a/tests/ref/costs-runt-allow.png b/tests/ref/costs-runt-allow.png new file mode 100644 index 00000000..31a348ff Binary files /dev/null and b/tests/ref/costs-runt-allow.png differ diff --git a/tests/ref/costs-runt-avoid.png b/tests/ref/costs-runt-avoid.png new file mode 100644 index 00000000..e45de59e Binary files /dev/null and b/tests/ref/costs-runt-avoid.png differ diff --git a/tests/ref/costs-widow-orphan.png b/tests/ref/costs-widow-orphan.png new file mode 100644 index 00000000..30e459de Binary files /dev/null and b/tests/ref/costs-widow-orphan.png 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%)) +} -- cgit v1.2.3