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

Reply
Trusted Contributor
taylor-tomt
Posts: 231
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
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: OS 10 simulator dpi

this function returns 358 on my Alpha device -)

Trusted Contributor
taylor-tomt
Posts: 231
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
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: OS 10 simulator dpi

What do you use to draw text?
Trusted Contributor
taylor-tomt
Posts: 231
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
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

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
taylor-tomt
Posts: 231
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
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

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);