Font size always the same no matter what number I put.

I’m drawing text to a roImageCanvas to use as a loading page for a video player. Here is all of the code used to draw on the canvas below:


Sub videoPaintCanvas()
	m.Canvas.AllowUpdates(false)
	list = []
	
	if m.progress < 100 then
		color = "#000000"
		titleFont = m.fonts.GetDefaultFont(75, false, false)
		padding = 5
		rect = {
			w: titleFont.GetOneLineWidth(m.content.Title, m.layout.w) + padding * 2
			h: titleFont.GetOneLineHeight() + padding * 2
			x: 0
			y: 0
		}
		rect.x = Int(m.layout.w / 2) - Int(rect.w / 2)
		rect.y = Int(m.layout.h / 2) - rect.h
		list.Push({
			Text: m.content.Title
			TextAttrs: { Font: titleFont }
			TargetRect: rect
		})
	else if m.paused AND NOT m.seeking then
		color = "#90000000"
		list.Push({
			url: "pkg:/images/pause.png"
			TargetRect: {
				x: Int(m.layout.w / 2) - 64
				y: Int(m.layout.h / 2) - 64
				w: 128
				h: 128
			}
			CompositionMode: "Source_Over"
		})
	else if m.seeking AND m.seekSpeed > 0 then
		color = "#90000000"
		list.Push({
			url: "pkg:/images/fast-forward.png"
			TargetRect: {
				x: Int(m.layout.w / 2) - 64
				y: Int(m.layout.h / 2) - 64
				w: 128
				h: 128
			}
			CompositionMode: "Source_Over"
		})
	else if m.seeking AND m.seekSpeed < 0 then
		color = "#90000000"
		list.Push({
			url: "pkg:/images/rewind.png"
			TargetRect: {
				x: Int(m.layout.w / 2) - 64
				y: Int(m.layout.h / 2) - 64
				w: 128
				h: 128
			}
			CompositionMode: "Source_Over"
		})
	else
		color = "#00000000"
	end if
	
	m.canvas.SetLayer(0, { Color: color, CompositionMode: "Source" })
	m.canvas.SetLayer(1, list)
	if m.progress < 100 then
		m.loadingBar.UpdateProgress(m.progress, 100)
	else if m.progress = 100 then
		m.canvas.ClearLayer(m.loadingBar.layer1)
		m.canvas.ClearLayer(m.loadingBar.layer2)
	end if
	m.canvas.AllowUpdates(true)
End Sub

m.fonts is a roFontRegistry object
m.canvas is the roImageCanvas used
m.progress is used to show a loading bar for buffering. (always between 1 and 100)

The specific part of this function I’m looking at right now is inside the if statement


if m.progress < 100 then
	...
else if ...

No matter what size I specify in the m.fonts.GetDefaultFont(75, false, false), when I run the app, the font is the same size every time. I’m certain it is somehow defaulting to the “Medium” font size.

Any help is greatly appreciated.

For roImageCanvas, you should use roFontRegistry.Get(), not roFontRegistry.GetFont().

–Mark

“RokuMarkn” wrote:
For roImageCanvas, you should use roFontRegistry.Get(), not roFontRegistry.GetFont().

–Mark

Okay, so that means I have to give it a font family parameter. What is the font-family for the system font? It doesn’t show up on the roFontRegistry.GetFamilies() list.

Ah I’ve got it. It’s “Gotham”. Thank you for your help.

^ That’s new! When was that implemented and is it documented?

-JT

If you look at the Design Guidelines on the Roku SDK Documentation (http://sdkdocs.roku.com/display/sdkdoc/Design+Guidelines), and go to Typography section (1.3.5), it says “A set of Roku system fonts (a collection of Gotham fonts) is provided through the SDK.”

That the system font is Gotham has been known, but the fact that you can pass “Gotham” as the font name to roFontRegistry.Get() I don’t believe has ever been documented.

-JT

“renojim” wrote:
That the system font is Gotham has been known, but the fact that you can pass “Gotham” as the font name to roFontRegistry.Get() I don’t believe has ever been documented.

-JT

You actually cannot pass “Gotham” as the font-family. I’ve tried different variations, and finally found that “Gotham Medium” works for the font-family parameter. I suppose different weights of Gotham are available in the system’s fonts, but just “Gotham” does not work.

That’s interesting. Just “Gotham” worked for me, but I think I tried it on a v3.1 firmware device. Now that I look at it, it may be no different than using GetDefaultFont(). I think my excitement comes from my memory of having to package a font with my channel because at that time there was no way to use the internal fonts, or no way to get the font metrics of the internal fonts, or something like that. Things have changed since then.

-JT