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

+3 -6
View File
@@ -237,18 +237,15 @@ func (s *Session) Close() error {
// 入参: fonts 字体文件列表
// 返回: error 错误信息
func (s *Session) SetFonts(fonts []FontFile) error {
opts := []ofdgo.RendererOption{
ofdgo.WithDPI(s.Renderer.DPI),
ofdgo.WithAnnotations(s.Renderer.RenderAnnotations),
}
if len(fonts) > 0 {
fontFS := ofdgo.NewFontFS(fonts)
if fontFS.Len() == 0 {
return fmt.Errorf("invalid font file")
}
opts = append(opts, ofdgo.WithFontFS(fontFS))
s.Renderer.SetFontFS(fontFS)
} else {
s.Renderer.SetFontFS()
}
s.Renderer = ofdgo.NewRenderer(s.Reader, opts...)
return nil
}