sparse tests: Add emboldened glyph snapshot Signed-off-by: Nico Burns <nico@nicoburns.com>
diff --git a/glifo/src/glyph.rs b/glifo/src/glyph.rs index c948d47..1ebfe0f 100644 --- a/glifo/src/glyph.rs +++ b/glifo/src/glyph.rs
@@ -1653,6 +1653,7 @@ hint: bool, } +#[inline(always)] fn join_bits(join: Join) -> u8 { match join { Join::Bevel => 0, @@ -1665,6 +1666,7 @@ clippy::cast_possible_truncation, reason = "Cache keys intentionally store embolden parameters at f32 precision." )] +#[inline(always)] fn f32_bits(value: f64) -> u32 { (value as f32).to_bits() }
diff --git a/sparse_strips/vello_sparse_tests/snapshots/glyphs_emboldened.png b/sparse_strips/vello_sparse_tests/snapshots/glyphs_emboldened.png new file mode 100644 index 0000000..5b4de08 --- /dev/null +++ b/sparse_strips/vello_sparse_tests/snapshots/glyphs_emboldened.png
@@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89f57ab8140371353cc2f4ed1019be299c899f6d0ec82c52204cfa334c31f94c +size 9629
diff --git a/sparse_strips/vello_sparse_tests/tests/glyph.rs b/sparse_strips/vello_sparse_tests/tests/glyph.rs index 75fb820..b0ba59d 100644 --- a/sparse_strips/vello_sparse_tests/tests/glyph.rs +++ b/sparse_strips/vello_sparse_tests/tests/glyph.rs
@@ -7,12 +7,12 @@ #[cfg(target_os = "macos")] use crate::util::layout_glyphs_apple_color_emoji; use crate::util::{layout_glyphs_noto_cbtf, layout_glyphs_noto_colr, layout_glyphs_roboto}; -use glifo::Glyph; +use glifo::{FontEmbolden, Glyph}; use std::f64::consts::FRAC_PI_4; use std::iter; use std::sync::Arc; use vello_common::color::palette::css::{BLACK, BLUE, GREEN, REBECCA_PURPLE}; -use vello_common::kurbo::{Affine, Stroke}; +use vello_common::kurbo::{Affine, Diagonal2, Stroke}; use vello_common::peniko::{Blob, FontData}; use vello_dev_macros::vello_test; @@ -126,6 +126,28 @@ .fill_glyphs(glyphs.into_iter()); } +#[vello_test(width = 760, height = 140)] +fn glyphs_emboldened(ctx: &mut impl Renderer) { + let font_size: f32 = 44_f32; + let (font, glyphs) = layout_glyphs_roboto("this is regular and emboldened text", font_size); + + ctx.set_transform(Affine::translate((0., f64::from(font_size)))); + ctx.set_paint(REBECCA_PURPLE.with_alpha(0.5)); + ctx.glyph_run(&font) + .font_size(font_size) + .hint(true) + .fill_glyphs(glyphs.into_iter()); + + let (font, glyphs) = layout_glyphs_roboto("this is regular and emboldened text", font_size); + + ctx.set_transform(Affine::translate((0., f64::from(font_size) + 58.0))); + ctx.glyph_run(&font) + .font_size(font_size) + .font_embolden(FontEmbolden::new(Diagonal2::new(1.0, 1.0))) + .hint(true) + .fill_glyphs(glyphs.into_iter()); +} + #[vello_test(width = 300, height = 70, glyph)] fn glyphs_stroked(ctx: &mut impl Renderer, enable_caching: bool) { let font_size: f32 = 50_f32;
diff --git a/vello_encoding/src/glyph_cache.rs b/vello_encoding/src/glyph_cache.rs index 2a6948b..336c9a3 100644 --- a/vello_encoding/src/glyph_cache.rs +++ b/vello_encoding/src/glyph_cache.rs
@@ -254,6 +254,7 @@ hint: bool, } +#[inline(always)] fn join_bits(join: Join) -> u8 { match join { Join::Bevel => 0, @@ -266,6 +267,7 @@ clippy::cast_possible_truncation, reason = "Cache keys intentionally store embolden parameters at f32 precision." )] +#[inline(always)] fn f32_bits(value: f64) -> u32 { (value as f32).to_bits() }