refactor(重构代码): 提升代码水平
build.yaml / build (push) Successful in 33s

This commit is contained in:
2026-07-09 11:10:47 +08:00
parent fa3260c108
commit 9eb9104380
5 changed files with 119 additions and 40 deletions
+5 -9
View File
@@ -227,16 +227,12 @@ func fontFSMatches(fsys fs.FS, patterns []string) []string {
func fontFSMatchesStyle(fsys fs.FS, patterns []string, bold, italic bool) []string {
var matches []fontFileMatch
seen := make(map[string]int)
add := func(pattern, name string, rank int) {
if !isFontFileName(name) {
return
}
appendFontFileMatch(&matches, seen, pattern, name, rank, bold, italic)
}
names, _ := fs.Glob(fsys, "*")
for _, pattern := range patterns {
for _, name := range names {
add(pattern, name, matchFontPatternRank(pattern, path.Base(name)))
candidates := fontFileCandidates(names, path.Base)
for _, matcher := range newFontPatternMatchers(patterns) {
for _, file := range candidates {
rank := matcher.rank(file.base)
appendFontFileMatch(&matches, seen, matcher.pattern, file.name, rank, bold, italic)
}
}
sortFontFileMatches(matches, bold, italic)