Symbian
Symbian OS Library

FAQ-0533 How can I change the font for a text editor control?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: EIKON
Created: 10/23/2000 Modified: 09/04/2001
Number: FAQ-0533
Platform: ER5, Symbian OS v6.0, Symbian OS v6.1

Question:
How can I set the default font or font size for a text editor control?

Answer:
The font for a text editor control can be set using the ApplyCharFormatL method for the text editor control. This method can also be used to set any of the different character formatted attributes.
For example:

TCharFormat charFormat;
TCharFormatMask charFormatMask;

const CFont* editorFont=iEikonEnv->AnnotationFont();
charFormat.iFontSpec=editorFont->FontSpecInTwips();
charFormatMask.ClearAll();
charFormatMask.SetAttrib(EAttFontTypeface);      
charFormatMask.SetAttrib(EAttFontHeight);
iTextOutput->ApplyCharFormatL(charFormat, charFormatMask);
// iTextOutput is a pointer to a CEikGlobalTextEditor

Setting the character format requires that the internal text editor text view has been constructed. This is created once the text editor has been activated. Therefore, ApplyCharFormatL may only be called after a call to ActivateL has been made. Failing to do this will cause a Panic.