Font of text editor can be changed with method ApplyCharFormatL(). As with the ApplyParaFormatL(), it can be called only after the editor has been activated.
Following code sets the color, typeface, height and stroke weight of the editor:
const TInt KFontSize = 120; // Height of the typeface in twips TFontSpec fontSpec(KFontName, KFontSize); // Find the nearest available font to the TFontSpec and assign it to CFont CGraphicsDevice* screenDevice = iEikonEnv->ScreenDevice(); CFont* font; screenDevice->GetNearestFontInTwips(font, fontSpec); TCharFormat charFormat( fontSpec.iTypeface.iName, fontSpec.iHeight ); charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); charFormat.iFontPresentation.iTextColor = KRgbDarkGray; TCharFormatMask charFormatMask; charFormat.iFontPresentation.iTextColor = KRgbBlack; charFormatMask.SetAttrib(EAttColor); charFormatMask.SetAttrib(EAttFontTypeface); charFormatMask.SetAttrib(EAttFontHeight); charFormatMask.SetAttrib(EAttFontStrokeWeight); iEditor->ApplyCharFormatL(charFormat, charFormatMask); // Destroy the font screenDevice->ReleaseFont(font);
Leave a comment