Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding @font-face to CKEditor

Tags:

I would like to add a font to the CKEditor font combo box. This in itself is easy enough. However the font I would like to add is a custom font that I use with the @font-face CSS3 attribute. I managed to do that but the editor itself does not show the custom font. If I just take the html created by CKEditor and show it in a div on the page, the custom font show nicely. I would also like to somehow add the @font-face attribute to the text area of CKEditor, so my users can see the custom font as they type.

Is this possible?

like image 701
nivcaner Avatar asked Sep 09 '09 08:09

nivcaner


People also ask

How to add font family in CKEditor 5?

Configuring the font family featureUse the config. fontFamily. options configuration option to do so.

How do I change the default font in CKEditor?

To change the default font for text to which a style has not been applied, open \CRM\WWWRoot\ckeditor\contents. css and edit the body section at the top of the file. The following example changes the default font to Courier New.

How do you change the line height in CKEditor?

line_height="1em;1.1em;1.2em;1.3em;1.4em;1.5em" ; In this way, you'll have your custom values in dropdown and hence you can modify it accordingly.


1 Answers

add the following line to ckeditor/config.js

config.contentsCss = 'fonts.css'; //the next line add the new font to the combobox in CKEditor config.font_names = 'fontnametodisplay/yourfontname;' + config.font_names; 

where fonts.css has the @font-face attribute:

@font-face {       font-family: "yourfontname";       src: url( ../fonts/font.eot ); /* IE */       src: local("realfontname"), url("../fonts/font.TTF") format("truetype"); /*non-IE*/   } 
like image 104
nivcaner Avatar answered Oct 07 '22 20:10

nivcaner