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

Adobe AIR Development

Reply
Developer
pyth
Posts: 506
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space
Accepted Solution

Set font size depending on PPI or similar (BB10 Device vs PlayBook)

[ Edited ]

Hey everyone,

 

I wanted to port a PlayBook App to BB10, ran my code in the simulator and everything seemed fine (+it even worked except for a few places where I hardcoded setting the position of images). I was happy as it looked perfectly in the simulator, until I realised that the BB10 devices will be only about a third of the size of the PlayBook, respectively a third of that what we see in the simulator.

 

Therefore, if I create a label with size 16, it may look fine on the PlayBook and the Simulator, but on the actual device it will be like 16/3, which is way to small. How do you or would you handle it? I don't want to rely on reading stageHeight and stageWidth, saying 'oh, that's 1024x600, must be a PlayBook, so I use the normal font' (because we don't know what devices will come in the future)

 

Or is there a way to get the PPI or something similar programmatically? Anything that could be used

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Set font size depending on PPI or similar (BB10 Device vs PlayBook)

[ Edited ]

You can get the DP from:

 

Capabilities.screenDPI;

 

From

import flash.system.Capabilities;

 

I use the PlayBook screen as a basis of the BB10 phones for ratios.  So I have a centralized function to return:

public function get tabletRatio() : Number
{
	return this.dpi / 170.0; // 170 being that of the playbook
}

 Which is about 2x for the BB10 devices.  Seems to work pretty well for fonts and anything else.

 

When BB10 is available for both the phone and the PlayBook, I will mighrate over to CSS style sheets to help with all of this.

Please use plain text.
Developer
pyth
Posts: 506
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Set font size depending on PPI or similar (BB10 Device vs PlayBook)

Thanks jtegen! This is exactly what I was looking for! Though I was a bit perplexed when I tested it in the simulator and I got the same 170 value as for the PlayBook.

After that, I asked a friend with a BB10 Alpha device (that lucky guy was in the states) and he gave me 355 as dpi with the same testing app. Phew! This is something I can work with

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Set font size depending on PPI or similar (BB10 Device vs PlayBook)

One other thing. In the example of tabletRatio, the this.dpi is another get function that returns Capabilities.screenDPI.
Please use plain text.