summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeng Guanwen <pg999w@outlook.com>2024-12-17 22:07:45 +0800
committerGitHub <noreply@github.com>2024-12-17 14:07:45 +0000
commit73253d465192454f0dfe3fe9eef46d495b343aef (patch)
tree4d8179d7b0d7c169e283471d7df928d264192ca0 /tests
parent54cee16c3128695089d7472451f02646c6d81521 (diff)
Support for defining which charset should be covered by a font (#5305)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/text-font-covers-chinese.pngbin0 -> 2619 bytes
-rw-r--r--tests/ref/text-font-covers-numbers.pngbin0 -> 500 bytes
-rw-r--r--tests/suite/text/font.typ37
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/ref/text-font-covers-chinese.png b/tests/ref/text-font-covers-chinese.png
new file mode 100644
index 00000000..5c9b4b1e
--- /dev/null
+++ b/tests/ref/text-font-covers-chinese.png
Binary files differ
diff --git a/tests/ref/text-font-covers-numbers.png b/tests/ref/text-font-covers-numbers.png
new file mode 100644
index 00000000..9ed95c2f
--- /dev/null
+++ b/tests/ref/text-font-covers-numbers.png
Binary files differ
diff --git a/tests/suite/text/font.typ b/tests/suite/text/font.typ
index bb75f4ae..5af8dcb9 100644
--- a/tests/suite/text/font.typ
+++ b/tests/suite/text/font.typ
@@ -112,3 +112,40 @@ I
[ ]
text(fill: t, "Hello")
})
+
+--- text-font-types ---
+#let ubuntu = (name: "Ubuntu", covers: regex("[\u{20}-\u{FFFF}]"))
+#set text(font: ubuntu)
+#set text(font: (ubuntu, "Ubuntu"))
+
+--- text-font-covers-chinese ---
+// Without ranges, the quotation mark is using the Latin font.
+#set text(font: ("Ubuntu", "Noto Serif CJK SC"))
+分别设置“中文”和English字体
+
+// With ranges, the quotation mark is using the Chinese font.
+#set text(font: ((name: "Noto Serif CJK SC", covers: regex("[\u{00B7}-\u{3134F}]")), "Ubuntu"))
+分别设置“中文”和English字体
+
+// With "latin-in-cjk", the quotation mark is also using the Chinese font.
+#set text(font: ((name: "Ubuntu", covers: "latin-in-cjk"), "Noto Serif CJK SC"))
+分别设置“中文”和English字体
+
+--- text-font-covers-numbers ---
+// Change font only for numbers.
+#set text(font: (
+ (name: "PT Sans", covers: regex("[0-9]")),
+ "Libertinus Serif"
+))
+
+The number 123.
+
+--- text-font-covers-bad-1 ---
+// Error: 17-59 coverage regex may only use dot, letters, and character classes
+// Hint: 17-59 the regex is applied to each letter individually
+#set text(font: (name: "Ubuntu", covers: regex("20-FFFF")))
+
+--- text-font-covers-bad-2 ---
+// Error: 17-65 coverage regex may only use dot, letters, and character classes
+// Hint: 17-65 the regex is applied to each letter individually
+#set text(font: (name: "Ubuntu", covers: regex("\u{20}-\u{10}")))