1

Topic: Default font family value in Combobox

Hello everybody,

I have the following question. I know how to set default font family for content, but I cannot find the way how I can change Font Family combobox value by page start. In the other words, when user opens page combobox "Font Family" should have a particular value (for example, Times New Roman).

My initialization of TinyMCE looks like
                tinyMCE.init({
                    selector: "textarea",                   
                    paste_as_text: true,                   
                    plugins: ["advlist autolink lists link image charmap print preview anchor",
                              "searchreplace visualblocks code fullscreen",
                              "insertdatetime media table contextmenu paste"],                   
                    toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code",
                    toolbar2: "formatselect fontselect fontsizeselect | bullist numlist",
                    toolbar3: "cut copy paste pastetext pasteword | undo redo | outdent indent blockquote | subscript superscript | hr removeformat | autoformat",
                    menubar: false,
                    auto_focus: "Content1",
                    content_css: "TextEditorContent1.css",
                    setup: function (ed) {
                        ed.on("init", function (ed) {                               
                            if ("<%=DT_Master.DT_Master.RadFontSize%>") tinymce.activeEditor.getBody().style.fontSize = "<%=DT_Master.DT_Master.RadFontSize%>" + "pt";                           
                            if (tinyMCE.get("Content1"))
                                tinyMCE.get("Content1").theme.resizeTo(798, $(window).height() - 510);
                        });
                        tinyMCE.DOM.bind(window, 'resize', function () {
                            if (tinyMCE.get("Content1"))
                                tinyMCE.get("Content1").theme.resizeTo(798, $(window).height() - 510);
                        });
                        ed.addButton('autoformat', {
                            title: 'Auto-Format',
                            lable: 'Auto-Format',
                            image: '../../Includes/Scripts/tiny_mce/images/af.gif',
                            onclick: function () {
                                editContent(ed.getBody());
                            }
                        });
                    }
                });

2

Re: Default font family value in Combobox

Even I am facing the same issue, let me know if there is any workaround for it.

3

Re: Default font family value in Combobox

Hi! I found the solution. You have to write the complete list of font for a particular font. For example, I wanted 'courier new' for the default. If I set 'Courier New', the combobox shows 'Font'. But if I use the full font family list, it writes 'Courier New'

this.execCommand("fontName", false, "Courier New,courier,monospace");

instead of:
this.execCommand("fontName", false, "Courier New");  <- will not work

How to find the full font name: select a font name with the combobox. Type some text. Get the content of the editor. You will see something like:

<p><span style="font-family: 'Courier New', courier, monospace; font-size: 12pt;">courier new</span></p>
<p><span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;">tahoma</span></p>
<p><span style="font-family: verdana, geneva, sans-serif; font-size: 12pt;">verdana</span></p>