javascriptcssfontstinymcefont-face

Changing the default font family in TinyMCE


I've successfully changed the default font inside the editor using the documentation here but that leaves me with a problem. The original default font no longer works in the font drop down list.

Original default: Verdana
New default: MyCustomFont

When I type into the editor I see my MyCustomFont font by default. If I try to change that to Verdana (original default) nothing happens. I can change it to any font family except Verdana. I noticed also that when I select MyCustomFont in the drop down list the content gets surrounded with a span with inline styles. This does not happen with the original default font (hence why nothing happens).

It seems to me like there's a key piece of documentation missing - how to tell the editor (the font feature in particular) that the font I've defined by default in the css is the default font.

I've Googled quite a bit but had no results. Everybody else seems to be settling for the documentation mentioned above. Am I the only one having this problem? If not, please help! :)

Please note, the answers to this question do not answer my question.


Solution

  • maybe too late but...

    $('.tinymce').tinymce({
        setup : function(ed) {
            ed.onInit.add(function(ed) {
                ed.execCommand("fontName", false, "Arial");
                ed.execCommand("fontSize", false, "2");
            });
        }
    });
    

    EDIT

    For TinyMCE 4, as @jason-tolliver and @georg states, the syntax is:

    ed.on('init', function (ed) {
        ed.target.editorCommands.execCommand("fontName", false, "Arial");
    });