feat: support PostScript names for fonts

This commit is contained in:
Erzbir
2026-08-20 15:07:35 +08:00
parent a72f97611d
commit c537f88f2e
2 changed files with 11 additions and 4 deletions
+7 -1
View File
@@ -66,10 +66,16 @@ spec:
label: "$value.file" label: "$value.file"
children: children:
- $formkit: text - $formkit: text
name: name name: family_name
label: 字体名称 label: 字体名称
placeholder: "JetBrains Mono" placeholder: "JetBrains Mono"
validation: "required:trim|length:1,64" validation: "required:trim|length:1,64"
- $formkit: text
name: postscript_name
label: PostScript Name
placeholder: "JetBrainsMono-Regular"
validation: "length:0,64"
help: "用于匹配系统中已安装的本地字体"
- $formkit: attachment - $formkit: attachment
name: file name: file
label: 自定义字体文件 label: 自定义字体文件
+4 -3
View File
@@ -155,8 +155,9 @@
[# th:each="font : ${theme.config.style.custom_fonts}"] [# th:each="font : ${theme.config.style.custom_fonts}"]
@font-face { @font-face {
font-display: swap; font-display: swap;
font-family: "[(${font.name})]"; font-family: "[(${font.family_name})]";
src: local("[(${font.name})]"), url("[(${font.file})]") format("[(${font.format})]"); src: local("[(${#strings.isEmpty(font.postscript_name) ? font.family_name : font.postscript_name})]"),
url("[(${font.file})]") format("[(${font.format})]");
font-style: [(${font.advanced ? #objects.nullSafe(font.style, 'normal') : 'normal'})]; font-style: [(${font.advanced ? #objects.nullSafe(font.style, 'normal') : 'normal'})];
font-weight: [(${font.advanced ? #objects.nullSafe(font.weight, '400') : '400'})]; font-weight: [(${font.advanced ? #objects.nullSafe(font.weight, '400') : '400'})];
font-display: [(${font.advanced ? #objects.nullSafe(font.display, 'swap') : 'swap'})]; font-display: [(${font.advanced ? #objects.nullSafe(font.display, 'swap') : 'swap'})];
@@ -190,7 +191,7 @@
:root { :root {
--family-theme-font: --family-theme-font:
[# th:each="font, stat : ${theme.config.style.custom_fonts}"] [# th:each="font, stat : ${theme.config.style.custom_fonts}"]
"[(${font.name})]"[# th:if="${!stat.last}"],[/] "[(${font.family_name})]"[# th:if="${!stat.last}"],[/]
[/]; [/];
} }
</style> </style>