改变CEikEdwin字体大小的两种方法

先说第一种,它只适用于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());
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值