Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 798
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

font issues blackberry

on 7.0 Font.getDefault().getHeight() it giveds me 27

on 7.1 Font.getDefault().getHeight() it gives me 32

 

I want to have the font set based on the width + height of the screen.If scnreen is 640..i want it 27.

if screen is 320, i want it 12..

 

how can I do this? on what logic?

 

right now I am doign this

 

final int fSize = Display.getWidth()/25;
        Font font1 = getFont().derive(Font.BOLD, fSize);

 

basically 640/25 = 25 font size lol

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: font issues blackberry

Can I recommend that you use points and not pixels when determining Font size.  points are a fixed physical size, so will appear the same physical size on the screen regardless of the resolution of the screen.  This means you do not have to do any calculations.  And remember that screen size and screen resolution are two completely different things.  Your font size will depend on the resolution of the device, devices with higher density of pixels (more dpi) will require more pixels.

 

Anyway, to define fonts using points, define the font using Ui.UNITS_pt.  1 point == 1/72 inch, most users will have their default font set to 8 or 9 points. 

Developer
Posts: 798
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: font issues blackberry

okey will follow ur advice, and use points. i hope it solves it on both different resolutions and different screen sizes. its pretty hard work, doing an application to handle all types of devices.

I am thankful for this forum, its helping me alot...cause i am new to mobile development, and have whole application responsible for
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: font issues blackberry

Have a look at the tutorials you will find here:

http://supportforums.blackberry.com/t5/Java-Development/Tutorials-for-new-developers-Part-1/m-p/1621...

especially the last one that talks about handling the various screen sizes and resolutions.