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: 
eockh
Visitor

Fonts weights and documentation

I'm using an image canvas to display a bunch of text and I need to change the font per line. Does anyone know the valid weights for the "Default" font to be used with the GetDefaultFont(integer size, Boolean bold, Boolean italic) call. Also, why does the BrightScriptReferenceManual.pdf in the SDK have the Object GetFont(String Family, integer size, Boolean bold, Boolean italic) call documented, but the docs online don't specify it.

Is there a way to turn an roFont into a string to use with TextAttr on an imageCanvas?

Which docs are valid/most recent? There also seem to be missing documentation on many of the interfaces on the online SDK reference.
0 Kudos
20 REPLIES 20
TheEndless
Channel Surfer

Re: Fonts weights and documentation

The wiki is the most up to date, but the PDFs still include some documentation that's not available in the wiki (as you've discovered). There are two different versions of the roFontRegistry. In the PDFs, the roImageCanvas version is in the component reference, while the roScreen version is in the BrightScript reference. In the wiki, currently only the roImageCanvas version is documented. RokuMarkn mentioned that he was going to update it in this thread (viewtopic.php?f=34&t=51521&p=350111#p350111), but it doesn't look like that's happened, yet.

For the roImageCanvas, the only valid default fonts are "Small", "Medium", "Large", and "Huge", and they don't correspond in any way, as far as I can tell, with the GetDefaultFont() that's used with the roScreen. If you want custom sizes and weights on the image canvas, you'll need to use our own TTF or OTF font.
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
eockh
Visitor

Re: Fonts weights and documentation

You can use the default fontRegistry font. For example if I call

normalFont = fontRegistry.Get("Default", 25, 50, false)

I and set normatlFont to the font key in the TextAttr I get a 25 pt normal font and if I bump the font from 25 to 36 it gets bigger. I just don't know what the magic font weight numbers are other than the 50 for normal. I know there is a bold weight it's just what is the magic number?
0 Kudos
destruk
Streaming Star

Re: Fonts weights and documentation

Drawing text in the same place with the same size on the same buffer also increases the 'weight' that is displayed on the screen.
0 Kudos
MSGreg
Visitor

Re: Fonts weights and documentation

"destruk" wrote:
Drawing text in the same place with the same size on the same buffer also increases the 'weight' that is displayed on the screen.

Really? Does this effect happen with fully opaque text? I have overwritten multiple transparent images and the result on screen is less transparency which could be mistaken (or referred to) as "weight". Real font weight I think incorporates more pixels. One way to (kind of) do that is to draw multiple times offset by one in one or more directions. In fact, combining the offset with transparency overwrite, might be a better way overall to get a weight kind of effect.

I've used drawtext with black (or gray) offset by 1,1 then drawtext white (or other color) to create a shadow effect. Works very well for visibility on top of an image without requiring a background shaded box.
0 Kudos
eockh
Visitor

Re: Fonts weights and documentation

I appreciate the ideas, but I can't imagine that drawing the same text multiple times is very efficient. Any of the Roku devs want to enlighten me as to what weights are in the default font?
0 Kudos
TheEndless
Channel Surfer

Re: Fonts weights and documentation

"eockh" wrote:
I appreciate the ideas, but I can't imagine that drawing the same text multiple times is very efficient. Any of the Roku devs want to enlighten me as to what weights are in the default font?

The font weight effect destruk is talking about is strictly a result of the anti-aliased edge transparency getting doubled up. Not a particularly effective way to make a font bold, as it has an obviously detrimental effect on the smoothness of the text.

As for the default font weights, if you want to figure it out objectively, you could just write a loop that draws multiple weights to the screen to see what, if any, difference there is. As I mentioned before, however, for the roImageCanvas, the only documented default fonts are "Small", "Medium", "Large", and "Huge". There are no weights available for those. For the roScreen, boldness is boolean, so there are only two weights available. If GetFont("Default"...) works on the roImageCanvas, then the loop will probably get you an answer faster than waiting for Roku to respond will.
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
RokuJoel
Binge Watcher

Re: Fonts weights and documentation

"eockh" wrote:
I can't imagine that drawing the same text multiple times is very efficient.


Slightly off topic, but in the roScreen world, you will typically be redrawing every element on the screen as often as possible, in pseudocode your app will look like something like this (note the second line is the no-delay method of reading the messageport):

while true
msg=port.getmessage()
calculate Graphics Positions On Screen
draw bitmaps
draw text
for each sprite, adjust position based on calculate logic
compositor DrawAll
swapbuffers
end while


If you find that redrawing text is slowing your app down, you can draw text once to a bitmap of the correct size to to fit the text and then draw that bitmap in your loop instead.

- Joel
0 Kudos
destruk
Streaming Star

Re: Fonts weights and documentation

That's a good idea Joel - using the bitmap.
0 Kudos
eockh
Visitor

Re: Fonts weights and documentation

Joel,

Yeah, in my table view implementation this is what I do and only draw the new text, each cell is a sprite that just gets moved. However I have another view where I am using an image canvas and I can use the default font and modify the size, but I don't know what the valid weights are. Is there any Roku developer that knows them?
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.