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: 
RokuJoel
Binge Watcher

Re: Fonts weights and documentation

by weights you mean point sizes of the default fonts?

- Joel
0 Kudos
destruk
Binge Watcher

Re: Fonts weights and documentation

0 Kudos
eockh
Visitor

Re: Fonts weights and documentation

In the following call http://sdkdocs.roku.com/display/RokuSDK ... leanitalic

String Get(String Family, integer size, integer weight, Boolean italic)

If I call it with Get("Default", 36, 50, false) I get a 36 point regular weight font. The 3rd parameter is defined in the font. 50 is regular but what is bold?
0 Kudos
RokuJoel
Binge Watcher

Re: Fonts weights and documentation

I've passed your question on to our Engineering team, I'll post back here if/when I get an answer.

- Joel
0 Kudos
TheEndless
Channel Surfer

Re: Fonts weights and documentation

"eockh" wrote:
In the following call http://sdkdocs.roku.com/display/RokuSDK ... leanitalic

String Get(String Family, integer size, integer weight, Boolean italic)

If I call it with Get("Default", 36, 50, false) I get a 36 point regular weight font. The 3rd parameter is defined in the font. 50 is regular but what is bold?

Unless I'm completely misunderstanding what you're trying to do, it's not entirely clear to me why you chose to ignore my suggestions, and not just try this yourself, as it would have gotten you an answer infinitely quicker than waiting for an official answer from Roku, but... I spent 10 minutes and put this together for you:

Sub Main()
fontRegistry = CreateObject("roFontRegistry")
canvas = CreateObject("roImageCanvas")
canvas.SetMessagePort(CreateObject("roMessagePort"))
canvas.SetLayer(0, { Color: "#000000" })
layerIndex = 1
xStep = 160
yStep = 30
fontSize = 22
weight = 0
weightDelta = 1
For y = 0 To 720 - yStep Step yStep
For x = 0 To 1280 - xStep Step xStep
layer = {
Text: "Weight: " + weight.ToStr()
TextAttrs: {
Font: fontRegistry.Get("Default", fontSize, weight, False)
Color: "#FFFFFF"
HAlign: "Left"
}
TargetRect: {
x: x
y: y
w: xStep
h: yStep
}
}
canvas.SetLayer(layerIndex, layer)

layerIndex = layerIndex + 1
weight = weight + weightDelta
?x,y,layer.TextAttrs.Font
Next
Next
canvas.Show()
Wait(0, canvas.GetMessagePort())
End Sub

This will draw 192 different text strings to the screen, each with an increasing weight value. You can modify how much it increases by changing the "weightDelta" variable.
What you'll find is, specifying a different value for weight in the Get() method doesn't appear to have any effect on the actual weight of the text. You may also notice that the debug output shows that the result of fontRegistry.Get() is the same string every time, regardless of what you pass in for the weight.

Default,22,-1,5,2,0,0,0,0,0

Now, having seen the output of Get(), I decided to play with the numbers a little, and discovered that the fourth number (2) seems to control the weight of the font, so swapping the Get() line in the code above with a programmatically generated string, instead, I got this, which resulted in a font weight increase at the value of 63. If that doesn't give you sufficient information, then I'd suggest playing with the numbers further (particularly the zeros) to see if they have any more effect on the weight.
Sub Main()
fontRegistry = CreateObject("roFontRegistry")
canvas = CreateObject("roImageCanvas")
canvas.SetMessagePort(CreateObject("roMessagePort"))
canvas.SetLayer(0, { Color: "#000000" })
layerIndex = 1
xStep = 160
yStep = 30
fontSize = 22
weight = 0
weightDelta = 1
For y = 0 To 720 - yStep Step yStep
For x = 0 To 1280 - xStep Step xStep
layer = {
Text: "Weight: " + weight.ToStr()
TextAttrs: {
Font: "Default," + fontSize.ToStr() + ",-1,5," + weight.ToStr() + ",0,0,0,0,0"
Color: "#FFFFFF"
HAlign: "Left"
}
TargetRect: {
x: x
y: y
w: xStep
h: yStep
}
}
canvas.SetLayer(layerIndex, layer)

layerIndex = layerIndex + 1
weight = weight + weightDelta
?x,y,layer.TextAttrs.Font
Next
Next
canvas.Show()
Wait(0, canvas.GetMessagePort())
End Sub

So, it doesn't look like any value you pass to Get() is going to yield a bold font, but you can get bold if you build the font string yourself.
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

The Endless,

I wasn't ignoring you. I just didn't see your response and was responding to RokuJoel's after you had posted. I had intended on going back and writing a render loop to try all the parameters, but I've been busy writing all the other custom pieces of the channel I'm working on. Thanks for doing the work it is very useful information.
0 Kudos
RokuJoel
Binge Watcher

Re: Fonts weights and documentation

Response from Engineering is that our current code only supports two weights - 1 (normal) and 2 (bold).

- Joel
0 Kudos
eockh
Visitor

Re: Fonts weights and documentation

Thanks Joel
0 Kudos
RokuJoel
Binge Watcher

Re: Fonts weights and documentation

Further info from Engineering:

- The docs are wrong. There is no integer weight parameter in the Get() function on roFontRegistry. It is a boolean value indicating bold or not.

- There is a firmware bug translating between the bool value given to the Get() for bold and the weight value passed. The result of this is that it's impossible to get a Bold font for the ImageCanvas. All integer values given to Get() for weight are converted to a boolean value for bold. But the true boolean value is converted to an internal weight of 2 which is not bold.

There is a backwards compatibility problem with fixing this in that any app that uses an integer other than 0 is currently getting a normal font, but after the fix they will get a bold font. This could break some apps.

We have opened a bug report for this, the fix is trivial but it is yet to be determined if or when we will fix it.
0 Kudos
destruk
Binge Watcher

Re: Fonts weights and documentation

Thanks for the explanation.
0 Kudos