CKEditor 4 - How to set the default font?

I am using CKEditor 4 and I want to set the default font. I added "font_defaultLabel" with my font selection, but it does not work ...

I found this solution on the Internet, but this is a trick for me, not a real solution:

CKEDITOR.on( 'instanceReady', function( ev ) { ev.editor.setData('<span style="font-family:Arial, Verdana, sans-serif;">&shy;</span>'); }); 

Can someone help me?

Epokk

+4
source share
2 answers

you can use the dataprocessor ckeditor to change (for example) paragraphs of your choice for the font size, font family, this will affect any paragraph entered in ckeditor if it is inserted, written or modified in the source; something like that:

 CKEDITOR.on('instanceReady', function( ev ) { ev.editor.dataProcessor.htmlFilter.addRules({ elements: { p: function (e) { e.attributes.style = 'font-size:' + fontsizevariable + 'px; font-family:' + fontfamilyvariable + ';'; } } }); }); 

same for dataProcessor.dataFilter

But if you intend to view html created outside of your environment, these rules can make it a real mess.

+9
source

CKeditor uses the default css file for it: contents.css You can change the fonts used. Just make sure you use the same css (or just the font) when displaying the contents of CKeditor without CKeditor.

0
source

All Articles