Skip to content

Commit

Permalink
google 思源宋体字体
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jan 19, 2022
1 parent dd541d2 commit 26fbe3b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 41 deletions.
2 changes: 2 additions & 0 deletions components/CommonHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const CommonHead = ({ meta }) => {
<meta property='article:author' content={BLOG.AUTHOR} />
</>
)}
{/* 谷歌字体镜像 */}
<link href="https://fonts.loli.net/css2?family=Noto+Serif+SC&display=swap" rel="stylesheet"/>
</Head>
}

Expand Down
21 changes: 0 additions & 21 deletions lib/cjk.js

This file was deleted.

52 changes: 52 additions & 0 deletions lib/font.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* 在此处配置字体
*/
const BLOG = require('../blog.config')
// const { fontFamily } = require('tailwindcss/defaultTheme')

function CJK () {
switch (BLOG.LANG.toLowerCase()) {
case 'zh-cn':
case 'zh-sg':
return 'SC'
case 'zh':
case 'zh-hk':
case 'zh-tw':
return 'TC'
case 'ja':
case 'ja-jp':
return 'JP'
case 'ko':
case 'ko-kr':
return 'KR'
default:
return null
}
}

const fontSansCJK = !CJK()
? []
: [`"Noto Sans CJK ${CJK()}"`, `"Noto Sans ${CJK()}"`]
const fontSerifCJK = !CJK()
? []
: [`"Noto Serif CJK ${CJK()}"`, `"Noto Serif ${CJK()}"`]

const fontFamilies = {
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',
'SimSun', '"WenQuanYi Bitmap Song"', '"Times New Roman"', 'Times', 'serif',
'"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"', ...fontSerifCJK],
noEmoji: [
'ui-sans-serif',
'system-ui',
'-apple-system',
'BlinkMacSystemFont',
'sans-serif'
]
}

module.exports = fontFamilies
Binary file removed public/fonts/IBMPlexSansVar-Italic.woff2
Binary file not shown.
Binary file removed public/fonts/IBMPlexSansVar-Roman.woff2
Binary file not shown.
Binary file removed public/fonts/SourceSerif-Italic.var.woff2
Binary file not shown.
Binary file removed public/fonts/SourceSerif.var.woff2
Binary file not shown.
23 changes: 3 additions & 20 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
const BLOG = require('./blog.config')
const { fontFamily } = require('tailwindcss/defaultTheme')
const CJK = require('./lib/cjk')
const fontSansCJK = !CJK()
? []
: [`"Noto Sans CJK ${CJK()}"`, `"Noto Sans ${CJK()}"`]
const fontSerifCJK = !CJK()
? []
: [`"Noto Serif CJK ${CJK()}"`, `"Noto Serif ${CJK()}"`]
const fontFamilies = require('./lib/font')

module.exports = {
purge: ['./pages/**/*.js', './components/**/*.js', './layouts/**/*.js', './themes/**/*.js'],
darkMode: BLOG.APPEARANCE === 'class' ? 'media' : 'class', // or 'media' or 'class'
theme: {
fontFamily: {
sans: ['"IBM Plex Sans"', ...fontFamily.sans, ...fontSansCJK],
serif: ['"Source Serif"', ...fontFamily.serif, ...fontSerifCJK],
noEmoji: [
'"IBM Plex Sans"',
'ui-sans-serif',
'system-ui',
'-apple-system',
'BlinkMacSystemFont',
'sans-serif'
]
},
fontFamily: fontFamilies,
extend: {
colors: {
day: {
Expand Down

0 comments on commit 26fbe3b

Please sign in to comment.