S60 3rd中怎么设置字体类型与字体大小!!!!!(转)
- Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 10:38#7
问题已经解决,具体如下:
//首先查找机器支持的字体个数.
TInt iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
//然后就可以查找所有的字体
for(TInt i = 0; i < iNumTypefaces; i++)
{
TTypefaceSupport myTypefaceSupport;
iCoeEnv->ScreenDevice()->TypefaceSupport(myTypefaceSupport,i);
TBuf<KMaxTypefaceNameLength> aTemp;
aTemp.Copy(myTypefaceSupport.iTypeface.iName.Des());
}//这样就可以得到所有的aTypefaceName.
//设置指定的字体
TFontSpec fontSpec;
fontSpec.iTypeface.iName= aTemp;
fontSpec.iHeight = 40;
(这个地方也可以使用相对于别的字体的高度如下:
const CFont* font = CEikonEnv::Static()->SymbolFont();
fontSpec.iHeight = font->FontSpecInTwips().iHeight + 10;
)
//生成新的字体
CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(newFont, fontSpec);
//最后使用字体
CWindowGc::UseFont(newFont);TurboC
珍惜每一次机会 - Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 10:06#6
字体大小样式,全套的(注释掉的代码也是有效的)
const CFont* font = iEikonEnv->SymbolFont();
iOffScreenBitmapGc->UseFont( font );
iOffScreenBitmapGc->DrawText(_L("hello world"),TPoint(0,20) );
iOffScreenBitmapGc->DiscardFont();
CFont* fontNew = NULL;
TFontSpec fontSpec;
fontSpec.iTypeface.iName=font->FontSpecInTwips().iTypeface.iName;// KFontName;
//if (text->Bold())
//{
// // Set Bold
// fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
//}
//if (text->Italic())
//{
// // Set Italic
// fontSpec.iFontStyle.SetPosture(EPostureItalic);
//}
//fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
//fontSpec.iHeight=text->Height();
//// Set Underline
//if (text->Underline())
//{
// iGc->SetUnderlineStyle(EUnderlineOn);
//}
fontSpec.iHeight = font->FontSpecInTwips().iHeight + 40;
iOffScreenBitmapDevice->GetNearestFontInTwips(fontNew,fontSpec);
if (fontNew != NULL)
{
iOffScreenBitmapGc->UseFont( fontNew );
iOffScreenBitmapGc->DrawText(_L("hello world"),TPoint(0,100) );
iOffScreenBitmapGc->DiscardFont();
iOffScreenBitmapDevice->ReleaseFont(fontNew);
} - Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 05:40#5
Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 04:41#4
- Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 04:17#3
看样子是我没有说清楚, 再说明一下:
关于SDK中TFontSpec(const TDesC &aTypefaceName, TInt aHeight)的两个参数,是这样说的:
aTypefaceName :The name of the typeface (e.g. "Roman").
aHeight :The height of the typeface, in twips.
这里有几个问题:
1、怎么找到aTypefaceName的列表呢?好尝试各字体的显示效果,然后加以选择。SDK中没有找到,或者我找法有问题。。。
2、关于twips这个单位,一直没有概念,大家能够帮忙解释一下
3、在1没有结果的情况下,希望大家能够提供一些已知的活常用的字体的名字,如上面提到的“Roman”.
谢谢TurboC
珍惜每一次机会 Re: S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 04:03#2
这是我的取字体方式
if( fontType == FUI_FONT_TYPE_LARGE )
font = CEikonEnv::Static()->TitleFont();
else if( fontType == FUI_FONT_TYPE_SMALL )
font = CEikonEnv::Static()->DenseFont();
else
font = CEikonEnv::Static()->NormalFont();*
TInt m_nFontStyle = EFontStyle_Title;
switch (m_nFontStyle)
{
case EFontStyle_Normal:
{
#ifdef __SERIES60_3X__
// TFontSpec oFontSpec(_L("Sans MT 936_S60"), 100);
TFontSpec oFontSpec;
oFontSpec = LatinBold13()->FontSpecInTwips();
#else
TFontSpec oFontSpec(_L("CombinedChinesePlain12"), 300);
#endif
CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(font, oFontSpec);
}
break;
case EFontStyle_Title:
{
#ifdef __SERIES60_3X__
// TFontSpec oFontSpec(_L("Sans MT 936_S60"), 130);
TFontSpec oFontSpec;
oFontSpec = LatinBold16()->FontSpecInTwips();
#else
TFontSpec oFontSpec(_L("CombinedChinesePlain12"), 300);
#endif
CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips(font, oFontSpec);
}
break;
default:
break;
}
我这样设置
aGC.UseFont( font );
PS:都是系统字体- S60 3rd中怎么设置字体类型与字体大小!!!!! - 2008-09-05 03:53#1
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步