Interspire Product Knowledge Base

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Remove from favorites Remove from favorites

Remove Highlighting Remove Highlighting

Edit this Article

Export to PDF

User Opinions (36 votes)

75% thumbs up 25% thumbs down

How would you rate this answer?

Thank you for rating this answer.

How can I set a default font for the editor?

There are a few things to be done here. Lets say we want to change the default font to verdana, and make sure everything uses it.

Part 1

Firstly, we need to set the font for the editor. You'll need to create a style sheet (.css) file. Just put this code into it (or whatever style you want):

body {
    font-family: verdana;
    font-size: 10pt;

Then open up /admin/includes/classes/class.editor.php and find:

$myDE = new devedit;
and on a new line after that, put:


Put the URL of the style sheet file you created just before.

Part 2

Then the next part we strip out any other fonts the user may have put in. So open up  /admin/includes/classes/class.engine.php and find:

if($k != "wysiwyg" && $k != "filedata" && gettype($_POST[$k]) == "string"){
    $_POST[$k] = htmlspecialchars_utf8($v);

then after that (but before the next } ) place this code:

if($k == "wysiwyg"){
    $patterns[0] = '/\<font([^>])*face\="([^"]*)"/i';
    $patterns[1] = '/\<([\w]+) style="([^"]*)font-family\:[^;"]*[;]?([^"]*)"/i';
    $patterns[2] = '/\<([\w]+) style=" "/i';
    $replacements[0] = '<font $1';
    $replacements[1] = '<$1 style="$2 $3"';
    $replacements[2] = '<$1';    

    $v = preg_replace($patterns, $replacements, $v);
    $_POST[$k] = $v;

That strips out all fonts used. Although when using the editor they CAN select different fonts, that will be removed in this code after submission.

If you want to impose the same font limitation for authors who submit through the public-area login, open up /includes/classes/class.sanatize.php and find:

            $_POST['wysiwyg'] = $_POST['wysiwyg_html'];

and add this code after it:

$patterns[0] = '/\<font([^>])*face\="([^"]*)"/i';
$patterns[1] = '/\<([\w]+) style="([^"]*)font-family\:[^;"]*[;]?([^"]*)"/i';
$patterns[2] = '/\<([\w]+) style=" "/i';
$replacements[0] = '<font $1';
$replacements[1] = '<$1 style="$2 $3"';
$replacements[2] = '<$1';   

$_POST['wysiwyg'] = preg_replace($patterns, $replacements, $_POST['wysiwyg']);

Now you can go to your style file for the public area and change the font to verdana. E.g. open up /templates/{your-template}/Styles/styles.css and find all the "font-family:" sections and change the relevant ones to Verdana.

Also, because you've set the fonts in the style sheets, and not hard coded it into every submission (we're actually removing the fonts from them), should you ever want to change fonts, its just a matter of editing the style sheets and everything will display how you want.

Powered by Interspire Knowledge Manager - World's #1 Best Selling FAQ and Knowledge Base Software