×

Discussion Board

Results 1 to 15 of 17

Hybrid View

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    280

    How to change font style and font size of s40 app

    I want to change the the font size and font style of my app . I want to provide some options both in style and font so that user can chose it according to his requirement.

    How to do this?

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: How to change font style and font size of s40 app

    I think you need to apply styles to the components where you want to change fonts style and size an basic example can be:

    Code:
    Button myBtn = new Button("Button");
    Style btnStyle = myBtn.getStyle();
    btnStyle.setFgColor("Font Color");
    .. some more
    Hope this helps!!

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: How to change font style and font size of s40 app

    This is how you create a font in LWUIT (change the face, style and size according to your requirements):

    Code:
    Font myFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
    Then you just assign it to the desired component:

    Code:
    getStyle().setFont(myFont );
    However, be careful when changing fonts, since it could cause issues in the Store certification process, as discussed here: Font size issue
    -CarlosDL

  4. #4
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    Thanks cadlg. I applied them

    Also i want some predefined styles on my text such as Pisces,Aries,Taurus,Gemini..
    I tried to apply styles as follows but they are not getting displayed and i m getting blank view in textarea
    Code:
     thoughttext.getUnselectedStyle().setFont(Font.getBitmapFont("Aries"));
    How to apply them on my component?
    Last edited by Manpreet_Singh; 2013-08-22 at 07:16. Reason: code

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    anyone......?

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to change font style and font size of s40 app

    Quote Originally Posted by Manpreet_Singh View Post
    Thanks cadlg. I applied them

    Also i want some predefined styles on my text such as Pisces,Aries,Taurus,Gemini..
    I tried to apply styles as follows but they are not getting displayed and i m getting blank view in textarea
    Code:
     thoughttext.getUnselectedStyle().setFont(Font.getBitmapFont("Aries"));
    How to apply them on my component?
    Check if the font you are trying to apply is available in your resource - using LWUIT resource editor.

    Share code let where you are fetching this font from resource.

    Get more info from - http://docs.oracle.com/javame/dev-to.../resources.htm
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  7. #7
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    Hello sir,
    thanks for reply i tried this code as i thought i can get these fonts only by coding and not using resource editor.

    I tried recourse editor this time. Created theme with name theme1 and then i directly clicked font(by clicking on plus symbol) named it font1 and selected serif and this is all i have done(because i only want to apply that font on textarea) . Then i saved file with some name say manpreet and got file as manpreet.res .
    Do i have to include only this file in my resource folder or i m missing something?
    Last edited by Manpreet_Singh; 2013-08-26 at 08:11.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to change font style and font size of s40 app

    Quote Originally Posted by Manpreet_Singh View Post
    Hello sir,
    thanks for reply i tried this code as i thought i can get these fonts only by coding and not using resource editor.

    I tried recourse editor this time. Created theme with name theme1 and then i directly clicked font(by clicking on plus symbol) named it font1 and selected serif and this is all i have done(because i only want to apply that font on textarea) . Then i saved file with some name say manpreet and got file as manpreet.res .
    Do i have to include only this file in my resource folder or i m missing something?
    You need place this file in resource folder, load this theme file in your app then UIManager.getInstance().setThemeProps(res.getTheme(manpreet));
    Once this is loaded then you try to use this font -- as done in below codelet

    //Open your resource font
    r = Resources.open("/myfont.res");
    //get the Font object. Name should be the same as the one defined in Resource Editor
    Font myfont=r.getFont("NameGivenInResourceEditor");

    Form f = new Form();
    Label mylabel=new Label("Hello");
    //Set the style of this component to your custom style
    mylabel.getStyle().setFont(myfont);


    f.setTitle("Hello World");
    f.setLayout(new BorderLayout());
    f.addComponent("Center", mylabel);
    f.show();
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  9. #9
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    Thanks im2amit. It works

  10. #10
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    Hello sir, i applied font as you suggested from resource editor. While using editor that time, i selected some font and below that selected font size . I uploaded that font in my app.

    Now as i have one popupchoicegroup for text size which has three options 1. small 2. medium 3 large. . I m putting actions on three through following code
    Code:
    Font myFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
    but this code is not able to increase size of font i applied through resource editor . How to do this

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to change font style and font size of s40 app

    Workaround In LWUIT resource editor you can define 3 fonts for the same font in 3 sizes... and use them.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  12. #12
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to change font style and font size of s40 app

    I need three different fonts then with 3 sizes that counts to 9. When i made them , smallest font has 8 kb(20 font size), medim has 9(24 font size) and larget has 11 kb(28 font size).

    When i am working with them i am getting out of memory error
    Last edited by Manpreet_Singh; 2013-08-29 at 07:54.

  13. #13
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to change font style and font size of s40 app

    Quote Originally Posted by Manpreet_Singh View Post
    I need three different fonts then with 3 sizes that counts to 9. When i made them , smallest font has 8 kb(20 font size), medim has 9(24 font size) and larget has 11 kb(28 font size).

    When i am working with them i am getting out of memory error
    If you want to use Fonts from resource editor you have to make fonts of different sizes - you cannot re-size them on the fly....if such thing is needed stick to System fonts.

    Workaround - define different size fonts - but load only one - which user selects? Change your UI.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. How to change font style of app?
    By Manpreet_Singh in forum Mobile Java UI and User Experience
    Replies: 2
    Last Post: 2013-07-15, 16:09
  2. Replies: 1
    Last Post: 2010-12-01, 04:45
  3. Replies: 2
    Last Post: 2009-10-29, 06:33
  4. Change font style to Bold
    By nital_shah in forum Symbian
    Replies: 2
    Last Post: 2009-02-06, 07:07

Posting Permissions

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