-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update vello and parley deps... (#165)
* Update vello and parley deps... ... and everything else, apparently. This pushes the new font code changes through the ecosystem. Brings everything into sync and should put us in a good place to start releasing. This works as is but depends on a vello commit that is still under review: linebender/vello#425 should land first and this should be updated with the new git rev before merging. * fmt :( * update git revs
- Loading branch information
Showing
9 changed files
with
280 additions
and
221 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,44 @@ | ||
use parley::Layout; | ||
use vello::kurbo::Affine; | ||
use vello::{ | ||
glyph::{fello::raw::FontRef, GlyphContext}, | ||
peniko::{Brush, Color}, | ||
*, | ||
kurbo::Affine, | ||
peniko::{Brush, Fill}, | ||
SceneBuilder, | ||
}; | ||
|
||
#[derive(Clone, PartialEq, Debug)] | ||
pub struct ParleyBrush(pub Brush); | ||
|
||
impl Default for ParleyBrush { | ||
fn default() -> ParleyBrush { | ||
ParleyBrush(Brush::Solid(Color::rgb8(0, 0, 0))) | ||
} | ||
} | ||
|
||
impl parley::style::Brush for ParleyBrush {} | ||
|
||
pub fn render_text(builder: &mut SceneBuilder, transform: Affine, layout: &Layout<ParleyBrush>) { | ||
let mut gcx = GlyphContext::new(); | ||
pub fn render_text(builder: &mut SceneBuilder, transform: Affine, layout: &Layout<Brush>) { | ||
for line in layout.lines() { | ||
for glyph_run in line.glyph_runs() { | ||
let mut x = glyph_run.offset(); | ||
let y = glyph_run.baseline(); | ||
let run = glyph_run.run(); | ||
let font = run.font(); | ||
let font_size = run.font_size(); | ||
let font_ref = font.as_ref(); | ||
if let Ok(font_ref) = FontRef::from_index(font_ref.data, font.index()) { | ||
let style = glyph_run.style(); | ||
let vars: [(&str, f32); 0] = []; | ||
let mut gp = gcx.new_provider(&font_ref, None, font_size, false, vars); | ||
for glyph in glyph_run.glyphs() { | ||
if let Some(fragment) = gp.get(glyph.id, Some(&style.brush.0)) { | ||
let font = vello::peniko::Font::new(font.data().0.clone(), font.index()); | ||
let style = glyph_run.style(); | ||
let coords = run | ||
.normalized_coords() | ||
.iter() | ||
.map(|coord| vello::skrifa::instance::NormalizedCoord::from_bits(*coord)) | ||
.collect::<Vec<_>>(); | ||
builder | ||
.draw_glyphs(&font) | ||
.brush(&style.brush) | ||
.transform(transform) | ||
.font_size(font_size) | ||
.normalized_coords(&coords) | ||
.draw( | ||
Fill::NonZero, | ||
glyph_run.glyphs().map(|glyph| { | ||
let gx = x + glyph.x; | ||
let gy = y - glyph.y; | ||
let xform = Affine::translate((gx as f64, gy as f64)) | ||
* Affine::scale_non_uniform(1.0, -1.0); | ||
builder.append(&fragment, Some(transform * xform)); | ||
} | ||
x += glyph.advance; | ||
} | ||
} | ||
x += glyph.advance; | ||
vello::glyph::Glyph { | ||
id: glyph.id as _, | ||
x: gx, | ||
y: gy, | ||
} | ||
}), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters