summaryrefslogtreecommitdiff
path: root/tests/typ/text
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-08 15:08:26 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-08 15:45:14 +0200
commit712c00ecb72b67da2c0788e5d3eb4dcc6366b2a7 (patch)
treef5d7ef4341a4728c980d020cc173fa6bb70feaff /tests/typ/text
parent977ac77e6a3298be2644a8231e93acbef9f7f396 (diff)
Em units
Diffstat (limited to 'tests/typ/text')
-rw-r--r--tests/typ/text/baseline.typ2
-rw-r--r--tests/typ/text/deco.typ4
-rw-r--r--tests/typ/text/edge.typ25
-rw-r--r--tests/typ/text/em.typ23
-rw-r--r--tests/typ/text/font.typ29
-rw-r--r--tests/typ/text/par.typ2
-rw-r--r--tests/typ/text/tracking-spacing.typ30
-rw-r--r--tests/typ/text/tracking.typ12
8 files changed, 81 insertions, 46 deletions
diff --git a/tests/typ/text/baseline.typ b/tests/typ/text/baseline.typ
index 7100ab52..5f451563 100644
--- a/tests/typ/text/baseline.typ
+++ b/tests/typ/text/baseline.typ
@@ -1,4 +1,4 @@
// Test text baseline.
---
-Hi #text(150%)[You], #text(75%)[how are you?]
+Hi #text(1.5em)[You], #text(0.75em)[how are you?]
diff --git a/tests/typ/text/deco.typ b/tests/typ/text/deco.typ
index a9f380b9..071208ac 100644
--- a/tests/typ/text/deco.typ
+++ b/tests/typ/text/deco.typ
@@ -19,11 +19,11 @@
#overline(underline[Running amongst the wolves.])
---
-#let redact = strike.with(10pt, extent: 5%)
+#let redact = strike.with(10pt, extent: 0.05em)
#let highlight = strike.with(
stroke: rgb("abcdef88"),
thickness: 10pt,
- extent: 5%,
+ extent: 0.05em,
)
// Abuse thickness and transparency for redacting and highlighting stuff.
diff --git a/tests/typ/text/edge.typ b/tests/typ/text/edge.typ
new file mode 100644
index 00000000..c3c60b28
--- /dev/null
+++ b/tests/typ/text/edge.typ
@@ -0,0 +1,25 @@
+// Test top and bottom text edge.
+
+---
+#set page(width: 160pt)
+#set text(size: 8pt)
+
+#let try(top, bottom) = rect(fill: conifer)[
+ #set text("IBM Plex Mono", top-edge: top, bottom-edge: bottom)
+ From #top to #bottom
+]
+
+#try("ascender", "descender")
+#try("ascender", "baseline")
+#try("cap-height", "baseline")
+#try("x-height", "baseline")
+#try(4pt, -2pt)
+#try(1pt + 0.3em, -0.15em)
+
+---
+// Error: 21-23 expected string or length, found array
+#set text(top-edge: ())
+
+---
+// Error: 24-26 unknown font metric
+#set text(bottom-edge: "")
diff --git a/tests/typ/text/em.typ b/tests/typ/text/em.typ
index d9b00f06..dd0a436e 100644
--- a/tests/typ/text/em.typ
+++ b/tests/typ/text/em.typ
@@ -4,14 +4,31 @@
#set text(size: 5pt)
A // 5pt
[
- #set text(size: 200%)
+ #set text(size: 2em)
B // 10pt
[
- #set text(size: 150% + 1pt)
+ #set text(size: 1.5em + 1pt)
C // 16pt
- #text(size: 200%)[D] // 32pt
+ #text(size: 2em)[D] // 32pt
E // 16pt
]
F // 10pt
]
G // 5pt
+
+---
+// Test using ems in arbitrary places.
+#set text(size: 5pt)
+#set text(size: 2em)
+#set square(fill: red)
+
+#let size = {
+ let size = 0.25em + 1pt
+ for _ in range(3) {
+ size *= 2
+ }
+ size - 3pt
+}
+
+#square(size: size)
+#square(size: 25pt)
diff --git a/tests/typ/text/font.typ b/tests/typ/text/font.typ
index 4b7d7534..b2909182 100644
--- a/tests/typ/text/font.typ
+++ b/tests/typ/text/font.typ
@@ -3,8 +3,8 @@
---
// Set same font size in three different ways.
#text(20pt)[A]
-#text(200%)[A]
-#text(size: 15pt + 50%)[A]
+#text(2em)[A]
+#text(size: 15pt + 0.5em)[A]
// Do nothing.
#text()[Normal]
@@ -39,23 +39,6 @@ Emoji: 🐪, 🌋, 🏞
2π = 𝛼 + 𝛽. ✅
---
-// Test top and bottom edge.
-#set page(width: 150pt)
-#set text(size: 8pt)
-
-#let try(top, bottom) = rect(fill: conifer)[
- #set text("IBM Plex Mono", top-edge: top, bottom-edge: bottom)
- From #top to #bottom
-]
-
-#try("ascender", "descender")
-#try("ascender", "baseline")
-#try("cap-height", "baseline")
-#try("x-height", "baseline")
-#try(4pt, -2pt)
-#try(1pt + 27%, -18%)
-
----
// Error: 11-16 unexpected argument
#set text(false)
@@ -64,14 +47,6 @@ Emoji: 🐪, 🌋, 🏞
#set text(style: "bold", weight: "thin")
---
-// Error: 21-23 expected string or relative length, found array
-#set text(top-edge: ())
-
----
-// Error: 21-23 unknown font metric
-#set text(top-edge: "")
-
----
// Error: 23-27 unexpected argument
#set text(size: 10pt, 12pt)
diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ
index 2bff4a47..6b7c0f59 100644
--- a/tests/typ/text/par.typ
+++ b/tests/typ/text/par.typ
@@ -31,7 +31,7 @@ A #set par(spacing: 0pt, leading: 0pt); B #parbreak() C
---
// Test weird metrics.
-#set par(spacing: 100%, leading: 0pt)
+#set par(spacing: 1em, leading: 0pt)
But, soft! what light through yonder window breaks?
It is the east, and Juliet is the sun.
diff --git a/tests/typ/text/tracking-spacing.typ b/tests/typ/text/tracking-spacing.typ
new file mode 100644
index 00000000..b938af36
--- /dev/null
+++ b/tests/typ/text/tracking-spacing.typ
@@ -0,0 +1,30 @@
+// Test tracking characters apart or together.
+
+---
+// Test tracking.
+#set text(tracking: -0.01em)
+I saw Zoe yӛsterday, on the tram.
+
+---
+// Test tracking for only part of paragraph.
+I'm in#text(tracking: 0.15em + 1.5pt)[ spaace]!
+
+---
+// Test that tracking doesn't disrupt mark placement.
+#set text(tracking: 0.3em)
+טֶקסט
+
+---
+// Test tracking in arabic text (makes no sense whatsoever)
+#set text(tracking: 0.3em)
+النص
+
+---
+// Test word spacing.
+#set text(spacing: 1em)
+My text has spaces.
+
+---
+// Test word spacing relative to the font's space width.
+#set text(spacing: 50% + 1pt)
+This is tight.
diff --git a/tests/typ/text/tracking.typ b/tests/typ/text/tracking.typ
deleted file mode 100644
index e3ff70ff..00000000
--- a/tests/typ/text/tracking.typ
+++ /dev/null
@@ -1,12 +0,0 @@
-// Test tracking characters apart or together.
-
----
-#set text(tracking: -0.01)
-I saw Zoe yӛsterday, on the tram.
-
----
-I'm in#text(tracking: 0.3)[ spaace]!
-
----
-#set text("Noto Serif Hebrew", tracking: 0.3)
-טֶקסט