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

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Trusted Contributor
Posts: 232
Registered: ‎11-19-2010
My Device: Z10, Playbook
Accepted Solution

OS 10 simulator dpi

Since the simulator returns 0 if you ask for the screen dpi using :

 

dpi = bbutil_calculate_dpi(screen_cxt);

 

what dpi should be specified for testing?

 

I have tried setting it to 170, but my text seems very small when I compare to the same code running on the PB OS 2.1

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: OS 10 simulator dpi

If you're asking for the DPI of the first BB10 phone, you'll find it here: https://developer.blackberry.com/devzone/design/devices_and_screen_sizes.html

(If that's not what you wanted, then I didn't understand the question.)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: OS 10 simulator dpi

this function returns 358 on my Alpha device -)

Highlighted
Trusted Contributor
Posts: 232
Registered: ‎11-19-2010
My Device: Z10, Playbook

Re: OS 10 simulator dpi

Thanks. That is what I'm after.

 

However, I found a problem with the dpi value in my code and fixed it.

 

If I use dpi=170 with the simulator, the text looks reasonable.

 

If I use dpi=356, the text appears too small.

 

Not having a device in hand, I can't check it.

 

Would it be safe to assume that the simulator is based on 170dpi, while the device will actually be 356 (or 358 as posted by another developer), and that if I just used the value returned by bbutil_calculate_dpi(screen_cxt); , the text will appear OK on the device?

 

Thanks

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: OS 10 simulator dpi

What do you use to draw text?
Trusted Contributor
Posts: 232
Registered: ‎11-19-2010
My Device: Z10, Playbook

Re: OS 10 simulator dpi

Using opengl ES 1.1, so I use bbutil_render_text

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: OS 10 simulator dpi

Don't use fixed font size. Make it dependable on dpi. Yes font size 10 on playbook looks ok but the same size 10 on BB10 device looks too small. Somewhere in examples there is very nice code sample that utilizes this approach. If you don't find it by the time I reach home then I'll post it here for you -)
Trusted Contributor
Posts: 232
Registered: ‎11-19-2010
My Device: Z10, Playbook

Re: OS 10 simulator dpi

Loading the font with

 

bbutil_load_font( "/usr/fonts/font_repository/monotype/arialbd.ttf", 48, dpi);

 

is dependent on the dpi.

 

I.e. I believe that bbutil_load_font is scaling the requested size (48 here) based on the dpi of the screen so that, for example, if a font size was used that was 1/2 the screen height, it would always appear 1/2 screen height on a 170dpi screen or a 356dpi screen.

 

bbutil_render_text does not include a font size parameter, since this is determined by bbutil_load_font

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: OS 10 simulator dpi

This is what I mean:

    int point_size10 = (int)(10.0f / ((float)dpi / 170.0f ));

    fontMono10 = bbutil_load_font("/usr/fonts/font_repository/monotype/courbi.ttf", point_size10, dpi);