11//! WebGL-compatible [`PaintScene`] implementation for [`vello_hybrid::Scene`].
22
33use anyrender:: { Glyph , NormalizedCoord , Paint , PaintRef , PaintScene , RenderContext } ;
4- use kurbo:: { Affine , Rect , Shape , Stroke } ;
4+ use glifo:: FontEmbolden ;
5+ use kurbo:: { Affine , Diagonal2 , Rect , Shape , Stroke } ;
56use peniko:: { BlendMode , Color , Fill , FontData , StyleRef } ;
67use vello_common:: paint:: PaintType ;
78
@@ -174,7 +175,7 @@ impl PaintScene for WebGlScenePainter<'_> {
174175 font_size : f32 ,
175176 hint : bool ,
176177 normalized_coords : & ' a [ NormalizedCoord ] ,
177- _embolden : kurbo:: Vec2 ,
178+ embolden : kurbo:: Vec2 ,
178179 style : impl Into < StyleRef < ' a > > ,
179180 paint : impl Into < PaintRef < ' a > > ,
180181 _brush_alpha : f32 ,
@@ -186,14 +187,6 @@ impl PaintScene for WebGlScenePainter<'_> {
186187 self . scene . set_paint ( paint) ;
187188 self . scene . set_transform ( transform) ;
188189
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- }
196-
197190 let style: StyleRef < ' a > = style. into ( ) ;
198191 match style {
199192 StyleRef :: Fill ( fill) => {
@@ -205,7 +198,11 @@ impl PaintScene for WebGlScenePainter<'_> {
205198 . normalized_coords ( normalized_coords)
206199 . font_embolden ( FontEmbolden :: new ( Diagonal2 :: new ( embolden. x , embolden. y ) ) )
207200 . glyph_transform ( glyph_transform. unwrap_or_default ( ) )
208- . fill_glyphs ( glyphs. map ( into_vello_glyph) ) ;
201+ . fill_glyphs ( glyphs. map ( |g| glifo:: Glyph {
202+ id : g. id ,
203+ x : g. x ,
204+ y : g. y - embolden. y as f32 ,
205+ } ) ) ;
209206 }
210207 StyleRef :: Stroke ( stroke) => {
211208 self . scene . set_stroke ( stroke. clone ( ) ) ;
@@ -215,7 +212,11 @@ impl PaintScene for WebGlScenePainter<'_> {
215212 . hint ( hint)
216213 . normalized_coords ( normalized_coords)
217214 . glyph_transform ( glyph_transform. unwrap_or_default ( ) )
218- . stroke_glyphs ( glyphs. map ( into_vello_glyph) ) ;
215+ . stroke_glyphs ( glyphs. map ( |g| glifo:: Glyph {
216+ id : g. id ,
217+ x : g. x ,
218+ y : g. y ,
219+ } ) ) ;
219220 }
220221 }
221222 }
0 commit comments