0
votes

I have activated the font selector in Silverstripe CMS TinyMCE by adding this in _config.php:

HtmlEditorConfig::get('cms')->insertButtonsBefore('formatselect', 'fontselect');

This works, now the font selector is showing. But I can only choose the basic fonts. How can I add extra fonts to this selector? For example Google fonts?

1

1 Answers

1
votes

If you want this to work a specific theme, just have an editor.css inside the css folder and define the webfont includes there (at the beginning).

Otherwise you need to tell tinyMCE the location:

HtmlEditorConfig::get('cms')->setOption('content_css','/mysite/css/editor.css');

Then you can add Googles webfonts or any other font like this:

HtmlEditorConfig::get('cms')->setOption(
    'theme_advanced_fonts',
    //left side is a custom Name to be displayed in the dropdown
    //right side is the name of the webfont, defined in the stylesheet
    'Name=WebfontFamily; AnotherName=AnotherWebfontFamily;'
);