如何设置正确的字体大小?

egxsguo 2008-02-25 04:10:16
同样的TFontSpec分别在N95、N73、E50上字体大小不一样
于是用下列代码进行测试:
TInt typefaceCount = dev->NumTypefaces();

TBuf<5000> sTypeface;
sTypeface.AppendFormat(_L("TypeFace Count: %d\n"), typefaceCount);

for (TInt i = 0; i < typefaceCount; i++)
{
TTypefaceSupport typefaceSupport;
dev->TypefaceSupport(typefaceSupport, i);
sTypeface.Append(typefaceSupport.iTypeface.iName);
sTypeface.Append(_L("\n"));
sTypeface.AppendFormat(_L("Height Count(%d)=%d\n"), i, typefaceSupport.iNumHeights);
for (TInt j = 0; j < typefaceSupport.iNumHeights; j++)
{
TFontSpec fontSpec;
fontSpec.iTypeface = typefaceSupport.iTypeface;
fontSpec.iHeight = dev->FontHeightInTwips(i, j);
fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
CFont* pFont = NULL;
CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(pFont, fontSpec);
sTypeface.AppendFormat(_L("Height(%d)=%d Width=%d\n"), j, dev->FontHeightInTwips(i, j), pFont->TextWidthInPixels(szBuf));
CEikonEnv::Static()->ReleaseScreenFont(pFont);
}
}

发现各个手机同样的typeface都有同样的FontHeightInTwips列表,但是字体宽度都是不一样的
例如N95上TypeFace.iName为Sans MT 936_S60的字体
Height(0)=80 Width=73
Height(1)=100 Width=99
Height(2)=120 Width=117
.....
在E50上的数据则为
Height(0)=80 Width=108
Height(1)=100 Width=135
Height(2)=120 Width=153
.....

据以上数据,也就是说通过如下方法创建的字体在各个手机上都是不一样大的
TFontSpec fontSpec = CEikonEnv::Static()->NormalFont()->FontSpecInTwips();
fontSpec.iHeight = 120;
fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(pFont, fontSpec);

请教各位达人,有没有什么方法可以在各个手机上创建出同样大小的字体
...全文
654 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
guangzou 2011-08-04
  • 打赏
  • 举报
回复
怎么设置啊 求赐教!!!
egxsguo 2008-02-25
  • 打赏
  • 举报
回复
问题已解决

3,119

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧