summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-10 23:23:50 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-10 23:36:36 +0200
commit34fa8df044f1491069c9ae69f1c1e73d635c8955 (patch)
tree30b9144690f55f0343a1fdbfcac6c9238c617077 /tests
parent29eb13ca6214461a4b0deb63d589cd39ad6d41c2 (diff)
Move language-related properties from `par` to `text`
Closes #67
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/text/hyphenate.pngbin6196 -> 20764 bytes
-rw-r--r--tests/typ/layout/align.typ4
-rw-r--r--tests/typ/layout/columns.typ3
-rw-r--r--tests/typ/text/bidi.typ31
-rw-r--r--tests/typ/text/hyphenate.typ34
-rw-r--r--tests/typ/text/indent.typ4
-rw-r--r--tests/typ/text/justify.typ2
-rw-r--r--tests/typ/text/knuth.typ6
-rw-r--r--tests/typ/text/microtype.typ3
9 files changed, 46 insertions, 41 deletions
diff --git a/tests/ref/text/hyphenate.png b/tests/ref/text/hyphenate.png
index 24c52de5..0560d5b7 100644
--- a/tests/ref/text/hyphenate.png
+++ b/tests/ref/text/hyphenate.png
Binary files differ
diff --git a/tests/typ/layout/align.typ b/tests/typ/layout/align.typ
index f0603b46..753683de 100644
--- a/tests/typ/layout/align.typ
+++ b/tests/typ/layout/align.typ
@@ -25,11 +25,11 @@
// Test start and end alignment.
#rotate(-30deg, origin: end + horizon)[Hello]
-#set par(lang: "de")
+#set text(lang: "de")
#align(start)[Start]
#align(end)[Ende]
-#set par(lang: "ar")
+#set text(lang: "ar")
#align(start)[يبدأ]
#align(end)[نهاية]
diff --git a/tests/typ/layout/columns.typ b/tests/typ/layout/columns.typ
index 0a585868..ce291fb2 100644
--- a/tests/typ/layout/columns.typ
+++ b/tests/typ/layout/columns.typ
@@ -3,9 +3,8 @@
---
// Test normal operation and RTL directions.
#set page(height: 3.25cm, width: 7.05cm, columns: 2)
+#set text(lang: "ar", "Noto Sans Arabic", "IBM Plex Serif")
#set columns(gutter: 30pt)
-#set text("Noto Sans Arabic", "IBM Plex Serif")
-#set par(lang: "ar")
#rect(fill: conifer, height: 8pt, width: 6pt) وتحفيز
العديد من التفاعلات الكيميائية. (DNA) من أهم الأحماض النووية التي تُشكِّل
diff --git a/tests/typ/text/bidi.typ b/tests/typ/text/bidi.typ
index 5c666381..a180ad55 100644
--- a/tests/typ/text/bidi.typ
+++ b/tests/typ/text/bidi.typ
@@ -2,37 +2,35 @@
---
// Test reordering with different top-level paragraph directions.
-#let content = [Text טֶקסט]
+#let content = par[Text טֶקסט]
#set text("IBM Plex Serif")
-#par(lang: "he", content)
-#par(lang: "de", content)
+#text(lang: "he", content)
+#text(lang: "de", content)
---
// Test that consecutive, embedded LTR runs stay LTR.
// Here, we have two runs: "A" and italic "B".
-#let content = [أنت A#emph[B]مطرC]
+#let content = par[أنت A#emph[B]مطرC]
#set text("IBM Plex Serif", "Noto Sans Arabic")
-#par(lang: "ar", content)
-#par(lang: "de", content)
+#text(lang: "ar", content)
+#text(lang: "de", content)
---
// Test that consecutive, embedded RTL runs stay RTL.
// Here, we have three runs: "גֶ", bold "שֶׁ", and "ם".
-#let content = [Aגֶ#strong[שֶׁ]םB]
+#let content = par[Aגֶ#strong[שֶׁ]םB]
#set text("IBM Plex Serif", "Noto Serif Hebrew")
-#par(lang: "he", content)
-#par(lang: "de", content)
+#text(lang: "he", content)
+#text(lang: "de", content)
---
// Test embedding up to level 4 with isolates.
-#set text("IBM Plex Serif")
-#set par(dir: rtl)
+#set text(dir: rtl, "IBM Plex Serif")
א\u{2066}A\u{2067}Bב\u{2069}?
---
// Test hard line break (leads to two paragraphs in unicode-bidi).
-#set text("Noto Sans Arabic", "IBM Plex Serif")
-#set par(lang: "ar")
+#set text(lang: "ar", "Noto Sans Arabic", "IBM Plex Serif")
Life المطر هو الحياة \
الحياة تمطر is rain.
@@ -44,13 +42,12 @@ Lריווח #h(1cm) R
---
// Test inline object.
-#set text("IBM Plex Serif")
-#set par(lang: "he")
+#set text(lang: "he", "IBM Plex Serif")
קרנפיםRh#image("../../res/rhino.png", height: 11pt)inoחיים
---
// Test setting a vertical direction.
// Ref: false
-// Error: 15-18 must be horizontal
-#set par(dir: ttb)
+// Error: 16-19 must be horizontal
+#set text(dir: ttb)
diff --git a/tests/typ/text/hyphenate.typ b/tests/typ/text/hyphenate.typ
index 67711ac3..02a33277 100644
--- a/tests/typ/text/hyphenate.typ
+++ b/tests/typ/text/hyphenate.typ
@@ -1,23 +1,33 @@
// Test hyphenation.
---
-// Hyphenate english.
-#set page(width: 70pt)
-#set par(lang: "en", hyphenate: true)
-Warm welcomes to Typst.
+// Test hyphenating english and greek.
+#set text(hyphenate: true)
+#set page(width: auto)
+#grid(
+ columns: (70pt, 60pt),
+ text(lang: "en")[Warm welcomes to Typst.],
+ text(lang: "el")[διαμερίσματα. \ λατρευτός],
+)
---
-// Hyphenate greek.
-#set page(width: 60pt)
-#set par(lang: "el", hyphenate: true)
-διαμερίσματα. \
-λατρευτός
+// Test disabling hyphenation for short passages.
+#set text(lang: "en", hyphenate: true)
+
+Welcome to wonderful experiences. \
+Welcome to `wonderful` experiences. \
+Welcome to #text(hyphenate: false)[wonderful] experiences. \
+Welcome to wonde#text(hyphenate: false)[rf]ul experiences. \
+
+// Test enabling hyphenation for short passages.
+#set text(lang: "en", hyphenate: false)
+Welcome to wonderful experiences. \
+Welcome to wo#text(hyphenate: true)[nd]erful experiences. \
---
// Hyphenate between shape runs.
-#set par(lang: "en", hyphenate: true)
#set page(width: 80pt)
-
+#set text(lang: "en", hyphenate: true)
It's a #emph[Tree]beard.
---
@@ -26,5 +36,5 @@ It's a #emph[Tree]beard.
// 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)
+#set text(lang: "en", hyphenate: true)
#h(6pt) networks, the rest.
diff --git a/tests/typ/text/indent.typ b/tests/typ/text/indent.typ
index 6da562f6..1b48851b 100644
--- a/tests/typ/text/indent.typ
+++ b/tests/typ/text/indent.typ
@@ -19,8 +19,8 @@ starts a paragraph without indent.
Except if you have another paragraph in them.
-#set text(8pt, "Noto Sans Arabic", "IBM Plex Sans")
-#set par(lang: "ar", leading: 8pt)
+#set text(8pt, lang: "ar", "Noto Sans Arabic", "IBM Plex Sans")
+#set par(leading: 8pt)
= Arabic
دع النص يمطر عليك
diff --git a/tests/typ/text/justify.typ b/tests/typ/text/justify.typ
index d19249ea..24b6b99e 100644
--- a/tests/typ/text/justify.typ
+++ b/tests/typ/text/justify.typ
@@ -1,8 +1,8 @@
---
#set page(width: 180pt)
+#set text(lang: "en")
#set par(
- lang: "en",
justify: true,
indent: 14pt,
spacing: 0pt,
diff --git a/tests/typ/text/knuth.typ b/tests/typ/text/knuth.typ
index d5af87f8..33249ef4 100644
--- a/tests/typ/text/knuth.typ
+++ b/tests/typ/text/knuth.typ
@@ -1,6 +1,6 @@
#set page(width: auto, height: auto)
-#set par(lang: "en", leading: 4pt, justify: true)
-#set text(family: "Latin Modern Roman")
+#set par(leading: 4pt, justify: true)
+#set text(lang: "en", family: "Latin Modern Roman")
#let story = [
In olden times when wishing still helped one, there lived a king whose
@@ -16,7 +16,7 @@
#let column(title, linebreaks, hyphenate) = {
rect(width: 132pt, fill: rgb("eee"))[
#strong(title)
- #par(linebreaks: linebreaks, hyphenate: hyphenate, story)
+ #par(linebreaks: linebreaks, text(hyphenate: hyphenate, story))
]
}
diff --git a/tests/typ/text/microtype.typ b/tests/typ/text/microtype.typ
index dbcb4998..7e85bd3f 100644
--- a/tests/typ/text/microtype.typ
+++ b/tests/typ/text/microtype.typ
@@ -23,8 +23,7 @@ A#box["]B
‹Book quotes are even smarter.› \
---
-#set par(lang: "ar")
-#set text("Noto Sans Arabic", "IBM Plex Sans")
+#set text(lang: "ar", "Noto Sans Arabic", "IBM Plex Sans")
"المطر هو الحياة" \
المطر هو الحياة