From c537f88f2ee9f1b22ebebe39c3c6e5233913d8d5 Mon Sep 17 00:00:00 2001 From: Erzbir Date: Thu, 20 Aug 2026 15:06:35 +0800 Subject: [PATCH] feat: support PostScript names for fonts --- settings.yaml | 8 +++++++- templates/layout.html | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/settings.yaml b/settings.yaml index 8a2dbeb..626cf93 100644 --- a/settings.yaml +++ b/settings.yaml @@ -66,10 +66,16 @@ spec: label: "$value.file" children: - $formkit: text - name: name + name: family_name label: 字体名称 placeholder: "JetBrains Mono" validation: "required:trim|length:1,64" + - $formkit: text + name: postscript_name + label: PostScript Name + placeholder: "JetBrainsMono-Regular" + validation: "length:0,64" + help: "用于匹配系统中已安装的本地字体" - $formkit: attachment name: file label: 自定义字体文件 diff --git a/templates/layout.html b/templates/layout.html index b3e88a4..89b92b5 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -155,8 +155,9 @@ [# th:each="font : ${theme.config.style.custom_fonts}"] @font-face { font-display: swap; - font-family: "[(${font.name})]"; - src: local("[(${font.name})]"), url("[(${font.file})]") format("[(${font.format})]"); + font-family: "[(${font.family_name})]"; + 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-weight: [(${font.advanced ? #objects.nullSafe(font.weight, '400') : '400'})]; font-display: [(${font.advanced ? #objects.nullSafe(font.display, 'swap') : 'swap'})]; @@ -190,7 +191,7 @@ :root { --family-theme-font: [# th:each="font, stat : ${theme.config.style.custom_fonts}"] - "[(${font.name})]"[# th:if="${!stat.last}"],[/] + "[(${font.family_name})]"[# th:if="${!stat.last}"],[/] [/]; }