Forum Discussion

Komag's avatar
Komag
Roku Guru
11 years ago

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?

4 Replies

  • Why not specify the font size, so you don't have to worry about it?
    font = font_registry.GetDefaultFont(47, false, false)
  • 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. 🙂
  • 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"
  • 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.