View Full Version : Default font of html editor

3 Nov 2011, 1:16 AM

my problem is the following:
I have a htmleditor and i want to make it possible to set a custom default font with a setting in my application. So i am asking me how to do that.
My approach was to set the defaultFont: "a font value". The result was, that if the htmledtor loads, the correct font of my setting is selected. But when I start writing some text into the editor it is always the same font. But if I select another font of the font combobox manuylly and start writing, the correct font is selected and shown in editor.
But I don`t want to manually select the font before typing.
Can anyone help me with this?

here is my code for htmleditor:

var myEditor = new Ext.form.HtmlEditor({
cls: "fixed",
layout: "fit",
border: false,
defaultFont: settings.getDefaultFont(),
fieldLabel: ""

18 Nov 2011, 11:24 AM
It looks like the fontname is set too early and doesn't do it again when the editor is initialized. Here is how I got it to work:

var form = new Ext.form.FormPanel({
renderTo : Ext.getBody(),
width : 600,
height : 400,
title : 'Test',
labelAlign : 'top',
items : [
xtype : 'htmleditor',
fieldLabel : 'Test',
anchor : '100%',
height : 200,
listeners : {
initialize: function(field) {
field.relayCmd('fontname', 'courier new');

Notice the font name passed is actually all lowercase.

21 Nov 2011, 12:29 AM
I just included your code to my editor and now it works great. Thank you very much!!!