Custom font in ckeditor

I am trying to add a custom font but cannot. I get an error below code. The font name is added to the drop-down menu, but it does not change ...

my code

config.js:

CKEDITOR.editorConfig = function( config )
{
config.contentsCss = 'fonts.css';
config.font_names = 'Dekers/dekers_true' + config.font_names;
}

fonts.css:

@font-face {  
font-family: "dekers_true", serif;
src: url(fonts/Dekers_light.eot ); /* IE */  
src: local("Dekers"), url("fonts/Dekers_light.ttf") format("truetype"); /*non-IE*/  
}
+6
source share
3 answers

Your own CSS file should contain the basic style for the CKEditor body. CKEditor only loads this CSS file in the iframe.

@font-face {  
    font-family: "dekers_true"; /* font name for the feature use*/
    src: url(fonts/Dekers_light.eot ); /* IE */  
    src: local("Dekers"), url("fonts/Dekers_light.ttf") format("truetype"); /*non-IE*/  
}
body {
    font: normal 13px/1.2em dekers_true, serif;
    color: #333;
}
p {
    font: normal 13px/1.2em dekers_true, serif;
    margin-top: 0;
    margin-bottom: 0.5em
}
...

And how to add a font declaration to your main site CSS file.

Update: Alternative. You can declare your custom styles, for example.

config.stylesSet = [
    { name : 'Pretty font face', element : 'span', attributes : { 'class' : 'pretty_face' } },
    ... 
];

, .pretty_face, . rte, contentsCSS.

+5

config.js

config.font_names = 'Arial/Arial, Helvetica, sans-serif;' +
    'Comic Sans MS/Comic Sans MS, cursive;' +
    'Courier New/Courier New, Courier, monospace;' +
    'Georgia/Georgia, serif;' +
    'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' +
    'Tahoma/Tahoma, Geneva, sans-serif;' +
    'Times New Roman/Times New Roman, Times, serif;' +
    'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' +
    'Verdana/Verdana, Geneva, sans-serif;' + 
    **'Dekers/dekers_true';**

CSS. "", "".

+4

, config.contentCss:

config.contentsCss = [ '/css/mysitestyles.css', 'https://fonts.googleapis.com/css?family=Roboto' ]

( .title { font-family: 'Roboto', sans-serif;), - , .

, config.styleSet:

config.styleSet = [ { 'name': 'Title', 'element': 'h1', 'attributes': { 'class': 'title' } ]

0

All Articles