feat: 更好的自定义字体配置

This commit is contained in:
wb_guodonghao
2022-10-21 14:27:34 +08:00
parent 56e4836260
commit 8f7e6ccfb3
5 changed files with 24 additions and 38 deletions

View File

@@ -2,9 +2,10 @@
* 在此处配置字体
*/
const BLOG = require('../blog.config')
// const { fontFamily } = require('tailwindcss/defaultTheme')
function CJK () {
function CJK() {
switch (BLOG.LANG.toLowerCase()) {
case 'zh-cn':
case 'zh-sg':
@@ -32,12 +33,12 @@ const fontSerifCJK = !CJK()
: [`"Noto Serif CJK ${CJK()}"`, `"Noto Serif ${CJK()}"`]
const fontFamilies = {
sans: ['-apple-system', 'BlinkMacSystemFont', '"Apple Color Emoji"',
sans: [...(BLOG.CUSTOM_FONT ? BLOG.CUSTOM_FONT_SANS : []), '-apple-system', 'BlinkMacSystemFont', '"Apple Color Emoji"',
'"Segoe UI Emoji"', '"Segoe UI Symbol"', '"Segoe UI"', '"PingFang SC"',
'HarmonyOS_Regular', '"Hiragino Sans GB"', '"Microsoft YaHei"', '"Helvetica Neue"',
'Helvetica', '"Source Han Sans SC"', '"Noto Sans CJK SC"', '"WenQuanYi Micro Hei"',
'Arial', 'sans-serif', ...fontSansCJK],
serif: ['STZhongsong', 'STSong', '"Noto Serif CJK"', '"Noto Serif SC"', 'PMingLiu',
serif: [...(BLOG.CUSTOM_FONT ? BLOG.CUSTOM_FONT_SERIF : []), 'STZhongsong', 'STSong', '"Noto Serif CJK"', '"Noto Serif SC"', 'PMingLiu',
'SimSun', '"WenQuanYi Bitmap Song"', '"Times New Roman"', 'Times', 'serif',
'"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"', ...fontSerifCJK],
noEmoji: [
@@ -46,8 +47,7 @@ const fontFamilies = {
'-apple-system',
'BlinkMacSystemFont',
'sans-serif'
],
custom: BLOG.FONT_CUSTOM_FAMILY
]
}
module.exports = fontFamilies