mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve font loading https://github.com/siyuan-note/siyuan/issues/15879
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
f747739fd5
commit
ea781d30ed
1 changed files with 19 additions and 7 deletions
|
@ -103,6 +103,10 @@ func existFont(family string, fonts []*Font) bool {
|
||||||
func parseTTCFontFamily(fontPath string) (ret []string) {
|
func parseTTCFontFamily(fontPath string) (ret []string) {
|
||||||
defer logging.Recover()
|
defer logging.Recover()
|
||||||
|
|
||||||
|
if strings.Contains(fontPath, "Alibaba") {
|
||||||
|
logging.LogInfo(fontPath)
|
||||||
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(fontPath)
|
data, err := os.ReadFile(fontPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//logging.LogErrorf("read font file [%s] failed: %s", fontPath, err)
|
//logging.LogErrorf("read font file [%s] failed: %s", fontPath, err)
|
||||||
|
@ -121,15 +125,23 @@ func parseTTCFontFamily(fontPath string) (ret []string) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
family, _ := font.Name(nil, ttc.NameIDFamily)
|
family, _ := font.Name(nil, ttc.NameIDFull)
|
||||||
if "" == family {
|
|
||||||
family, _ = font.Name(nil, ttc.NameIDTypographicFamily)
|
|
||||||
}
|
|
||||||
family = strings.TrimSpace(family)
|
family = strings.TrimSpace(family)
|
||||||
if "" == family || strings.HasPrefix(family, ".") {
|
if "" != family && !strings.HasPrefix(family, ".") {
|
||||||
continue
|
ret = append(ret, family)
|
||||||
|
}
|
||||||
|
|
||||||
|
family, _ := font.Name(nil, ttc.NameIDFamily)
|
||||||
|
family = strings.TrimSpace(family)
|
||||||
|
if "" != family && !strings.HasPrefix(family, ".") {
|
||||||
|
ret = append(ret, family)
|
||||||
|
}
|
||||||
|
|
||||||
|
family, _ = font.Name(nil, ttc.NameIDTypographicFamily)
|
||||||
|
family = strings.TrimSpace(family)
|
||||||
|
if "" != family && !strings.HasPrefix(family, ".") {
|
||||||
|
ret = append(ret, family)
|
||||||
}
|
}
|
||||||
ret = append(ret, family)
|
|
||||||
}
|
}
|
||||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue