S60 3rd中怎么设置字体类型与字体大小!!!!!(转)

  1. #7
    TurboC 
    TurboC is offline
    Super Contributor TurboC's Avatar
    Join Date
    Jul 2008
    Posts
    1,201
     问题已经解决,具体如下:
      
    //首先查找机器支持的字体个数.
    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
    珍惜每一次机会
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  2. #6
    Super Contributor oracle3's Avatar
    Join Date
    Sep 2007
    Posts
    1,003
     字体大小样式,全套的(注释掉的代码也是有效的)
    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);
    }
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  3. #5
    TurboC 
    TurboC is offline
    Super Contributor TurboC's Avatar
    Join Date
    Jul 2008
    Posts
    1,201
    Quote Originally Posted by  red_shi  View Post
    cxt回的

    可以参考:
    » Symbian OS v9.1 » Symbian OS guide » Graphics » Using Graphics Device Interface » Using Fonts » How to select a font


    Symbian OS v9.1 » Symbian OS guide » Graphics » Using Graphics Device Interface » Using Fonts » How to use typefaces

    选择一个字体并使用。
    兄弟这个我一开始就看了, SDK Help中没有列出来啊,
    TurboC
    珍惜每一次机会
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  4. #4
    Forum Nokia Champion red_shi's Avatar
    Join Date
    Nov 2005
    Posts
    1,904
    Quote Originally Posted by  TurboC  View Post
    看样子是我没有说清楚, 再说明一下:
    关于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”.
    谢谢

    cxt回的

    可以参考:
    » Symbian OS v9.1 » Symbian OS guide » Graphics » Using Graphics Device Interface » Using Fonts » How to select a font


    Symbian OS v9.1 » Symbian OS guide » Graphics » Using Graphics Device Interface » Using Fonts » How to use typefaces

    选择一个字体并使用。
    欢迎访问 www.devdiv.net

    向beover1984学习,向huwell学习,向所有开发Symbian者学习

    red_shi
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  5. #3
    TurboC 
    TurboC is offline
    Super Contributor TurboC's Avatar
    Join Date
    Jul 2008
    Posts
    1,201
     看样子是我没有说清楚, 再说明一下:
    关于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
    珍惜每一次机会
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  6. #2
    Forum Nokia Champion red_shi's Avatar
    Join Date
    Nov 2005
    Posts
    1,904
    Quote Originally Posted by  TurboC  View Post
    请问在S60 3rd中怎么设置字体类型与字体大小:
    例如 字体类型: 宋体/隶书/华文行楷
    字体大小: 10/12/14/16/五号/小五/
    这是我的取字体方式
    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:都是系统字体
    欢迎访问 www.devdiv.net

    向beover1984学习,向huwell学习,向所有开发Symbian者学习

    red_shi
    Quick reply to this messageReply   Reply With QuoteReply With Quote   Multi-Quote This Message     
  7. #1
    TurboC 
    TurboC is offline
    Super Contributor TurboC's Avatar
    Join Date
    Jul 2008
    Posts
    1,201
     请问在S60 3rd中怎么设置字体类型与字体大小:
    例如 字体类型: 宋体/隶书/华文行楷
    字体大小: 10/12/14/16/五号/小五/
    TurboC

转载于:https://www.cnblogs.com/yaoliang11/archive/2010/11/05/1870086.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值