现在的位置: 首页 > 综合 > 正文

Symbian设置CEikEdwin字体

2013年09月14日 ⁄ 综合 ⁄ 共 2023字 ⁄ 字号 评论关闭

先说第一种,它只适用于2nd

  1.            TCharFormat charFormat;
  2.     Mem::FillZ(&charFormat,
    sizeof
    (TCharFormat));
  3.     TCharFormatMask   charMask;
  4.     Mem::FillZ(&charMask,
    sizeof
    (TCharFormatMask));  
  5.     TFontSpec sFontSpec = PocoUtils::NormalFont()->FontSpecInTwips();
  6.     charFormat.iFontSpec.iTypeface =  sFontSpec.iTypeface;
  7.     charMask.SetAttrib(EAttFontTypeface);
  8.     charFormat.iFontSpec.iHeight = sFontSpec.iHeight;
  9.     charMask.SetAttrib(EAttFontHeight);
  10.     charFormat.iFontPresentation.iTextColor = KDarkGreenColour;
  11.     charMask.SetAttrib(EAttColor);
  12.     charFormat.iFontPresentation.iStrikethrough = (TFontStrikethrough)EFalse;
  13.     charMask.SetAttrib(EAttFontStrikethrough);  
  14.     charFormat.iFontPresentation.iUnderline = (TFontUnderline)EFalse;
  15.     charMask.SetAttrib(EAttFontUnderline);
  16.     CCharFormatLayer* FormatLayer1 = CCharFormatLayer::NewL(charFormat,charMask);
  17.     iTitle->SetCharFormatLayer(FormatLayer1);

再来介绍第二种,它使用于2nd和3rd

  1. CFont* font=NULL;
  2. #ifdef _UIQ3_SDK_
  3.             TFontSpec fontSpec=CEikonEnv::Static()->NormalFont()->FontSpecInTwips();
  4.             fontSpec.iHeight-=fontSpec.iHeight/4;
  5.             fontSpec.iFontStyle.SetPosture(EPostureUpright);
  6.             CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(font,fontSpec);
  7. #else
  8.             font=CEikonEnv::Static()->NormalFont();
  9. #endif
  10.             CGlobalText* globalText = (CGlobalText*)edwin->Text();
  11.             TCharFormat charFormat;
  12.             Mem::FillZ(&charFormat, 
    sizeof
    (TCharFormat));
  13.             TCharFormatMask charMask;
  14.             Mem::FillZ(&charMask, 
    sizeof
    (TCharFormatMask));
  15.             TFontSpec sFontSpec = font->FontSpecInTwips();
  16.             charFormat.iFontSpec.iTypeface = sFontSpec.iTypeface;
  17.             charMask.SetAttrib(EAttFontTypeface);
  18.             charFormat.iFontSpec.iHeight = sFontSpec.iHeight;
  19.             charMask.SetAttrib(EAttFontHeight);
  20.             charFormat.iFontPresentation.iTextColor = KDarkGreenColour;
  21.             charMask.SetAttrib(EAttColor);
  22.             globalText->ApplyCharFormatL(charFormat,charMask,0,edwin->TextLength());

抱歉!评论已关闭.