我试图实现一个Adobe字体家族到Neve主题的WP,无济于事.我按照Adobe建议的步骤转移字体,我想使用,我也安装了Adobe字体插件.字体被识别,但仍然没有出现在任何字体菜单的主题.
我还安装了一个自定义CSS插件,并实现了以下代码:
<link rel="stylesheet" href="https://use.typekit.net/ati2qpt.css">
function add_custom_font() {
$font_path_ttf = get_stylesheet_directory_uri() . '/fonts/zuume-cut, sans-serif';
$extra_font_path_ttf = get_stylesheet_directory_uri() . '/fonts/zuume-cut, sans-serif';
?>
<style type="text/css">
@font-face {
font-family: 'zuume-cut, sans-serif';
src: url(<?php echo esc_url($font_path_ttf); ?>) format('truetype');
}
@font-face {
font-family: 'zuume-cut, sans-serif';
src: url(<?php echo esc_url($extra_font_path_ttf); ?>) format('truetype');
}
</style>
<?php
}
add_action('wp_head', 'add_custom_font');
add_action('customize_controls_print_styles', 'add_custom_font');
function add_custom_fonts($localized_data) {
// First Font
$localized_data['fonts']['Custom'][] = 'zuume-cut, sans-serif';
// Second Font
$localized_data['fonts']['Custom'][] = 'ExtraFontName';
return $localized_data;
}
add_filter('neve_react_controls_localization', 'add_custom_fonts');
字符串
.这段代码部分改编自另一个来源,他在这里问了一个类似的问题。我错过了什么吗?
2条答案
按热度按时间hfsqlsce1#
$font_path_ttf
和$extra_font_path_ttf
没有引用正确的字体文件。前提是您已将有效的trutype文件复制到主题的字体目录中
它们应该看起来像这样:
字符串
此外,
@font-face
规则中的font-family
属性只需要一个名称值:型
您还应该指定字体粗细和样式,以将字体文件Map到样式变体。
由于你的typekit css包含woff 2文件,你应该更喜欢它们,因为它们的上级文件压缩。所以你的代码应该看起来像这样:
型
您还应该删除css
<link>
元素-否则您可能会遇到本地和远程版本之间的冲突。zbsbpyhn2#
从我收集到的信息来看,你是说它累积起来应该是这样的?
字符串