WordPress 2023 主题内添加字体的一种办法

WordPress 5.8 版本以后引入了 theme.json 文件来控制主题的样式,这里记录一下一种添加个性化字体的方法。

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2,
	"settings": {
		"appearanceTools": true,
		"typography": {
			"dropCap": false,
			"fluid": true,
			"fontFamilies": [
				{
					"fontFace": [
						{
							"fontDisplay": "block",
							"fontFamily": "Sarasa Gothic Mono SC",
							"fontStretch": "normal",
							"fontStyle": "normal",
							"fontWeight": "400",
							"src": [
								"file:./assets/fonts/Sarasa-Gothic/sarasa-mono-sc-regular.ttf"
							]
						}
					],
					"fontFamily": "'Sarasa Gothic Mono SC', monospace",
					"name": "Sarasa Gothic Mono SC",
					"slug": "sarasa-gothic-mono-sc"
				}
			]
		},
		"useRootPaddingAwareAlignments": true
	}
}

评论

《“WordPress 2023 主题内添加字体的一种办法”》 有 1 条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注