Skip to content

Commit 89808f0

Browse files
committed
Implement font embolden for hybrid/cpu
Signed-off-by: Nico Burns <nico@nicoburns.com>
1 parent 84bbfa6 commit 89808f0

5 files changed

Lines changed: 11 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/anyrender_vello_cpu/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ anyrender = { workspace = true }
2828
debug_timer = { workspace = true }
2929
kurbo = { workspace = true }
3030
peniko = { workspace = true }
31+
glifo = { workspace = true }
3132

3233
# WindowRenderer backends
3334
softbuffer_window_renderer = { workspace = true, optional = true }

crates/anyrender_vello_cpu/src/scene.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyrender::{NormalizedCoord, Paint, PaintRef, PaintScene, RenderContext};
2-
use kurbo::{Affine, Rect, Shape, Stroke};
2+
use glifo::FontEmbolden;
3+
use kurbo::{Affine, Diagonal2, Rect, Shape, Stroke};
34
use peniko::{BlendMode, Color, Fill, FontData, ImageBrush, StyleRef};
45
use vello_cpu::{ImageSource, PaintType, Pixmap};
56

@@ -125,7 +126,7 @@ impl PaintScene for VelloCpuScenePainter {
125126
font_size: f32,
126127
hint: bool,
127128
normalized_coords: &'a [NormalizedCoord],
128-
_embolden: kurbo::Vec2,
129+
embolden: kurbo::Vec2,
129130
style: impl Into<StyleRef<'a>>,
130131
paint: impl Into<PaintRef<'a>>,
131132
_brush_alpha: f32,
@@ -154,6 +155,7 @@ impl PaintScene for VelloCpuScenePainter {
154155
.font_size(font_size)
155156
.hint(hint)
156157
.normalized_coords(normalized_coords)
158+
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
157159
.glyph_transform(glyph_transform.unwrap_or_default())
158160
.fill_glyphs(glyphs.map(into_vello_cpu_glyph));
159161
}

crates/anyrender_vello_hybrid/src/scene.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyrender::{NormalizedCoord, Paint, PaintRef, PaintScene, RenderContext};
2-
use kurbo::{Affine, Rect, Shape, Stroke};
2+
use glifo::FontEmbolden;
3+
use kurbo::{Affine, Diagonal2, Rect, Shape, Stroke};
34
use peniko::{BlendMode, Color, Fill, FontData, ImageBrush, ImageData, StyleRef};
45
use rustc_hash::FxHashMap;
56
use vello_common::paint::{ImageId, ImageSource, PaintType};
@@ -196,7 +197,7 @@ impl PaintScene for VelloHybridScenePainter<'_> {
196197
font_size: f32,
197198
hint: bool,
198199
normalized_coords: &'a [NormalizedCoord],
199-
_embolden: kurbo::Vec2,
200+
embolden: kurbo::Vec2,
200201
style: impl Into<StyleRef<'a>>,
201202
paint: impl Into<PaintRef<'a>>,
202203
_brush_alpha: f32,
@@ -225,6 +226,7 @@ impl PaintScene for VelloHybridScenePainter<'_> {
225226
.font_size(font_size)
226227
.hint(hint)
227228
.normalized_coords(normalized_coords)
229+
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
228230
.glyph_transform(glyph_transform.unwrap_or_default())
229231
.fill_glyphs(glyphs.map(into_vello_hybrid_glyph));
230232
}

crates/anyrender_vello_hybrid/src/webgl_scene.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl PaintScene for WebGlScenePainter<'_> {
203203
.font_size(font_size)
204204
.hint(hint)
205205
.normalized_coords(normalized_coords)
206+
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
206207
.glyph_transform(glyph_transform.unwrap_or_default())
207208
.fill_glyphs(glyphs.map(into_vello_glyph));
208209
}

0 commit comments

Comments
 (0)