style(代码风格): 整理声明顺序与字体模块
build.yaml / build (push) Successful in 51s

This commit is contained in:
xiaoqidun committed 2026-09-28 15:17:45 +08:00
1 parent 5e0da3da28
commit ee6c9f6a16
82 files changed
+4316 -4310

No files matched your search

+25 -25
View File
@@ -20,15 +20,6 @@ import (
"strings"
)
// fontMatchRule 字体匹配规则
type fontMatchRule struct {
Keys []string
Names []string
Files []string
System string
NoSyntheticBold bool
}
const (
fontMatchNone = iota
fontMatchExact
@@ -114,22 +105,13 @@ var fontMatchRules = normalizeFontMatchRules([]fontMatchRule{
var fontNameReplacer = strings.NewReplacer(" ", "", "-", "", "_", "", "(", "", ")", "", "(", "", ")", "")
// normalizeFontMatchRules 预处理固定字体规则的匹配名称,保留候选名称及顺序
// 入参: rules 字体匹配规则
// 返回: []fontMatchRule 预处理后的规则
func normalizeFontMatchRules(rules []fontMatchRule) []fontMatchRule {
for i := range rules {
rule := &rules[i]
keys := append(append(rule.Keys, rule.Names...), rule.System)
rule.Keys = nil
for _, key := range keys {
key = fontNormalizeName(key)
if key != "" && !slices.Contains(rule.Keys, key) {
rule.Keys = append(rule.Keys, key)
}
}
}
return rules
// fontMatchRule 字体匹配规则
type fontMatchRule struct {
Keys []string
Names []string
Files []string
System string
NoSyntheticBold bool
}
// FontNormalizeName 规范化字体名称
@@ -160,6 +142,24 @@ func FontSystemNames(names ...string) []string {
return fontSystemNames(names...)
}
// normalizeFontMatchRules 预处理固定字体规则的匹配名称,保留候选名称及顺序
// 入参: rules 字体匹配规则
// 返回: []fontMatchRule 预处理后的规则
func normalizeFontMatchRules(rules []fontMatchRule) []fontMatchRule {
for i := range rules {
rule := &rules[i]
keys := append(append(rule.Keys, rule.Names...), rule.System)
rule.Keys = nil
for _, key := range keys {
key = fontNormalizeName(key)
if key != "" && !slices.Contains(rule.Keys, key) {
rule.Keys = append(rule.Keys, key)
}
}
}
return rules
}
// fontNormalizeName 规范化字体名称
// 入参: name 字体名称
// 返回: string 规范化后的字体名称