2013-08-28 4 views
1

Wordpress의 TinyMCE 편집기에 squirreled 맞춤 글꼴 I 글꼴을 추가하려고합니다.Wordpress의 TinyMCE 편집기에 사용자 정의 글꼴 추가

나는 글꼴 모음 드롭 다운이 나타나지만 거기에 내 자신의 사용자 정의 글꼴을 가져올 수 없습니다.

내가 찾은 대부분의 자습서는 매우 혼란 스럽습니다. 누군가 나를 도울 수 있습니까?

+0

:

@font-face { font-family: 'iCielTALUHLA'; src: url('http://localhost/lucnham/wp-content/plugins/luc-nham/css/fonts/fontsiCielTALUHLA.eot?#iefix') format('embedded-opentype'), url('http://localhost/lucnham/wp-content/plugins/luc-nham/css/fonts/iCielTALUHLA.woff') format('woff'), url('http://localhost/lucnham/wp-content/plugins/luc-nham/css/fonts/iCielTALUHLA.ttf') format('truetype'), url('http://localhost/lucnham/wp-content/plugins/luc-nham/css/fonts/iCielTALUHLA.svg#iCielTALUHLA') format('svg'); font-weight: normal; font-style: normal; } /** Other fonts deracle same above */ 

는 그런 다음 아래와 같은 기본 플러그인 파일에 일부 funtions 필요합니다. - http://www.kvcodes.com/2014/05/how-to-add-google-webfonts-to-wordpress-tinymce-editor/ – Kvvaradha

답변

2

CSS를로드 할 수 있습니다. TinyMCE에 설정에서 : custom_content.css보다

content_css : "css/custom_content.css", 

같은 @font-face이 포함되어야합니다

/* load a font */ 
@font-face { 
    font-family: 'Foo'; 
    src: local('Foo'), url('path/to/Foo.woff') format('woff'); 
} 

h1 { font-family: 'Foo'; } 
+0

스타일을로드하는 것은 이런 식으로 작동하지만 어떤 이유로 글꼴 ​​얼굴을로드합니다. 하지 않습니다. –

+0

@HenrikPetterson : 당신은 내 대답을 의심하게 만들었습니다. 하지만 작동하지 않습니다 : http://jsfiddle.net/allcaps/okv8xq2w/ 글꼴로드가 의심 스럽다면 ... 항상 Google 글꼴 CDN에서 호스팅되는 스타일 시트를 포함 할 수 있습니다. 예 :'@import url (http://fonts.googleapis.com/css?family=Grand+Hotel); – allcaps

0

내 플러그인 내 설정을 수 있습니다 (하지 테마). Wordpress 4.9와 함께 작동

먼저 사용자 지정 글꼴을 폴더에 넣어야합니다. 그리고 사용자 정의 CSS 파일에서 그들을 링크하면 CSS에서 전체 경로를 호출해야합니다. 나는 내 글꼴을 모두 폴더 luc-nham/css/fonts에 넣은 다음 CSS 파일에서 테마를 호출합니다. 참고로, 제 경우에는 CSS 파일을 css 폴더에 넣고 custom_fonts.css라는 파일을 사용하면 늦게 사용하게됩니다. 나는이 문서가 당신을 위해 당신을 도움이되기를 바랍니다

/** 
* Add fonts to TinyMCE select box 
*/ 

function ln_custom_fonts_init($init) { 
    $custom_fonts = "TALUHLA=iCielTALUHLA;" . 
        "Other fonts=Other fonts;" . 
        "Other fonts=Other fontst;" . 
        "Other fonts=Other fonts"; 
    $init['font_formats'] = $custom_fonts; 
    return $init; 
} 
add_filter('tiny_mce_before_init', 'ln_custom_fonts_init'); 

/** 
* Register custom CSS file, it also affect if you call wp_edior in frontend pages 
*/ 

function ln_custom_fonts_css($mce_css) { 
    if (! empty($mce_css)) 
     $mce_css .= ','; 

    $mce_css .= plugins_url('css/custom_fonts.css', __FILE__); 

    return $mce_css; 
} 
add_filter('mce_css', 'ln_custom_fonts_css'); 

/** 
* Apply font live show in backend (when creating, editing a post, page) 
*/ 

function ln_admin_editor_fonts($hook) { 
    if($hook != 'post-new.php') { 
     return; 
    } 

    wp_register_style('custom_wp_admin_css', plugins_url('css/custom_fonts.css', __FILE__)); 
    wp_enqueue_style('custom_wp_admin_css'); 
} 
add_action('admin_enqueue_scripts', 'ln_admin_editor_fonts'); 
관련 문제