Skip to content

Commit c0af4bb

Browse files
committed
Shift glyphs up by embolden amount
Signed-off-by: Nico Burns <nico@nicoburns.com>
1 parent 89808f0 commit c0af4bb

4 files changed

Lines changed: 33 additions & 31 deletions

File tree

crates/anyrender_vello/src/scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl PaintScene for VelloScenePainter<'_, '_> {
163163
glyphs.map(|g: anyrender::Glyph| vello::Glyph {
164164
id: g.id,
165165
x: g.x,
166-
y: g.y,
166+
y: g.y - embolden.y as f32,
167167
}),
168168
);
169169
}

crates/anyrender_vello_cpu/src/scene.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,6 @@ impl PaintScene for VelloCpuScenePainter {
138138
self.render_ctx
139139
.set_paint(anyrender_paint_to_vello_cpu_paint(paint.into()));
140140

141-
fn into_vello_cpu_glyph(g: anyrender::Glyph) -> vello_cpu::Glyph {
142-
vello_cpu::Glyph {
143-
id: g.id,
144-
x: g.x,
145-
y: g.y,
146-
}
147-
}
148-
149141
let style: StyleRef<'a> = style.into();
150142
match style {
151143
StyleRef::Fill(fill) => {
@@ -157,7 +149,11 @@ impl PaintScene for VelloCpuScenePainter {
157149
.normalized_coords(normalized_coords)
158150
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
159151
.glyph_transform(glyph_transform.unwrap_or_default())
160-
.fill_glyphs(glyphs.map(into_vello_cpu_glyph));
152+
.fill_glyphs(glyphs.map(|g| vello_cpu::Glyph {
153+
id: g.id,
154+
x: g.x,
155+
y: g.y - embolden.y as f32,
156+
}));
161157
}
162158
StyleRef::Stroke(stroke) => {
163159
self.render_ctx.set_stroke(stroke.clone());
@@ -167,7 +163,11 @@ impl PaintScene for VelloCpuScenePainter {
167163
.hint(hint)
168164
.normalized_coords(normalized_coords)
169165
.glyph_transform(glyph_transform.unwrap_or_default())
170-
.stroke_glyphs(glyphs.map(into_vello_cpu_glyph));
166+
.stroke_glyphs(glyphs.map(|g| vello_cpu::Glyph {
167+
id: g.id,
168+
x: g.x,
169+
y: g.y,
170+
}));
171171
}
172172
}
173173
}

crates/anyrender_vello_hybrid/src/scene.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,6 @@ impl PaintScene for VelloHybridScenePainter<'_> {
209209
self.scene.set_paint(paint);
210210
self.scene.set_transform(transform);
211211

212-
fn into_vello_hybrid_glyph(g: anyrender::Glyph) -> glifo::Glyph {
213-
glifo::Glyph {
214-
id: g.id,
215-
x: g.x,
216-
y: g.y,
217-
}
218-
}
219-
220212
let style: StyleRef<'a> = style.into();
221213
match style {
222214
StyleRef::Fill(fill) => {
@@ -228,7 +220,11 @@ impl PaintScene for VelloHybridScenePainter<'_> {
228220
.normalized_coords(normalized_coords)
229221
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
230222
.glyph_transform(glyph_transform.unwrap_or_default())
231-
.fill_glyphs(glyphs.map(into_vello_hybrid_glyph));
223+
.fill_glyphs(glyphs.map(|g| glifo::Glyph {
224+
id: g.id,
225+
x: g.x,
226+
y: g.y - embolden.y as f32,
227+
}));
232228
}
233229
StyleRef::Stroke(stroke) => {
234230
self.scene.set_stroke(stroke.clone());
@@ -238,7 +234,11 @@ impl PaintScene for VelloHybridScenePainter<'_> {
238234
.hint(hint)
239235
.normalized_coords(normalized_coords)
240236
.glyph_transform(glyph_transform.unwrap_or_default())
241-
.stroke_glyphs(glyphs.map(into_vello_hybrid_glyph));
237+
.stroke_glyphs(glyphs.map(|g| glifo::Glyph {
238+
id: g.id,
239+
x: g.x,
240+
y: g.y,
241+
}));
242242
}
243243
}
244244
}

crates/anyrender_vello_hybrid/src/webgl_scene.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl PaintScene for WebGlScenePainter<'_> {
174174
font_size: f32,
175175
hint: bool,
176176
normalized_coords: &'a [NormalizedCoord],
177-
_embolden: kurbo::Vec2,
177+
embolden: kurbo::Vec2,
178178
style: impl Into<StyleRef<'a>>,
179179
paint: impl Into<PaintRef<'a>>,
180180
_brush_alpha: f32,
@@ -186,13 +186,7 @@ impl PaintScene for WebGlScenePainter<'_> {
186186
self.scene.set_paint(paint);
187187
self.scene.set_transform(transform);
188188

189-
fn into_vello_glyph(g: Glyph) -> glifo::Glyph {
190-
glifo::Glyph {
191-
id: g.id,
192-
x: g.x,
193-
y: g.y,
194-
}
195-
}
189+
fn into_vello_glyph(g: Glyph) -> glifo::Glyph {}
196190

197191
let style: StyleRef<'a> = style.into();
198192
match style {
@@ -205,7 +199,11 @@ impl PaintScene for WebGlScenePainter<'_> {
205199
.normalized_coords(normalized_coords)
206200
.font_embolden(FontEmbolden::new(Diagonal2::new(embolden.x, embolden.y)))
207201
.glyph_transform(glyph_transform.unwrap_or_default())
208-
.fill_glyphs(glyphs.map(into_vello_glyph));
202+
.fill_glyphs(glyphs.map(|g| glifo::Glyph {
203+
id: g.id,
204+
x: g.x,
205+
y: g.y - embolden.y as f32,
206+
}));
209207
}
210208
StyleRef::Stroke(stroke) => {
211209
self.scene.set_stroke(stroke.clone());
@@ -215,7 +213,11 @@ impl PaintScene for WebGlScenePainter<'_> {
215213
.hint(hint)
216214
.normalized_coords(normalized_coords)
217215
.glyph_transform(glyph_transform.unwrap_or_default())
218-
.stroke_glyphs(glyphs.map(into_vello_glyph));
216+
.stroke_glyphs(glyphs.map(|g| glifo::Glyph {
217+
id: g.id,
218+
x: g.x,
219+
y: g.y,
220+
}));
219221
}
220222
}
221223
}

0 commit comments

Comments
 (0)