mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 13:56:32 +08:00
1 parent
2c06e5ff69
commit
478c18cb1f
3 files changed
+43
-7
No files matched your search
@@ -103,12 +103,24 @@ func (r *Renderer) cachedTextGlyphPath(face *canvas.FontFace, glyph textGlyph) (
|
||||
}
|
||||
outlines := r.canvasState().fontOutlines[face.Font]
|
||||
if outlines == nil {
|
||||
metrics, err := parseSFNTFont(fontSFNTData(face.Font.Tables))
|
||||
if err != nil {
|
||||
r.renderError = err
|
||||
return &canvas.Path{}, 0
|
||||
cache := r.canvasFontOutlines()
|
||||
outlines, _ = cache.get(face.Font)
|
||||
if outlines == nil {
|
||||
metrics, err := parseSFNTTables(face.Font.Tables)
|
||||
if err != nil {
|
||||
r.renderError = err
|
||||
return &canvas.Path{}, 0
|
||||
}
|
||||
outlines = &sfntOutliner{font: metrics}
|
||||
cost := uint64(512)
|
||||
for _, data := range metrics.Tables {
|
||||
cost += uint64(len(data)) * 8
|
||||
}
|
||||
for _, cmap := range metrics.cmaps {
|
||||
cost += uint64(len(cmap.mapping)) * 48
|
||||
}
|
||||
cache.put(face.Font, outlines, int(min(cost, uint64(cache.limit)+1)))
|
||||
}
|
||||
outlines = &sfntOutliner{font: metrics}
|
||||
r.canvasState().fontOutlines[face.Font] = outlines
|
||||
}
|
||||
path, width, err := textGlyphPath(face, glyph, outlines)
|
||||
|
||||
Reference in new issue
Block a user