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
Trusted Contributor
lakshmanan
Posts: 144
Registered: ‎05-04-2011
My Carrier: app development

Font issues in the single Build for all devices

Hi Friends,


              I implemented a single application which is working across all Blackberry OS7 and OS6 devices.I faced a font issue while testing in simulator.

 

            Eg: If i test the same application in the various simulators of 9930 i faced alignment issues(Font alignment). I get the fonts in points not in pixels.

 

            I can get vertical resolution and horizontal resolution for these simulators and it varied for different simulators of the same model.

 

This is my code

 

            InputStream is = this.getClass().getResourceAsStream(
                    fontName + ".ttf");
            int codeNum = FontManager.getInstance().load(is, font,
                    FontManager.APPLICATION_FONT);
            FontFamily fontFam = FontFamily.forName(font);
            System.out.println("Created fontFamily");
            langFont = fontFam.getFont(FontFamily.SCALABLE_FONT, size,
                    Ui.UNITS_pt);

 

Can anyone help me to design labels and texts based on font by using resolutions of device.

 

Regards,

Lakshmanan

Please use plain text.
Developer
peter_strange
Posts: 19,521
Registered: ‎07-14-2008

Re: Font issues in the single Build for all devices

My experience is that using points gives a consistent look and physical size across all BlackBerry devices, with both BB supplied and application supplied fonts. 

 

You say "I can get vertical resolution and horizontal resolution for these simulators and it varied for different simulators of the same model". I was not aware that the screen resolution or the screen size of the 9930 changed.  You can get the actual screen resolution and the size of screen using various methods of the Display class - can you confirm that these are indeed different in your situation and document the differences? 

Screen size : Display.getWidth() and getHeight()

Resolution: Display.getHorizontalResolution() and getVerticalResolution()

 

if you see differences than I suspect that you are seeing differences in the default RIM implementation of Fields.  RIM have changed the look and feel of Fields are various OS levels, most notably with the introduction of touch devices, so this is a possibility.  But I would like to see it as I not noted any changes since OS 6.  So can you show us an example of the problem?  Document the OS levels associated with the examples so that we can replicate the situation too. 

 

Please use plain text.
Trusted Contributor
lakshmanan
Posts: 144
Registered: ‎05-04-2011
My Carrier: app development

Font issues in the single Build for all devices

Hi peter,

 

       Thanks for your reply,

 

       I wrongly mentioned the details in previous post.

 

       Actually i tested my application with two different simulators having different OS versions of same model(9930).
One device version is 7.1 and another one has 7.0.Thier screen sizes are same and thier resolutions are different.

 

11299(vertical resolution)--9930 china telecom(OS 7.1)

 

9661(vertical resolution)--9930 Generic(OS 7.0)

 

This is my code

 

InputStream is = this.getClass().getResourceAsStream(
                    fontName + ".ttf");
            int codeNum = FontManager.getInstance().load(is, font,
                    FontManager.APPLICATION_FONT);
            FontFamily fontFam = FontFamily.forName(font);
            System.out.println("Created fontFamily");
            gujFont = fontFam.getFont(FontFamily.SCALABLE_FONT, size,
                    Ui.UNITS_pt);

          System.out.println("gujFont Height::"+gujFont.getHeight());

 

          Actually i am doing one application where i have to display gujarati(indian language) text.

My size variable is 8 and My gujFont.getHeight() for one device is 32 and another device(lower resolution) is 27. So the text displays bigger on higher resolution device.

 

           Can u please guide me to set a common font height for all devices or guide me to design the font based on resolution.

 

Regards,

Lakshmanan

       

Please use plain text.
Developer
peter_strange
Posts: 19,521
Registered: ‎07-14-2008

Re: Font issues in the single Build for all devices

[ Edited ]

I can see this difference in other Simulators too. 

 

I've installed the latest available generic OS 7.0 (7.0.0.574) and OS 7.1 (7.1.0.355) 9930 Simulators and tested on these. 

 

I don't have a 9930 to test on so I am not sure if this is a problem in the Simulators or the real devices.

 

Basically your code should produce the same size text given that you use the same point size - the fact that it is different means that in either OS 7.0 or OS 7.1, they used the wrong screen resolution.  This will effect all apps on the device too.  You can see this on the screen shots I have attached - the screen is the same physical size with the same physical dpi, so the 8 point font should be the same. 

 

If anyone has a 9900 or 9930 to test with, I would be interested to know which of these two screen shots it matches and which OS level you have on device. 

 

Amyway what should you do?  At this time I would wait and see what other comments we have, but in essence I think you are going to have to choose one of these screen resolutions (which ever matches other devices with similar screen sizes would seem sensible), and force that size for the errant 9930.  So you will have to calculate the equivalent pixel size of the font yourself.  However if you do this, then your app will be out of step with other apps on the phone. 

 

And let us hope we can some comment from people with the real device so we find out if this is a device or just a Simulator problem. 

 

Edit: Corrected images attached

Please use plain text.
Administrator
MSohm
Posts: 14,073
Registered: ‎07-09-2008
My Carrier: Bell

Re: Font issues in the single Build for all devices

This looks like an issue with the BlackBerry smartphone simulator that was corrected.  On a real device I see the same behaviour in both 7.0 and 7.1, which matches what's seen in the 7.1 simulator.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
lakshmanan
Posts: 144
Registered: ‎05-04-2011
My Carrier: app development

Re: Font issues in the single Build for all devices

Hi Peter and Mark,

 

          Thanks for your reply.

 

          I tested my application first in 7.0 simulator and send the build to my client. Our client has 7.1(9930 china telecom) device.He tested on that and send us the report that there are some alignment issues mainly on texts and labels. Then only i realised it is the font size issue.

 

        But i have designed my application for all devices(OS 6 and OS 7). So i tested it in my 9800(os 6) device and find font issue. Fontsize is very small compared to our clients screen shots based on OS 7.1 device.

 

        Is there any possiblity to set a common font height for a single application which is working on all devices(Having different screen sizes and screen resolutions) .

 

Regards,

Lakshmanan

Please use plain text.
Developer
peter_strange
Posts: 19,521
Registered: ‎07-14-2008

Re: Font issues in the single Build for all devices

I am concerned that there is some confusion here.

 

If you specify a font size in points, then it should, in theory, be exactly the same height on all devices.  And by this I mean that the physical height when measured on the screen will be the same on all devices.  That is what points is supposed to do. 

 

You have found an issue on the Simulators where the screen resolution (the dpi, not the width/height) reported by the OS 7.0 Simulator was incorrect, so that 8 points on that Simulator did not match 8 points on another Simulator.  What Mark has suggested is that this is a bug in the Simulator only, so if you use 8 points then on device it will be the same. 

 

But that is not the whole story.  That is just the physical height of the font on screen.  You also need to factor in the actual number of pixels on the screen.  So if you try your application on a Curve 9300, your text will fill a different proportion of the screen to that on a torch 9800.  And to confuse the  matter further, the actual screen on the 9300 is physically wider than the one on the 9800, so will see more text displayed using the same point font on a 9300 that you will on a 9800.  Despite the fact that it actually has a lower resolution screen with fewer pixels in its width.

 

So doing a build for all devices and expecting the text fields to be laid out the same way on these devices is not possible.  Just try the 9800 in landscape and portrait modes.  How do you expect the text to be laid out the same way?

 

But you can get the text to look similar and scale appropriately for each device, by using points.  This is what I think you want to do and so it was what I suggested right at the start.  But as noted, getting the text laid out in the same way with the same line breaks is not reasonable given the differing screen form factors.

 

With this information can you review your problem and perhaps explain it in another way.  I think screen shots provide an good way to explain this rather than using subjective words like "smaller". 

Please use plain text.