diff --git a/ofdgo_font_match.go b/ofdgo_font_match.go index a37c6a7..8fe023e 100644 --- a/ofdgo_font_match.go +++ b/ofdgo_font_match.go @@ -310,13 +310,6 @@ func isFontFileName(name string) bool { } } -// fontRuleMatch 判断字体规则是否匹配 -// 入参: rule 字体匹配规则, name 字体名称 -// 返回: bool 是否匹配 -func fontRuleMatch(rule fontMatchRule, name string) bool { - return fontRuleMatchLevel(rule, name) != fontMatchNone -} - // fontRuleMatchLevel 获取字体规则匹配等级 // 入参: rule 字体匹配规则, name 字体名称 // 返回: int 匹配等级 diff --git a/ofdgo_font_util.go b/ofdgo_font_util.go index d789a80..8003d2f 100644 --- a/ofdgo_font_util.go +++ b/ofdgo_font_util.go @@ -20,13 +20,6 @@ import ( "sort" ) -// align4 计算 4 字节对齐后的长度 -// 入参: n 原始长度 -// 返回: uint32 对齐后的长度 -func align4(n uint32) uint32 { - return (n + 3) & ^uint32(3) -} - // packedGlyphRune 获取包装字体字符 // 入参: gid 字形ID // 返回: rune 包装字体字符 @@ -55,27 +48,6 @@ func calcTableChecksum(data []byte) uint32 { return sum } -// checkMissingCmap 检查是否缺失 cmap 表 -// 入参: data 字体数据 -// 返回: bool 是否缺失 -func checkMissingCmap(data []byte) bool { - if len(data) < 12 { - return true - } - numTables := binary.BigEndian.Uint16(data[4:6]) - for i := 0; i < int(numTables); i++ { - pos := 12 + i*16 - if len(data) < pos+4 { - break - } - tag := string(data[pos : pos+4]) - if tag == "cmap" { - return false - } - } - return true -} - // parseCmapMappings 解析 cmap 字符映射 // 入参: data cmap表数据 // 返回: map[rune]uint16 字符到字形映射 @@ -287,13 +259,6 @@ func buildHheaTable(numGlyphs uint16) []byte { return buf.Bytes() } -// buildMaxpTable 构建 maxp 表 -// 入参: numGlyphs 字形数量 -// 返回: []byte maxp表数据 -func buildMaxpTable(numGlyphs uint16) []byte { - return buildCFFMaxpTable(numGlyphs) -} - // buildCFFMaxpTable 构建 CFF 轮廓使用的 maxp 0.5 表 // 入参: numGlyphs 字形数量 // 返回: []byte maxp表数据 diff --git a/ofdgo_sign.go b/ofdgo_sign.go index 84a26cd..b2a0bf3 100644 --- a/ofdgo_sign.go +++ b/ofdgo_sign.go @@ -61,7 +61,6 @@ type SignedInfo struct { Seal SignatureSeal `xml:"Seal"` StampAnnot []SignatureStamp `xml:"StampAnnot"` References SignatureReferences `xml:"References"` - Raw []byte `xml:"-"` } // SignatureProvider 签名提供者信息 diff --git a/ofdgo_sign_verify.go b/ofdgo_sign_verify.go index a56bee2..f84384b 100644 --- a/ofdgo_sign_verify.go +++ b/ofdgo_sign_verify.go @@ -355,11 +355,6 @@ func parseSignatureFile(data []byte) (*SignatureFile, error) { if err := xml.Unmarshal(data, &sigFile); err != nil { return nil, err } - raw, err := xmlElementRaw(data, "SignedInfo") - if err != nil { - return nil, err - } - sigFile.SignedInfo.Raw = raw return &sigFile, nil } @@ -720,46 +715,6 @@ func compactSignatureCerts(certs [][]byte) [][]byte { return out } -// xmlElementRaw 提取XML元素原始字节 -// 入参: data XML数据, localName 元素名称 -// 返回: []byte 元素原始字节, error 错误信息 -func xmlElementRaw(data []byte, localName string) ([]byte, error) { - dec := xml.NewDecoder(bytes.NewReader(data)) - for { - tok, err := dec.Token() - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - start, ok := tok.(xml.StartElement) - if !ok || start.Name.Local != localName { - continue - } - end := int(dec.InputOffset()) - begin := bytes.LastIndex(data[:end], []byte("<")) - if begin < 0 { - return nil, fmt.Errorf("xml element not found: %s", localName) - } - depth := 1 - for depth > 0 { - tok, err = dec.Token() - if err != nil { - return nil, err - } - switch tok.(type) { - case xml.StartElement: - depth++ - case xml.EndElement: - depth-- - } - } - return append([]byte(nil), data[begin:int(dec.InputOffset())]...), nil - } - return nil, fmt.Errorf("xml element not found: %s", localName) -} - // signatureCertInfo 解析签名证书信息 // 入参: data DER编码证书 // 返回: SignatureCertInfo 签名证书信息 diff --git a/ofdgo_text.go b/ofdgo_text.go index 6a33cca..3ca78d9 100644 --- a/ofdgo_text.go +++ b/ofdgo_text.go @@ -22,13 +22,6 @@ import ( "github.com/tdewolff/canvas" ) -// parseColor 解析颜色字符串 -// 入参: val 颜色值(R G B) -// 返回: color.Color 颜色对象 -func parseColor(val string) color.Color { - return parseColorWithAlpha(val, nil) -} - // parseColorWithAlpha 解析带透明度的颜色 // 入参: val 颜色值, alpha 透明度 // 返回: color.Color 颜色对象