@@ -156,28 +156,15 @@ func (rs *Renderer) TextRun(ctx *render.Context, run *shapedgt.Run, ln *shaped.L
156156 pos := off .Add (math32 .Vec2 (math32 .FromFixed (g .XOffset ), - math32 .FromFixed (g .YOffset )))
157157 bb := run .GlyphBoundsBox (g ).Translate (off )
158158 // rs.StrokeBounds(ctx, bb, colors.Yellow)
159-
160- data := run .Face .GlyphData (g .GlyphID )
161- switch format := data .(type ) {
162- case font.GlyphOutline :
163- rs .GlyphOutline (ctx , run , g , format , fill , stroke , bb , pos , identity )
164- case font.GlyphBitmap :
165- rs .GlyphBitmap (ctx , run , g , format , fill , stroke , bb , pos , identity )
166- case font.GlyphSVG :
167- rs .GlyphSVG (ctx , run , g , format .Source , bb , pos , identity )
168- default :
169- fmt .Printf ("unrecognized glyph data: %T\n " , data )
159+ if data , ok := run .Face .GlyphDataSVG (g .GlyphID ); ok {
160+ rs .GlyphSVG (ctx , run , g , data .Source , bb , pos , identity )
161+ } else if data , ok := run .Face .GlyphDataBitmap (g .GlyphID ); ok {
162+ rs .GlyphBitmap (ctx , run , g , data , fill , stroke , bb , pos , identity )
163+ } else if data , ok := run .Face .GlyphDataOutline (g .GlyphID ); ok {
164+ rs .GlyphOutline (ctx , run , g , data , fill , stroke , bb , pos , identity )
165+ } else {
166+ fmt .Printf ("unrecognized glyph data for glyphID: %v, face: %v\n " , g .GlyphID , run .Face .Describe ().Family )
170167 }
171- // todo: once https://github.com/go-text/typesetting/pull/254 is merged
172- // if data, ok := run.Face.GlyphDataSVG(g.GlyphID); ok {
173- // rs.GlyphSVG(ctx, run, g, data.Source, bb, pos, identity)
174- // } else if data, ok := run.Face.GlyphDataBitmap(g.GlyphID); ok {
175- // rs.GlyphBitmap(ctx, run, g, data, fill, stroke, bb, pos, identity)
176- // } else if data, ok := run.Face.GlyphDataOutline(g.GlyphID); ok {
177- // rs.GlyphOutline(ctx, run, g, data, fill, stroke, bb, pos, identity)
178- // } else {
179- // fmt.Printf("unrecognized glyph data for glyphID: %v, face: %v\n", g.GlyphID, run.Face.Describe().Family)
180- // }
181168 off .X += math32 .FromFixed (g .XAdvance )
182169 off .Y -= math32 .FromFixed (g .YAdvance )
183170 }
0 commit comments