fonts - 如何向 TinyMCE Advanced 添加新字体

标签 fonts wordpress tinymce

我想添加例如字体“elef”,添加这种字体最简单的方法是什么?? 我使用的是 wordpress 3.9.1 和 TinyMCE Advanced vr。 4.0.2,如果这件事..

我更喜欢这个插件 https://wordpress.org/plugins/tinymce-advanced/

最佳答案

这是使用谷歌字体的方法,如果你想使用 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/

相关文章:

java - 如何使用 Java iText 检查所有使用的字体是否嵌入到 PDF 中?

html - 获得 25% 宽度的 div 并排放置并边缘到容器 div 的边缘

php - docker wordpress 容器无法连接到 mysql 容器

jquery - 如何获取宽度、高度或tinymce编辑器

javascript - 将 Tiny MCE 移动到文本区域之前

javascript - React Native 中的 Google 字体

java - 如何使用字体的 "others versions"?

objective-c - 从 Wordpress 网站下载数据的最佳方式

jquery - TinyMCE 4 和 FF/IE 中缺少图标

Android - 将自定义字体应用到 TextView 中不起作用