如何在WordPress站点中添加自定义字体

时间:2017-12-25 作者:Féileacán

我必须为我在Typekit中找不到并且无法上传到Fontsquirrel的网站使用字体。所以我无法制作webkit。我尝试用CSS嵌入字体@font-face, 但它似乎不起作用。

这是我的CSS:

@font-face {
    font-family: "Oz Handicraft";
    src: url(localhost/wordpress/wp-content/themes/twentythirteen_child/ozHandicraft.otf);
    font-weight: normal;
}

@font-face {
    font-family: "Liberation Regular";
    src: url(public_html/your-site/wp-content/themes/twentythirteen_child/liberationRegular.tff);
    font-weight: normal;
}

@font-face {
    font-family: "Liberation Bold";
    src: url(public_html/your-site/wp-content/themes/twentythirteen_child/liberationBold.tff);
    font-weight: normal;
}

@font-face {
    font-family: "Liberation Bold Italic";
    src: url(public_html/your-site/wp-content/themes/twentythirteen_child/liberationBoldItalic.tff);
    font-weight: normal;
}

@font-face {
    font-family: "Liberation Italic";
    src: url(public_html/your-site/wp-content/themes/twentythirteen_child/liberationItalic.tff);
    font-weight: normal;
}
有人能帮我吗?

编辑:我终于找到了问题,现在看来它正在工作。

@font-face {
    font-family: "Oz Handicraft";
    src: url(fonts/ozHandicraft.otf);
我的错误是,我在url中编写了完整的路径,而不是样式表中的路径(位于主题文件夹中)

1 个回复
SO网友:Serkan Algur

这是fontsquirrel配置数据。另存为generator\\u config。txt并与字体文件一起上载。选择专家模式。

# Font Squirrel Font-face Generator Configuration File
# Upload this file to the generator to recreate the settings
# you used to create these fonts.

{"mode":"expert","formats":["ttf"],"tt_instructor":"ttfautohint","fix_gasp":"xy","fix_vertical_metrics":"Y","metrics_ascent":"","metrics_descent":"","metrics_linegap":"","add_spaces":"Y","add_hyphens":"Y","fallback":"none","fallback_custom":"100","webonly":"Y","options_subset":"basic","subset_range":["lowercase","uppercase","currency","malagasy","turkish"],"subset_custom":"","subset_custom_range":"","subset_ot_features":"all","subset_ot_features_list":"","base64":"Y","style_link":"Y","css_stylesheet":"stylesheet.css","filename_suffix":"","emsquare":"2048","spacing_adjustment":"0","rememberme":"Y"}

结束