Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Komag
Roku Guru

It seems font height has changed!

	font = font_registry.GetDefaultFont()
fontH = font.GetOneLineHeight() ' fontH is 47

After a new round of compatibility testing today, I discovered that on my classic Roku HD N1100 (software 3.1), the GetDefaultFont font height is actually 49, but on my Roku 2 XS (software 6.1) the font height is 47, which is what I've been banking on for a few weeks of development.

Am I missing something, or is this a change that is documented somewhere?
0 Kudos
4 REPLIES 4
TheEndless
Channel Surfer

Re: It seems font height has changed!

Why not specify the font size, so you don't have to worry about it?
font = font_registry.GetDefaultFont(47, false, false)
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Komag
Roku Guru

Re: It seems font height has changed!

Oh my gosh, why didn't I know that?! Now I see it in the docs, I guess I just never really learned that part, thanks. 🙂
0 Kudos
Komag
Roku Guru

Re: It seems font height has changed!

So it seems that GetOneLineHeight() automatically adds a certain percent of the font height as a spacer, around 18%-25%. For example:
Font height, One Line Height:
20 . . . . . 25 (25%)
21 . . . . . 26 (24%)
25 . . . . . 30 (20%)
32 . . . . . 39 (22%)
38 . . . . . 45 (18%)
40 . . . . . 47 (18%)
47 . . . . . 56 (19%)

The added space seems to increment by 2s, not sure why or if that's really accurate though.
So in my code, if I want to ensure 47 line height, I need to set the font at 40
font = font_registry.GetDefaultFont(40, false, false)
fontH = font.GetOneLineHeight()
? fontH
Will print "47"
0 Kudos
TheEndless
Channel Surfer

Re: It seems font height has changed!

Presumably the difference is character height (including ascenders and descenders) vs. line height. The latter being the character height plus the surrounding padding, so you can accurately measure and layout multiple lines without having the text for each line touching the surrounding lines.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos