我想添加例如字体“elef”,添加这种字体最简单的方法是什么?? 我使用的是 wordpress 3.9.1 和 TinyMCE Advanced vr。 4.0.2,如果这件事..
最佳答案
这是使用谷歌字体的方法,如果你想使用 TTF 或类似的,请遵循这个引导:Using True type fonts in web applications .
添加/替换下拉列表中显示的字体:
add_filter( 'tiny_mce_before_init', 'wpex_mce_google_fonts_array' );
function wpex_mce_google_fonts_array( $initArray ) {
//$initArray['font_formats'] = 'Lato=Lato;Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
$theme_advanced_fonts = 'Aclonica=Aclonica;';
$theme_advanced_fonts .= 'Lato=Lato;';
$theme_advanced_fonts .= 'Michroma=Michroma;';
$theme_advanced_fonts .= 'Paytone One=Paytone One';
$initArray['font_formats'] = $theme_advanced_fonts;
return $initArray;
}
在下拉菜单中显示实时字体:
add_action( 'admin_init', 'wpex_mce_google_fonts_styles' );
function wpex_mce_google_fonts_styles() {
$font1 = 'http://fonts.googleapis.com/css?family=Aclonica:300,400,700';
add_editor_style( str_replace( ',', '%2C', $font1 ) );
$font2 = 'http://fonts.googleapis.com/css?family=Lato:300,400,700';
add_editor_style( str_replace( ',', '%2C', $font2 ) );
$font3 = 'http://fonts.googleapis.com/css?family=Michroma:300,400,700';
add_editor_style( str_replace( ',', '%2C', $font3 ) );
$font4 = 'http://fonts.googleapis.com/css?family=Paytone+One:300,400,700';
add_editor_style( str_replace( ',', '%2C', $font4 ) );
}
在内容框上显示实时字体:
add_action('admin_head-post.php', function() {
?>
<style>
@import url(http://fonts.googleapis.com/css?family=Aclonica);
@import url(http://fonts.googleapis.com/css?family=Lato);
@import url(http://fonts.googleapis.com/css?family=Michroma);
@import url(http://fonts.googleapis.com/css?family=Paytone+One);
</style>
<?php
});
基于:
关于fonts - 如何向 TinyMCE Advanced 添加新字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24105575/