diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-12-17 12:16:17 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-12-17 12:17:34 +0100 |
| commit | b02ba84264831ee97e7852f1e33cc78941dba13c (patch) | |
| tree | a9a33145de61d0b8b1f6a5bd65dae73b97f81f00 /tests | |
| parent | 0adbfe894ae1252758d1d7fff1df5514824347eb (diff) | |
Test [rgb] 🎨
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/rgb.png | bin | 0 -> 4142 bytes | |||
| -rw-r--r-- | tests/typ/rgb.typ | 24 | ||||
| -rw-r--r-- | tests/typeset.rs | 15 |
3 files changed, 32 insertions, 7 deletions
diff --git a/tests/ref/rgb.png b/tests/ref/rgb.png Binary files differnew file mode 100644 index 00000000..e394ccf1 --- /dev/null +++ b/tests/ref/rgb.png diff --git a/tests/typ/rgb.typ b/tests/typ/rgb.typ new file mode 100644 index 00000000..44d87819 --- /dev/null +++ b/tests/typ/rgb.typ @@ -0,0 +1,24 @@ +// Test the `rgb` function. + +// Check the output. +[rgb: 0.0, 0.3, 0.7] [val: #004db3] + +// Alpha channel. +[rgb: 1.0, 0.0, 0.0, 0.5] + +// Value smaller than 0.0 and larger than 1.0 +[rgb: -30, 15.5, 0.5] + +// Missing blue component. +[rgb: 0, 1] + +// Missing all components. +[rgb] + +// error: 4:23-4:26 unknown function +// error: 10:7-10:10 should be between 0.0 and 1.0 +// error: 10:12-10:16 should be between 0.0 and 1.0 +// error: 13:7-13:11 missing argument: blue component +// error: 16:5-16:5 missing argument: red component +// error: 16:5-16:5 missing argument: green component +// error: 16:5-16:5 missing argument: blue component diff --git a/tests/typeset.rs b/tests/typeset.rs index 5f108585..01576cf0 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -290,15 +290,16 @@ fn draw_text(canvas: &mut Canvas, pos: Point, env: &Env, shaped: &Shaped) { let mut builder = WrappedPathBuilder(PathBuilder::new()); face.outline_glyph(glyph, &mut builder); - let path = builder.0.finish().unwrap(); - let placed = path - .transform(&Transform::from_row(scale, 0.0, 0.0, -scale, x, y).unwrap()) - .unwrap(); + if let Some(path) = builder.0.finish() { + let placed = path + .transform(&Transform::from_row(scale, 0.0, 0.0, -scale, x, y).unwrap()) + .unwrap(); - let mut paint = Paint::default(); - paint.anti_alias = true; + let mut paint = Paint::default(); + paint.anti_alias = true; - canvas.fill_path(&placed, &paint, FillRule::default()); + canvas.fill_path(&placed, &paint, FillRule::default()); + } } } |
