feat(后端架构): 完善后端扩展与字体资源解耦,修复元数据保存和缩略图底边
build.yaml / build (push) Successful in 41s

This commit is contained in:
xiaoqidun committed 2026-09-24 10:13:54 +08:00
1 parent 3ba9317cf3
commit 81e6657c65
8 files changed
+337 -80

No files matched your search

+13 -2
View File
@@ -187,6 +187,9 @@ type editorFontSubset struct {
// 入参: progress 保存进度回调
// 返回: map[string][]byte 包内字体子集, error 错误信息
func (e *Editor) subsetFonts(progress editorProgress) (map[string][]byte, error) {
if e.backends.Resources == nil {
return nil, nil
}
used := make(map[string]map[uint16]bool)
mapped := make(map[string]bool)
for _, resource := range e.resources {
@@ -194,7 +197,15 @@ func (e *Editor) subsetFonts(progress editorProgress) (map[string][]byte, error)
continue
}
sfnt := e.fonts[resource.font.ID]
if sfnt.IsTrueType && !slices.ContainsFunc([]string{"fvar", "COLR", "CBDT", "sbix", "SVG "}, func(tag string) bool { return sfnt.Tables[tag] != nil }) {
if sfnt == nil {
var err error
sfnt, err = e.backends.Resources.OpenFontResource(FontFile{Data: resource.data}, 0)
if err != nil {
return nil, err
}
e.fonts[resource.font.ID] = sfnt
}
if sfnt.CanSubset {
used[resource.font.ID] = make(map[uint16]bool)
}
}
@@ -309,7 +320,7 @@ func (e *Editor) subsetFonts(progress editorProgress) (map[string][]byte, error)
}
slices.Sort(ids)
if resource.subset == nil || resource.subset.mapped != mapped[resource.font.ID] || !slices.Equal(resource.subset.glyphs, ids) {
data, err := subsetEditorFont(resource.data, ids, mapped[resource.font.ID])
data, err := e.backends.Resources.SubsetFont(resource.data, ids, mapped[resource.font.ID])
if err != nil {
return nil, fmt.Errorf("subset font %s: %w", resource.font.FontName, err)
}