summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/func-font-fallback.pngbin0 -> 3406 bytes
-rw-r--r--tests/ref/func-font-properties.pngbin0 -> 2210 bytes
-rw-r--r--tests/typ/func-font-fallback.typ18
-rw-r--r--tests/typ/func-font-properties.typ20
-rw-r--r--tests/typeset.rs4
5 files changed, 40 insertions, 2 deletions
diff --git a/tests/ref/func-font-fallback.png b/tests/ref/func-font-fallback.png
new file mode 100644
index 00000000..b7c565b4
--- /dev/null
+++ b/tests/ref/func-font-fallback.png
Binary files differ
diff --git a/tests/ref/func-font-properties.png b/tests/ref/func-font-properties.png
new file mode 100644
index 00000000..3dab43f5
--- /dev/null
+++ b/tests/ref/func-font-properties.png
Binary files differ
diff --git a/tests/typ/func-font-fallback.typ b/tests/typ/func-font-fallback.typ
new file mode 100644
index 00000000..587baed7
--- /dev/null
+++ b/tests/typ/func-font-fallback.typ
@@ -0,0 +1,18 @@
+// Test font fallback.
+
+// Source Sans Pro + Segoe UI Emoji.
+Emoji: 🏀
+
+// CMU Serif + Noto Emoji.
+[font: "CMU Serif", "Noto Emoji"][Emoji: 🏀]
+
+// Class definitions.
+[font: math=("CMU Serif", "Latin Modern Math", "Noto Emoji")]
+[font: math][Math: ∫ α + β ➗ 3]
+
+// Class redefinition.
+[font: sans-serif=("Noto Emoji",)]
+[font: sans-serif=("Archivo", sans-serif)]
+New sans-serif. 🚀
+
+// TODO: Add tests for other scripts.
diff --git a/tests/typ/func-font-properties.typ b/tests/typ/func-font-properties.typ
new file mode 100644
index 00000000..78093e98
--- /dev/null
+++ b/tests/typ/func-font-properties.typ
@@ -0,0 +1,20 @@
+// Test configuring font properties.
+
+[font: "PT Sans", 10pt]
+
+// Set same font size in three different ways.
+[font: 20pt][A]
+[font: 200%][A]
+[font: 15pt + 50%][A]
+
+// Do nothing.
+[font][Normal]
+
+// Set style (is available).
+[font: style=italic][Italic]
+
+// Set weight (is available).
+[font: weight=bold][Bold]
+
+// Set stretch (not available, matching closest).
+[font: stretch=ultra-condensed][Condensed]
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 01576cf0..ec2ad62d 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -278,7 +278,7 @@ fn draw(layouts: &[BoxLayout], env: &Env, pixel_per_pt: f32) -> Canvas {
}
fn draw_text(canvas: &mut Canvas, pos: Point, env: &Env, shaped: &Shaped) {
- let face = env.fonts.get_loaded(shaped.face).get();
+ let face = env.fonts.face(shaped.face).get();
for (&glyph, &offset) in shaped.glyphs.iter().zip(&shaped.offsets) {
let units_per_em = face.units_per_em().unwrap_or(1000);
@@ -304,7 +304,7 @@ fn draw_text(canvas: &mut Canvas, pos: Point, env: &Env, shaped: &Shaped) {
}
fn draw_image(canvas: &mut Canvas, pos: Point, env: &Env, img: &ImageElement) {
- let buf = &env.resources.get_loaded::<ImageResource>(img.res).buf;
+ let buf = &env.resources.loaded::<ImageResource>(img.res).buf;
let mut pixmap = Pixmap::new(buf.width(), buf.height()).unwrap();
for ((_, _, src), dest) in buf.pixels().zip(pixmap.pixels_mut()) {