mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 14:31:12 +08:00
feat(性能优化): 优化蒙版处理与字体更新性能,保持渲染一致
This commit is contained in:
1 parent
c5abb3667a
commit
565b7f6db4
4 files changed
+36
-17
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user