×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Oct 2009
    Posts
    314

    How to change the label text style to italics

    Hi

    I am making an application which has labels text box etc... Now I want to set the label text style as italics. How can I do that.

    I am not creating the label from the resource file. Here is what i did

    Code:
    iLabel1 = new ( ELeave ) CEikLabel;
    iLabel1->SetContainerWindowL( *this );
    _LIT(KLabelText,"Hello World!");
    
    iLabel1->SetTextL(KLabelText);
    iLabel1->ActivateL();
    
    // In the LayoutControl function
    const CFont *poFont = CEikonEnv::Static()->AnnotationFont() ;
       
    iLabel1->SetFont(poFont);
    iLabel1->SetExtent( TPoint( posX,6 ),iLabel1->MinimumSize() );
    Now how do i make it italic.

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to change the label text style to italics

    i suggest you find a italic font and use in place const CFont *poFont = CEikonEnv::Static()->AnnotationFont() ; . note: make sure that font is present on your phone.

  3. #3
    Regular Contributor
    Join Date
    Oct 2009
    Posts
    314

    Re: How to change the label text style to italics

    I am making an app for number of phones . How will i test on each phone. Is there any other alternative.

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to change the label text style to italics

    one dirty was is to you can package your required fonts with your application.

  5. #5
    Regular Contributor
    Join Date
    Oct 2009
    Posts
    314

    Re: How to change the label text style to italics

    I can include in the pkg file but how to change the text style to italic is my problem . If any one can help me with some code. I have did the below mentioned code to bring up the label

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to change the label text style to italics

    for example

    Code:
        TFontSpec fontSpec(<your font name>, fontHeightInTwips);
        fontSpec.iTypeface.SetIsProportional(ETrue);
        fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold );
        iCoeEnv->ScreenDevice()->GetNearestFontInTwips(iTextFont, fontSpec);
    now iTextFont will have your requied font that you can use for label or drawText directly.

  7. #7
    Regular Contributor
    Join Date
    Oct 2009
    Posts
    314

    Re: How to change the label text style to italics

    Hi I have implented the same but it is giving errors

    Code:
    TInt posX = iSize.iWidth - 90;
    iLabel1->OverrideColorL( EColorLabelText, KRgbDarkBlue );
    	
    const CFont *poFont = CEikonEnv::Static()->AnnotationFont() ;
    TFontSpec fontSpec(_L("Italics"), 3);
     fontSpec.iTypeface.SetIsProportional(ETrue);
     fontSpec.iFontStyle.SetPosture(EPostureItalic);
     iCoeEnv->ScreenDevice()->GetNearestFontInTwips(*poFont, fontSpec);
    iLabel1->SetFont(poFont);
    iLabel1->SetExtent( TPoint( posX,6 ),iLabel1->MinimumSize() );
    But I am getting error: 'CWsScreenDevice::GetNearestFontInTwips(CFont *&, const TFontSpec &)' (non-static)
    function call '[CWsScreenDevice].GetNearestFontInTwips({lval} const CFont, {lval} TFontSpec)' does not match

  8. #8
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: How to change the label text style to italics

    Quote Originally Posted by vicky_nits View Post
    Hi I have implented the same but it is giving errors

    Code:
    TInt posX = iSize.iWidth - 90;
    iLabel1->OverrideColorL( EColorLabelText, KRgbDarkBlue );
    	
    const CFont *poFont = CEikonEnv::Static()->AnnotationFont() ;
    TFontSpec fontSpec(_L("Italics"), 3);
     fontSpec.iTypeface.SetIsProportional(ETrue);
     fontSpec.iFontStyle.SetPosture(EPostureItalic);
     iCoeEnv->ScreenDevice()->GetNearestFontInTwips(*poFont, fontSpec);
    iLabel1->SetFont(poFont);
    iLabel1->SetExtent( TPoint( posX,6 ),iLabel1->MinimumSize() );
    But I am getting error: 'CWsScreenDevice::GetNearestFontInTwips(CFont *&, const TFontSpec &)' (non-static)
    function call '[CWsScreenDevice].GetNearestFontInTwips({lval} const CFont, {lval} TFontSpec)' does not match
    that was a constant you can't use like that just use CFont *poFont

  9. #9
    Regular Contributor
    Join Date
    Oct 2009
    Posts
    314

    Re: How to change the label text style to italics

    I have done that also . Same error.

Similar Threads

  1. Change label text from user thread
    By tomass311 in forum Symbian
    Replies: 4
    Last Post: 2009-11-02, 19:18
  2. Replies: 5
    Last Post: 2009-05-08, 09:53
  3. Change font style to Bold
    By nital_shah in forum Symbian
    Replies: 2
    Last Post: 2009-02-06, 07:07
  4. self.img.text - how to set text style
    By novis in forum Symbian
    Replies: 4
    Last Post: 2007-07-12, 15:52
  5. change default style in link
    By m.scrima in forum Browsing and Mark-ups
    Replies: 6
    Last Post: 2003-11-17, 11:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×