45

this way i initialize tinyMCE to a textarea. font, bold italic is working but font size select is not working .

tinymce.init({
    selector: "textarea#content",
    theme: "modern",
    width: 586,
    height: 300,
    menubar:false,
    font_size_classes : "fontSize1, fontSize2, fontSize3, fontSize4, fontSize5, fontSize6",//i used this line for font sizes 
    content_css: "css/content.css",
    toolbar: "sizeselect | bold italic | fontselect | fontsize",//used font size for showing font size toolbar   
style_formats: [

    {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ],
});**
Thariama
  • 50,002
  • 13
  • 138
  • 166
Hasnain
  • 529
  • 2
  • 7
  • 9

4 Answers4

113

All you need to do is to add fontsizeselect to your toolbar config param:

toolbar: "sizeselect | bold italic | fontselect |  fontsizeselect",

Update:

tinymce.init({
  fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt"
});
Thariama
  • 50,002
  • 13
  • 138
  • 166
10

This may be of use for perspective. Below is my TinyMCE init JS code which includes the option for font type and size.

tinymce.init({
    selector: '#articletextarea',
    plugins: [
        'advlist autolink lists link image charmap preview hr anchor pagebreak',
        'searchreplace wordcount visualblocks visualchars code',
        'insertdatetime media nonbreaking table contextmenu directionality',
        'emoticons template paste textcolor colorpicker textpattern imagetools codesample'
    ],
    toolbar: 'codesample | bold italic sizeselect fontselect fontsizeselect | hr alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | insertfile undo redo | forecolor backcolor emoticons | code',
    fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
    height: "350",
    menubar: false
});
Andrew
  • 18,680
  • 13
  • 103
  • 118
JGilmartin
  • 8,683
  • 14
  • 66
  • 85
5
theme_modern_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
font_size_style_values: "12px,13px,14px,16px,18px,20px",

toolbar: "insertfile undo redo | fontsizeselect |
d.raev
  • 9,216
  • 8
  • 58
  • 79
2

I'm really annoyed at how wordpress seems to endeavour to make people wanna dig into the background and play with the codes, even for supposedly basic functions like changing fonts.

Luckily, I found a way to enable the font size menu without doing any real coding.

Just -

  1. Use the plugin 'TinyMCE Advanced'
  2. Activate it in settings.

More detailed instructions here.