Skip to content

Commit 2035387

Browse files
committed
Upgrade to vello with font-embolden support
Signed-off-by: Nico Burns <nico@nicoburns.com>
1 parent 026f18f commit 2035387

13 files changed

Lines changed: 52 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 18 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ serde = "1.0.228"
4242
serde_json = "1.0"
4343
zip = { version = "2.1", default-features = false, features = ["deflate"] }
4444
sha2 = "0.10"
45-
skera = "=0.1.0" # pin because of breaking changes in past patch releases
45+
skera = "=0.1.0" # pin because of breaking changes in past patch releases
4646
read-fonts = "0.37"
4747
ttf2woff2 = "0.11"
4848
wuff = "0.2"
4949

5050
# Linebender
51-
color = "0.3"
51+
5252
linebender_resource_handle = "0.1"
5353
peniko = "0.6"
5454
kurbo = "0.13"
55-
# glifo = { version = "0.0.0" }
55+
# glifo = { version = "0.0.0" }color = "0.3"
5656
# vello = { version = "0.8", features = ["wgpu"] }
5757
# vello_cpu = { version = "0.0.7", default-features = false, features = [
5858
# "std",
@@ -61,17 +61,17 @@ kurbo = "0.13"
6161
# ] }
6262
# vello_hybrid = { version = "0.0.7" }
6363
# vello_common = { version = "0.0.7" }
64-
glifo = { git = "https://github.com/linebender/vello", rev = "b5c4a3192c1a2a5cc1dc2fe45342de1de95a1dc5" }
65-
vello = { git = "https://github.com/linebender/vello", rev = "b5c4a3192c1a2a5cc1dc2fe45342de1de95a1dc5", features = [
64+
glifo = { git = "https://github.com/linebender/vello", rev = "3e1aba3ffa1286012119052cb4bc7250e1b61a4b" }
65+
vello = { git = "https://github.com/linebender/vello", rev = "3e1aba3ffa1286012119052cb4bc7250e1b61a4b", features = [
6666
"wgpu",
6767
] }
68-
vello_cpu = { git = "https://github.com/linebender/vello", rev = "b5c4a3192c1a2a5cc1dc2fe45342de1de95a1dc5", default-features = false, features = [
68+
vello_cpu = { git = "https://github.com/linebender/vello", rev = "3e1aba3ffa1286012119052cb4bc7250e1b61a4b", default-features = false, features = [
6969
"std",
7070
"text",
7171
"u8_pipeline",
7272
] }
73-
vello_hybrid = { git = "https://github.com/linebender/vello", rev = "b5c4a3192c1a2a5cc1dc2fe45342de1de95a1dc5" }
74-
vello_common = { git = "https://github.com/linebender/vello", rev = "b5c4a3192c1a2a5cc1dc2fe45342de1de95a1dc5" }
73+
vello_hybrid = { git = "https://github.com/linebender/vello", rev = "3e1aba3ffa1286012119052cb4bc7250e1b61a4b" }
74+
vello_common = { git = "https://github.com/linebender/vello", rev = "3e1aba3ffa1286012119052cb4bc7250e1b61a4b" }
7575

7676
# Rendering
7777
wgpu = "29"
@@ -94,3 +94,6 @@ wasm-bindgen-futures = "0.4"
9494

9595
# Dev-dependencies
9696
winit = { version = "0.30.2", features = ["rwh_06"] }
97+
98+
[patch.crates-io]
99+
kurbo = { git = "https://github.com/linebender/kurbo", rev = "6836244" }

crates/anyrender/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ pub trait PaintScene: RenderContext {
229229
font_size: f32,
230230
hint: bool,
231231
normalized_coords: &'a [NormalizedCoord],
232+
embolden: kurbo::Vec2,
232233
style: impl Into<StyleRef<'a>>,
233234
brush: impl Into<PaintRef<'a>>,
234235
brush_alpha: f32,
@@ -294,6 +295,7 @@ pub trait PaintScene: RenderContext {
294295
cmd.font_size,
295296
cmd.hint,
296297
&cmd.normalized_coords,
298+
cmd.embolden,
297299
&cmd.style,
298300
match cmd.brush {
299301
Paint::Solid(alpha_color) => Paint::Solid(alpha_color),

crates/anyrender/src/null_backend.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl PaintScene for NullScenePainter {
135135
_font_size: f32,
136136
_hint: bool,
137137
_normalized_coords: &'a [crate::NormalizedCoord],
138+
_embolden: kurbo::Vec2,
138139
_style: impl Into<peniko::StyleRef<'a>>,
139140
_brush: impl Into<crate::PaintRef<'a>>,
140141
_brush_alpha: f32,

crates/anyrender/src/recording.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ pub struct GlyphRunCommand<Font = FontData, Brush = Paint> {
103103
pub font_size: f32,
104104
pub hint: bool,
105105
pub normalized_coords: Vec<NormalizedCoord>,
106+
#[cfg_attr(feature = "serde", serde(default = "Default::default"))]
107+
pub embolden: kurbo::Vec2,
106108
pub style: Style,
107109
pub brush: Brush,
108110
pub brush_alpha: f32,
@@ -244,6 +246,7 @@ impl PaintScene for Scene {
244246
font_size: f32,
245247
hint: bool,
246248
normalized_coords: &'a [NormalizedCoord],
249+
embolden: kurbo::Vec2,
247250
style: impl Into<StyleRef<'a>>,
248251
paint_ref: impl Into<PaintRef<'a>>,
249252
brush_alpha: f32,
@@ -257,6 +260,7 @@ impl PaintScene for Scene {
257260
font_size,
258261
hint,
259262
normalized_coords: normalized_coords.to_vec(),
263+
embolden,
260264
style: style.into().to_owned(),
261265
brush,
262266
brush_alpha,

crates/anyrender_serialize/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl ResourceCollector {
221221
font_size: glyph_run.font_size,
222222
hint: glyph_run.hint,
223223
normalized_coords: glyph_run.normalized_coords.clone(),
224+
embolden: glyph_run.embolden,
224225
style: glyph_run.style.clone(),
225226
brush,
226227
brush_alpha: glyph_run.brush_alpha,
@@ -308,6 +309,7 @@ impl ResourceReconstructor {
308309
font_size: glyph_run.font_size,
309310
hint: glyph_run.hint,
310311
normalized_coords: glyph_run.normalized_coords.clone(),
312+
embolden: glyph_run.embolden,
311313
style: glyph_run.style.clone(),
312314
brush,
313315
brush_alpha: glyph_run.brush_alpha,

crates/anyrender_serialize/tests/serialize.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyrender::{Glyph, Paint, PaintScene};
77
use anyrender_serialize::{
88
ArchiveError, ResourceManifest, SceneArchive, SerializableRenderCommand, SerializeConfig,
99
};
10-
use kurbo::{Affine, Rect, Stroke};
10+
use kurbo::{Affine, Rect, Stroke, Vec2};
1111
use peniko::{
1212
Blob, Color, Compose, Fill, FontData, ImageAlphaType, ImageBrush, ImageData, ImageFormat, Mix,
1313
};
@@ -282,6 +282,7 @@ fn test_font_deduplication() {
282282
12.0,
283283
false,
284284
&[],
285+
Vec2 { x: 0.0, y: 0.0 },
285286
Fill::NonZero,
286287
Color::from_rgb8(0, 0, 0),
287288
1.0,
@@ -428,6 +429,8 @@ fn build_glyph_scene(font: &FontData) -> Scene {
428429
16.0,
429430
false,
430431
&[],
432+
433+
Vec2 { x: 0.0, y: 0.0 },
431434
Fill::NonZero,
432435
Color::from_rgb8(0, 0, 0),
433436
1.0,

crates/anyrender_skia/src/scene.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ impl PaintScene for SkiaScenePainter<'_> {
465465
font_size: f32,
466466
hint: bool,
467467
normalized_coords: &'a [anyrender::NormalizedCoord],
468+
_embolden: kurbo::Vec2,
468469
style: impl Into<peniko::StyleRef<'a>>,
469470
brush: impl Into<anyrender::PaintRef<'a>>,
470471
brush_alpha: f32,

crates/anyrender_vello/src/scene.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl PaintScene for VelloScenePainter<'_, '_> {
138138
font_size: f32,
139139
hint: bool,
140140
normalized_coords: &'a [NormalizedCoord],
141+
embolden: kurbo::Vec2,
141142
style: impl Into<StyleRef<'a>>,
142143
paint: impl Into<PaintRef<'a>>,
143144
brush_alpha: f32,
@@ -150,6 +151,9 @@ impl PaintScene for VelloScenePainter<'_, '_> {
150151
.font_size(font_size)
151152
.hint(hint)
152153
.normalized_coords(normalized_coords)
154+
.font_embolden(vello::FontEmbolden::new(kurbo::Diagonal2::new(
155+
embolden.x, embolden.y,
156+
)))
153157
.brush(paint.into())
154158
.brush_alpha(brush_alpha)
155159
.transform(transform)

crates/anyrender_vello_cpu/src/scene.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ impl PaintScene for VelloCpuScenePainter {
125125
font_size: f32,
126126
hint: bool,
127127
normalized_coords: &'a [NormalizedCoord],
128+
_embolden: kurbo::Vec2,
128129
style: impl Into<StyleRef<'a>>,
129130
paint: impl Into<PaintRef<'a>>,
130131
_brush_alpha: f32,

0 commit comments

Comments
 (0)