Add tests for stroke + fill and fill + stroke
diff --git a/sparse_strips/vello_sparse_tests/snapshots/glyphs_filled_then_stroked.png b/sparse_strips/vello_sparse_tests/snapshots/glyphs_filled_then_stroked.png new file mode 100644 index 0000000..1a82977 --- /dev/null +++ b/sparse_strips/vello_sparse_tests/snapshots/glyphs_filled_then_stroked.png
@@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9ca8a3f2d206c18b80afa1fce8ef9e0e6ee28e449a18baa680d02a022916937 +size 6098
diff --git a/sparse_strips/vello_sparse_tests/snapshots/glyphs_stroked_then_filled.png b/sparse_strips/vello_sparse_tests/snapshots/glyphs_stroked_then_filled.png new file mode 100644 index 0000000..bfceb20 --- /dev/null +++ b/sparse_strips/vello_sparse_tests/snapshots/glyphs_stroked_then_filled.png
@@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:688c2b64098483aef590957dd368b8da98d6c0c123ba2e3fd6162b8b340adfb7 +size 6069
diff --git a/sparse_strips/vello_sparse_tests/tests/glyph.rs b/sparse_strips/vello_sparse_tests/tests/glyph.rs index 6390290..b1f366d 100644 --- a/sparse_strips/vello_sparse_tests/tests/glyph.rs +++ b/sparse_strips/vello_sparse_tests/tests/glyph.rs
@@ -83,6 +83,52 @@ .stroke_glyphs(glyphs.into_iter()); } +#[vello_test(width = 300, height = 120)] +fn glyphs_stroked_then_filled(ctx: &mut impl Renderer) { + let font_size: f32 = 50_f32; + let (font, glyphs) = layout_glyphs_roboto("Hello, world!", font_size); + + render_roboto_with_mode( + ctx, + &font, + font_size, + glyphs.iter().copied(), + Affine::translate((0., f64::from(font_size))), + DrawMode::Stroke, + ); + render_roboto_with_mode( + ctx, + &font, + font_size, + glyphs.into_iter(), + Affine::translate((0., f64::from(font_size * 2.0))), + DrawMode::Fill, + ); +} + +#[vello_test(width = 300, height = 120)] +fn glyphs_filled_then_stroked(ctx: &mut impl Renderer) { + let font_size: f32 = 50_f32; + let (font, glyphs) = layout_glyphs_roboto("Hello, world!", font_size); + + render_roboto_with_mode( + ctx, + &font, + font_size, + glyphs.iter().copied(), + Affine::translate((0., f64::from(font_size))), + DrawMode::Fill, + ); + render_roboto_with_mode( + ctx, + &font, + font_size, + glyphs.into_iter(), + Affine::translate((0., f64::from(font_size * 2.0))), + DrawMode::Stroke, + ); +} + #[vello_test(width = 300, height = 70)] fn glyphs_skewed(ctx: &mut impl Renderer) { let font_size: f32 = 50_f32; @@ -276,6 +322,32 @@ Stroke, } +fn render_roboto_with_mode( + ctx: &mut impl Renderer, + font: &FontData, + font_size: f32, + glyphs: impl Iterator<Item = Glyph>, + transform: Affine, + mode: DrawMode, +) { + ctx.set_transform(transform); + ctx.set_paint(REBECCA_PURPLE); + ctx.set_stroke(Stroke { + width: 3.0, + ..Stroke::default() + }); + let builder = ctx.glyph_run(font).font_size(font_size); + + match mode { + DrawMode::Fill => { + builder.fill_glyphs(glyphs); + } + DrawMode::Stroke => { + builder.stroke_glyphs(glyphs); + } + } +} + #[vello_test(width = 250, height = 70, skip_hybrid, cpu_u8_tolerance = 1)] fn glyphs_colr_noto(ctx: &mut impl Renderer) { render_colr_noto_with_transform(ctx, Affine::translate((0., 50.)), DrawMode::Fill);