fix(编辑能力): 修复嵌入字体编辑报错
build.yaml / build (push) Successful in 45s

This commit is contained in:
xiaoqidun committed 2026-10-24 00:56:18 +08:00
1 parent 0021228898
commit 86f34bbdea
2 files changed
+19 -14

No files matched your search

+14 -8
View File
@@ -131,6 +131,14 @@ func NormalizeCFFCharstringsAt(data []byte, unitsPerEm uint16) ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if _, cid := dict[1230]; !cid {
for op := 1231; op <= 1238; op++ {
if _, exists := dict[op]; exists {
delete(dict, op)
changed = true
}
}
}
if transform != nil { if transform != nil {
scale := 1 / float64(unitsPerEm) scale := 1 / float64(unitsPerEm)
dict[1207] = []float64{scale, 0, 0, scale, 0, 0} dict[1207] = []float64{scale, 0, 0, scale, 0, 0}
@@ -331,10 +339,9 @@ func SanitizeCFF(data []byte) ([]byte, error) {
localSubrData = data[start:end] localSubrData = data[start:end]
} }
charStringsData := data[charStringsOff:charEnd] charStringsData := data[charStringsOff:charEnd]
delete(topDict, 1230) for op := 1230; op <= 1238; op++ {
delete(topDict, 1236) delete(topDict, op)
delete(topDict, 1237) }
delete(topDict, 1234)
delete(topDict, 15) delete(topDict, 15)
delete(topDict, 16) delete(topDict, 16)
var finalPrivData []byte var finalPrivData []byte
@@ -494,10 +501,9 @@ func sanitizeMultiFDCFF(data []byte, hdrSize int, nameIndexData []byte, topDict
} }
inlined[gid] = output.Bytes() inlined[gid] = output.Bytes()
} }
delete(topDict, 1230) for op := 1230; op <= 1238; op++ {
delete(topDict, 1236) delete(topDict, op)
delete(topDict, 1237) }
delete(topDict, 1234)
delete(topDict, 15) delete(topDict, 15)
delete(topDict, 16) delete(topDict, 16)
delete(topDict, 1206) delete(topDict, 1206)
+5 -6
View File
@@ -3984,7 +3984,7 @@ func (e *businessEngine) changeCompositeText(page int, path ofdgo.ObjectPath, in
} }
// editorFont 读取对象编辑使用的字体,匹配的外部字体不嵌入文档 // editorFont 读取对象编辑使用的字体,匹配的外部字体不嵌入文档
// 入参: args 字体资源标识 // 入参: args 字体资源标识、可选的原字形映射标记
// 返回: any 字体数据, error 错误信息 // 返回: any 字体数据, error 错误信息
func (e *businessEngine) editorFont(args []platformValue) (any, error) { func (e *businessEngine) editorFont(args []platformValue) (any, error) {
if e.currentEditor == nil { if e.currentEditor == nil {
@@ -3994,11 +3994,10 @@ func (e *businessEngine) editorFont(args []platformValue) (any, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(args) > 1 && args[1].Bool() { mapped := len(args) > 1 && args[1].Bool()
_, data, _, _, err = ofdgo.FixFontDataAggressive(data, true, false) _, data, _, _, err = ofdgo.FixFontDataAggressive(data, mapped, false)
if err != nil { if err != nil {
return nil, err return nil, err
}
} }
return successResult(map[string]any{"bytes": bytesToJS(data)}), nil return successResult(map[string]any{"bytes": bytesToJS(data)}), nil
} }