Series 60 3rd上绘图时设置字体的大小

来源:互联网 发布:涉及大数据的上市公司 编辑:程序博客网 时间:2024/05/21 00:51

通常我们在绘制文字时都是使用CEikonEnv提供的NormalFont(),AnnotationFont(),TitleFont()等字体,有的情况需要调整字体的大小,下面的代码演示了如何设置字体大小的方法:

void  CEditorList3Col::Draw(const TRect& aRect) const
{
 CWindowGc& gc = SystemGc();
 
 gc.Clear( aRect );

 CFont *font = NULL;
 //获取字体信息
 TFontSpec fontSpec = iEikonEnv->LegendFont()->FontSpecInTwips();
  fontSpec.iHeight  -= fontSpec.iHeight / 6;   //更改字体大小

 iCoeEnv->ScreenDevice()->GetNearestFontInTwips( font, fontSpec );  //根据设置的字体信息获取合适的字体
 gc.UseFont( font );

//Draw text operation
..................................

gc.DiscardFont();
 iCoeEnv->ScreenDevice()->ReleaseFont( font );  //记住要调用ReleaseFont()释放字体资源.
}

说明:
由于Series60 3rd上与2nd上使用的字体形式可能不同,上面的代码可能在Series60 2nd上没有效果.

原创粉丝点击