我正在尝试手动将自定义字体添加到我的本地主机WP安装中,目前为止我所做的是:
下载fontsquirrel中的字体(Computer Modern).woff
格式化所需的4个文件(Serif):罗马(cmunrm)、加粗(cmunbx)、斜体(cmunti)、加粗斜体(cmunbi)
将这4个文件放入文件夹中C:\\xampp\\htdocs\\sitename\\wp-includes\\fonts\\latex
在中写入以下内容style.css
CSS代码
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunrm.woff\');
font-style: normal;
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunbx.woff\');
font-weight: bold;
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunti.woff\');
font-style: italic, oblique;
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunbi.woff\');
font-weight: bold;
font-style: italic, oblique;
}
body {
font-family: "Computer Modern", serif;
}
在WP编辑器中编写以下HTML代码
This is normal text
<strong>This is bold text</strong>
<em>This is oblique text</em>
<em><strong>This is bold and oblique text</strong></em>
但结果是
似乎只有粗体和斜体被加载,实际上是通过替换
cmunti
具有
cmunrm
(斜接罗马字母)和
cmunbi
具有
cmunbx
(粗体斜体加粗体)在CSS文件中显示
这是因为什么,如何解决?
最合适的回答,由SO网友:sound wave 整理而成
不知道为什么,但这解决了问题
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunrm.woff\');
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunti.woff\');
font-style: italic;
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunbx.woff\');
font-weight: bold;
}
@font-face {
font-family: "Computer Modern";
src: url(\'http://localhost/sitename/wp-includes/fonts/latex/cmunbi.woff\');
font-weight: bold;
font-style: italic;
}