mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 13:56:32 +08:00
1 parent
5cc811c2a1
commit
20e1bf95cd
2 files changed
+8
-1
No files matched your search
@@ -49,7 +49,7 @@ func FaceInfo(data []byte, index int) Face {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
return Face{Index: index, FullName: name(4, 6, 16, 1), Family: name(16, 1), Style: name(17, 2), PostScriptName: name(6), Names: NamesFromTable(data)}
|
||||
return Face{Index: index, FullName: name(4, 6, 16, 1), Family: name(16, 1), Style: name(17, 2), PostScriptName: name(6), Names: fontNamesFromValues(records, values)}
|
||||
}
|
||||
|
||||
// FileCount 校验字体或集合头并读取字体数量
|
||||
|
||||
@@ -96,6 +96,13 @@ func fontFaceNames(file io.ReaderAt, offset int64) []string {
|
||||
// 返回: []string 字体名称列表
|
||||
func NamesFromTable(data []byte) []string {
|
||||
records, values := fontNameValues(data)
|
||||
return fontNamesFromValues(records, values)
|
||||
}
|
||||
|
||||
// fontNamesFromValues 从已解码记录生成去重名称,保留原有顺序及样式匹配
|
||||
// 入参: records 名称记录, values 已解码的名称文本
|
||||
// 返回: []string 字体名称列表
|
||||
func fontNamesFromValues(records []fontNameRecord, values map[[4]uint16]string) []string {
|
||||
var names []string
|
||||
seen := make(map[string]bool)
|
||||
for _, record := range records {
|
||||
|
||||
Reference in new issue
Block a user