feat(字体匹配): 修复字体回退受文件名影响的问题
build.yaml / build (push) Successful in 36s

This commit is contained in:
xiaoqidun committed 2026-09-14 16:41:31 +08:00
1 parent 6525b01bab
commit c2ddde7c0e
1 file changed
+12 -3
+12 -3
View File
@@ -190,6 +190,18 @@ func (fsys *FontFS) matchStyle(names []string, bold, italic bool) []fontFileMatc
func fontFileMatches(candidates []fontFileCandidate, names []string, bold, italic bool) []fontFileMatch {
matches := make([]fontFileMatch, 0, len(candidates))
seen := make(map[string]int, len(candidates))
if len(names) == 0 {
for _, name := range fontDefaultSystemNames() {
for _, match := range fontFileMatches(candidates, []string{name}, bold, italic) {
key := strings.ToLower(match.name)
if _, ok := seen[key]; !ok {
seen[key] = len(matches)
matches = append(matches, match)
}
}
}
return matches
}
for i, name := range names {
if name == "" {
continue
@@ -206,9 +218,6 @@ func fontFileMatches(candidates []fontFileCandidate, names []string, bold, itali
}
}
}
if len(names) == 0 {
names = fontDefaultSystemNames()
}
for _, matcher := range newFontPatternMatchers(fontFilePatterns(names...)) {
for _, file := range candidates {
rank := matcher.rankCandidate(file)