【发布时间】:2020-01-15 23:56:06
【问题描述】:
我正在尝试手动将自定义字体添加到我的 WP 本地安装中,到目前为止我所做的:
- 从 fontsquirrel 以
.woff格式下载字体(Computer Modern) - 获取所需的 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>
但结果是这样的
似乎只加载了 Bold 和 Oblique,实际上通过在 CSS 文件中将 cmunti 替换为 cmunrm(Oblique 与 Roman)和 cmunbi 与 cmunbx(Bold Oblique 与 Bold)替换这是显示
这是什么原因造成的,如何解决?
【问题讨论】: