如何包含字体@font-face

How to include fonts @font-face

我下载了一种字体 libertaion_sans,它保存在 Wordpress 主题中,位于这样的字体文件夹下 \fonts\liberation_sans

我在 Youtube 上看到了很多视频,在 Whosebug 上看到了一些链接,但我没有正确地包含它们。

如果我没记错的话,我们必须在 style.css 中定义这些字体,然后再实际使用它:

font-family

谁能帮帮我。

目前,

我有兴趣使用它们 →

font-family: LiberationSans-Bold;

类似这样的内容 => 在您的 css 文件中

@font-face {
    font-family: 'YourFontName'; /*a name to be used later*/
    src: url('/fonts/font.ttf'); /*URL to font*/
}

并在任何 css 规则中使用 like font-family: 'YourFontName'
干杯!

PD:分别创建。

@font-face {
    font-family: 'LS-bold'; /*a name to be used later*/
    src: url('/fonts/ls-bold.ttf'); /*URL to font*/
}
@font-face {
    font-family: 'LS-Regular'; /*a name to be used later*/
    src: url('/fonts/ls-regular.ttf'); /*URL to font*/
}

..等...
如果你想使用粗体,你必须 font-family:'LS-bold'.
明白了吗?