Skip to content

Commit

Permalink
Remove skrifa from vello's public API
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Burns <[email protected]>
  • Loading branch information
nicoburns committed Nov 28, 2024
1 parent 15082ba commit d7005bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/scenes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
15 changes: 11 additions & 4 deletions examples/scenes/src/simple_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -210,7 +217,7 @@ impl SimpleText {
}

fn to_font_ref(font: &Font) -> Option<FontRef<'_>> {
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),
Expand Down
1 change: 0 additions & 1 deletion vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions vello/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = i16>) -> Self {
self.scene
.encoding
.resources
Expand All @@ -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
}
Expand Down

0 comments on commit d7005bb

Please sign in to comment.