From d7005bb42844a468cf6813ad87ab28fdb4c8a320 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Thu, 28 Nov 2024 13:43:07 +1300 Subject: [PATCH] Remove skrifa from vello's public API Signed-off-by: Nico Burns --- Cargo.lock | 1 + examples/scenes/Cargo.toml | 1 + examples/scenes/src/simple_text.rs | 15 +++++++++++---- vello/src/lib.rs | 1 - vello/src/scene.rs | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc8f811cd..92dda724c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2035,6 +2035,7 @@ dependencies = [ "image", "rand", "roxmltree", + "skrifa", "vello", "web-time", ] diff --git a/examples/scenes/Cargo.toml b/examples/scenes/Cargo.toml index 54d6cdd9f..14d379bcc 100644 --- a/examples/scenes/Cargo.toml +++ b/examples/scenes/Cargo.toml @@ -11,6 +11,7 @@ workspace = true [dependencies] vello = { workspace = true } +skrifa = { workspace = true } anyhow = { workspace = true } clap = { workspace = true, features = ["derive"] } image = { workspace = true, features = ["jpeg"] } diff --git a/examples/scenes/src/simple_text.rs b/examples/scenes/src/simple_text.rs index 9fe417d47..e321a89e2 100644 --- a/examples/scenes/src/simple_text.rs +++ b/examples/scenes/src/simple_text.rs @@ -3,9 +3,10 @@ use std::sync::Arc; +use skrifa::prelude::NormalizedCoord; +use skrifa::{raw::FontRef, MetadataProvider}; use vello::kurbo::Affine; use vello::peniko::{Blob, Brush, BrushRef, Color, Font, StyleRef}; -use vello::skrifa::{raw::FontRef, MetadataProvider}; use vello::{Glyph, Scene}; // This is very much a hack to get things working. @@ -148,7 +149,7 @@ impl SimpleText { let brush = brush.into(); let style = style.into(); let axes = font_ref.axes(); - let font_size = vello::skrifa::instance::Size::new(size); + let font_size = skrifa::instance::Size::new(size); let var_loc = axes.location(variations.iter().copied()); let charmap = font_ref.charmap(); let metrics = font_ref.metrics(font_size, &var_loc); @@ -161,7 +162,13 @@ impl SimpleText { .font_size(size) .transform(transform) .glyph_transform(glyph_transform) - .normalized_coords(var_loc.coords()) + .normalized_coords( + var_loc + .coords() + .iter() + .copied() + .map(NormalizedCoord::to_bits), + ) .brush(brush) .hint(false) .draw( @@ -210,7 +217,7 @@ impl SimpleText { } fn to_font_ref(font: &Font) -> Option> { - use vello::skrifa::raw::FileRef; + use skrifa::raw::FileRef; let file_ref = FileRef::new(font.data.as_ref()).ok()?; match file_ref { FileRef::Font(font) => Some(font), diff --git a/vello/src/lib.rs b/vello/src/lib.rs index ea72f388a..676aa9f5f 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -111,7 +111,6 @@ pub mod low_level { pub use peniko; /// 2D geometry, with a focus on curves. pub use peniko::kurbo; -pub use skrifa; #[cfg(feature = "wgpu")] pub use wgpu; diff --git a/vello/src/scene.rs b/vello/src/scene.rs index d3b3e1930..0310d5b15 100644 --- a/vello/src/scene.rs +++ b/vello/src/scene.rs @@ -400,7 +400,7 @@ impl<'a> DrawGlyphs<'a> { } /// Sets the normalized design space coordinates for a variable font instance. - pub fn normalized_coords(mut self, coords: &[NormalizedCoord]) -> Self { + pub fn normalized_coords(mut self, coords: impl Iterator) -> Self { self.scene .encoding .resources @@ -410,7 +410,7 @@ impl<'a> DrawGlyphs<'a> { .encoding .resources .normalized_coords - .extend_from_slice(coords); + .extend(coords.map(NormalizedCoord::from_bits)); self.run.normalized_coords.end = self.scene.encoding.resources.normalized_coords.len(); self }