feat(性能优化): 优化蒙版处理与字体更新性能,保持渲染一致

This commit is contained in:
xiaoqidun committed 2026-09-12 12:25:18 +08:00
1 parent c5abb3667a
commit 565b7f6db4
4 files changed
+36 -17

No files matched your search

+1 -11
View File
@@ -20,8 +20,6 @@ import (
"image"
"io"
"io/fs"
"github.com/tdewolff/canvas"
)
// Open 打开OFD文件
@@ -71,18 +69,10 @@ func NewRenderer(reader *Reader, opts ...RendererOption) *Renderer {
RenderAnnotations: true,
DrawParams: reader.drawParamCache,
CompositeGraphicUnits: reader.compositeGraphicUnitCache,
FontMap: make(map[string]*canvas.FontFamily),
FontGIDMap: make(map[string]map[uint16]rune),
FontCIDMap: make(map[string]map[uint16]rune),
fontCache: make(map[fontCacheKey]*canvas.FontFamily),
fontSourceCache: make(map[string][]fontSource),
fontSourceUsed: make(map[string]fontSource),
fontDirCandidates: make(map[string][]fontFileCandidate),
fontFSCandidates: make(map[int][]fontFileCandidate),
textGlyphPathCache: make(map[textGlyphPathCacheKey]textGlyphPathCacheValue),
templatePageCache: make(map[string]*PageContent),
imageCache: make(map[string]image.Image),
}
r.resetFontCache()
for _, opt := range opts {
opt(r)
}