首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian >> 用户界面 >> 正文
Font应用
作者:猫头鹰    文章来源:http://blog.csdn.net/bluerain1/archive/2005/02/01/276772.aspx    更新时间:2005-9-5 20:50:23
可以通过iEikonEnv-〉***Font()来获得Cfont指针。字体有TitleFont(),DenseFont()DenseFont()AnnotationFont()Font() 5种。画下划线的方法

   font = iEikonEnv->LegendFont();

   textPoint.iY = (aRect.Height() / KMiddleTextTwoVertAlign); gc.UseFont(font);//使用legendFont

   gc.SetPenColor(colorBlue);//定义gcclor

gc.SetUnderlineStyle(EUnderlineOn);//画下划线

   gc.DrawText(text, textPoint);  gc.SetUnderlineStyle(EUnderlineOff);//下划线结束

   gc.DiscardFont();//释放内存中使用的discard

 

画删除线:

   font = iEikonEnv->SymbolFont();

   textPoint.SetXY(aRect.Width() / KMiddleTextOneHorizAlign, aRect.Height() / KMiddleTextOneVertAlign);

   gc.UseFont(font);

   gc.SetPenColor(colorGreen);

   gc.SetStrikethroughStyle(EStrikethroughOn); //开始

   gc.DrawText(text, textPoint);

   gc.SetStrikethroughStyle(EStrikethroughOff);//结束

   gc.DiscardFont();

 

gc的颜色的定义AKN_LAF_COLORTint color);可以用这宏来定义。返回的是TRgb

 

可以通过iCoeEnvCCoeEnv)中的ScreenDevice()得到CWsScreenDevice(屏幕软件装置通过这个类可以设置屏幕或询问屏幕参数)TypefaceSupport()这个方法就可以得到,手机屏幕支持的font类型。

   for (TInt i = iCurrentScrollNum; i < iNumTypefaces; i++)

       {

       // Get the i-th font on the device.

       iCoeEnv->ScreenDevice()->TypefaceSupport(*iTypefaceSupport, i);

 

       // Get the font name.

       fontName = iTypefaceSupport->iTypeface.iName.Des();

 

       // Create font specification.

       TFontSpec fontSpec(fontName, KFontSpecSize);

       iDeviceMap->GetNearestFontInTwips(fontToUse, fontSpec);

      

       // Increment baseline by two times height of font.

       textPoint.iY += (fontToUse->HeightInPixels() * KBaseLineIncrementer);

 

       // Draw text in font with graphics context.

       gc.UseFont(fontToUse);

       gc.DrawText(fontName, textPoint);

       gc.DiscardFont();

       iDeviceMap->ReleaseFont(fontToUse);

       }  

 

TFontSpec是与设备无关的字体规范(支持字高,样式),CFont是与设备有关的字体。通过TZoomFactorGetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec);得到CFont

 

注意:gc(图形上下文)是没有默认字体的,如果在调用文本绘图函数之前没有调用useFont(),将会导致严重的错误。

相关文章:
S60 3rd Edition 简介及其应用开发
Series60游戏设计参考(二)
Symbian系统的字体集合
Symbian命名规则(翻译)
构造TPtr方法总结
如何断开ACL连接
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号