feat: custom font
This commit is contained in:
@@ -102,6 +102,24 @@ spec:
|
|||||||
- label: "custom"
|
- label: "custom"
|
||||||
value: "custom"
|
value: "custom"
|
||||||
|
|
||||||
|
- $formkit: checkbox
|
||||||
|
name: custom_font_enable
|
||||||
|
id: custom_font_enable
|
||||||
|
label: 启用自定义字体文件
|
||||||
|
value: false
|
||||||
|
help: '如果启用 "使用系统字体", 此配置项不生效'
|
||||||
|
- $formkit: attachment
|
||||||
|
if: "$get(custom_font_enable).value === true"
|
||||||
|
name: custom_font_file
|
||||||
|
label: 自定义字体文件
|
||||||
|
value: ""
|
||||||
|
- $formkit: text
|
||||||
|
if: "$get(custom_font_enable).value === true"
|
||||||
|
name: custom_font_name
|
||||||
|
label: 字体名称
|
||||||
|
help: "填写上传字体文件内部声明的 字体全名 或 PostScript. 如果和上传的字体文件不匹配, 将从网络上下载字体"
|
||||||
|
value: ""
|
||||||
|
|
||||||
- $formkit: text
|
- $formkit: text
|
||||||
if: "$get(time_style).value === 'custom'"
|
if: "$get(time_style).value === 'custom'"
|
||||||
name: custom_time_style
|
name: custom_time_style
|
||||||
|
|||||||
@@ -73,6 +73,41 @@
|
|||||||
const custom = /*[[${theme.config.style.custom}]]*/;
|
const custom = /*[[${theme.config.style.custom}]]*/;
|
||||||
applyRawCss(custom);
|
applyRawCss(custom);
|
||||||
</script>
|
</script>
|
||||||
|
<th:block
|
||||||
|
th:if="${theme.config?.style?.custom_font_enable and not theme.config?.style?.system_font}"
|
||||||
|
th:with="font=${#objects.nullSafe(theme.config?.style?.custom_font_file, #theme.assets('/dist/JetBrainsMono-Regular.woff2'))},
|
||||||
|
ext=${font.substring(font.lastIndexOf('.') + 1)},
|
||||||
|
format=${ext == 'woff2' ? 'woff2' :
|
||||||
|
(ext == 'woff' ? 'woff' :
|
||||||
|
(ext == 'ttf' ? 'truetype' :
|
||||||
|
(ext == 'otf' ? 'opentype' :
|
||||||
|
(ext == 'eot' ? 'embedded-opentype' :
|
||||||
|
((ext == 'ttc' or ext == 'otc') ? 'collection' : ext)))))},
|
||||||
|
mime=${ext == 'woff2' ? 'font/woff2' :
|
||||||
|
(ext == 'woff' ? 'font/woff' :
|
||||||
|
(ext == 'ttf' ? 'font/ttf' :
|
||||||
|
(ext == 'otf' ? 'font/otf' :
|
||||||
|
(ext == 'sfnt' ? 'font/sfnt' :
|
||||||
|
(ext == 'eot' ? 'application/vnd.ms-fontobject' :
|
||||||
|
((ext == 'ttc' or ext == 'otc') ? 'font/collection' : 'application/octet-stream'))))))}">
|
||||||
|
<link rel="preload" th:href="${font}" as="font" th:type="${mime}" crossorigin />
|
||||||
|
<!--/*/
|
||||||
|
<style th:inline="css">
|
||||||
|
@font-face {
|
||||||
|
font-display: swap;
|
||||||
|
font-family: "custom";
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src:
|
||||||
|
local("[(${theme.config?.style?.custom_font_name})]"),
|
||||||
|
url("[(${font})]") format("[(${format})]");
|
||||||
|
}
|
||||||
|
:root {
|
||||||
|
--font-theme-default: custom;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
/*/-->
|
||||||
|
</th:block>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user