我想将gutenberg编辑器改编成我网站的外观,并将我的web字体用于各种块元素。我一直在寻找插件的各种文件夹/ CSS文件,但没有找到任何有用的东西。编辑器的字体定义在哪里?
谢谢你们!
大卫
我不知道是否有正式方法,但你可以为此创建一个小插件(Gutenberg块编辑器资产,没有块,准确)。
gutenbergfontchanger
(或更好名称)的文件夹gutenbergfontchanger.php
的PHP文件,其代码与此类似:<?php
/*
Plugin Name: gutenbergfontchanger
*/
if (!function_exists('gutenbergfontchanger_editor_assets')) {
function gutenbergfontchanger_editor_assets()
{
wp_enqueue_style(
'gutenbergfontchanger-editor-style',
plugins_url('editor.css', __FILE__),
filemtime(plugin_dir_path(__FILE__) . 'editor.css')
);
}
add_action('enqueue_block_editor_assets', 'gutenbergfontchanger_editor_assets');
}
editor.css
的CSS文件,其中包含您的字体样式:@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,600');
.editor-styles-wrapper, .editor-post-title__input {
font-family: 'Source Sans Pro', sans-serif !important;
}