Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve font loading https://github.com/siyuan-note/siyuan/issues/15879

Danielea781d30edd5
diff --git a/kernel/util/font.go b/kernel/util/font.go
index 643beee7d9..2047afdda4 100644
--- a/kernel/util/font.go
+++ b/kernel/util/font.go
@@ -103,6 +103,10 @@ func existFont(family string, fonts []*Font) bool {
func parseTTCFontFamily(fontPath string) (ret []string) {
defer logging.Recover()
+ if strings.Contains(fontPath, "Alibaba") {
+ logging.LogInfo(fontPath)
+ }
+
data, err := os.ReadFile(fontPath)
if err != nil {
//logging.LogErrorf("read font file [%s] failed: %s", fontPath, err)
@@ -121,15 +125,23 @@ func parseTTCFontFamily(fontPath string) (ret []string) {
continue
}
+ family, _ := font.Name(nil, ttc.NameIDFull)
+ family = strings.TrimSpace(family)
+ if "" != family && !strings.HasPrefix(family, ".") {
+ ret = append(ret, family)
+ }
+
family, _ := font.Name(nil, ttc.NameIDFamily)
- if "" == family {
- family, _ = font.Name(nil, ttc.NameIDTypographicFamily)
+ 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, ".") {
- continue
+ if "" != family && !strings.HasPrefix(family, ".") {
+ ret = append(ret, family)
}
- ret = append(ret, family)
}
ret = gulu.Str.RemoveDuplicatedElem(ret)
return