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

Problem with getOneLineWidth

When I try

font_registery = CreateObject("roFontRegistry") 'GIVES roFont
font_regular = font_registery.getFont("lmroman10 caps", 18, 18, false)
print "line width"
print font_regular.GetOneLineWidth("Alabama",99999)

the line width returned is 0, but when I use getdefaultfont, for example

font_registery = CreateObject("roFontRegistry") 'GIVES roFont
font_regular = font_registery.getdefaultfont()
print "line width"
print font_regular.GetOneLineWidth("Alabama",99999)

it returns 752. I need the width with the lmroman font, so how do I get line width with a non default font? What am I doing wrong?
0 Kudos
9 REPLIES 9
renojim
Community Streaming Expert

Re: Problem with getOneLineWidth

If you want to use anything other than the default font, you have to add the TTF or ODF font to your package and Register it. I'm not sure why GetFont is even returning an roFont object when "lmroman10 caps" isn't a valid family name. Seems like a bug and it should return invalid.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
idunno
Visitor

Re: Problem with getOneLineWidth

I have a .otf file, registered

this = {
port: CreateObject("roMessagePort")
progress: 0 'buffering progress
position: 0 'playback position (in seconds)
paused: false 'is the video currently paused?
fonts: CreateObject("roFontRegistry") 'global font registry
canvas: CreateObject("roImageCanvas") 'user interface
player: CreateObject("roVideoPlayer")
setup: SetupFramedCanvas 'Calls setup framed Canvas
paint: PaintFramedCanvas
eventloop: EventLoop

}
this.fonts.Register("pkg:/fonts/caps.otf")


I apologize that I neglected to include this information in the earlier post. The caps.otf file contains the lmroman10 caps font, I actually got it from one of the example programs.
0 Kudos
renojim
Community Streaming Expert

Re: Problem with getOneLineWidth

Print out this.fonts.GetFamilies(). I don't think "lmroman10 caps" will work. I see the only family in that font as "LMRoman10-Caps". If I use that string, I get the one line width for "Alabama" as 80.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
idunno
Visitor

Re: Problem with getOneLineWidth

This is the code I currently have (not the whole program, just the relevant parts). When I run the program, there is just a space after the word "font" is printed out, almost like the program is not finding any font. I have the caps.otf file from the customvideoplayer example, the file is in the fonts folder, which is in the base folder. I have no idea what's wrong.



Sub RunUserInterface()
' initTheme()
o = Setup()
' o.eventloop()
o.setup()
' o.eventloop()
o.paint()
o.eventloop() 'real

End Sub

Sub Setup() As Object
this = {
port: CreateObject("roMessagePort")
progress: 0 'buffering progress
position: 0 'playback position (in seconds)
paused: false 'is the video currently paused?
fonts: CreateObject("roFontRegistry") 'global font registry
canvas: CreateObject("roImageCanvas") 'user interface
player: CreateObject("roVideoPlayer")
setup: SetupFramedCanvas 'Calls setup framed Canvas
paint: PaintFramedCanvas
eventloop: EventLoop

}
'Register available fonts:
this.fonts.Register("pkg:/fonts/caps.otf")
this.textcolor = "#EEEEEE"'"#406040" title color
Print "font"
print this.fonts.getfamilies()

'Setup image canvas:
this.canvas.SetMessagePort(this.port)
this.canvas.SetLayer(2, { Color: "#000000" }) 'was setlayer 0

this.canvas.Show()
0 Kudos
renojim
Community Streaming Expert

Re: Problem with getOneLineWidth

"idunno" wrote:
When I run the program, there is just a space after the word "font" is printed out, almost like the program is not finding any font.

There's your problem. Print out the result from this.fonts.Register("pkg:/fonts/caps.otf"). It's probably returning false. Check your zip. Maybe caps.otf isn't where you think it is.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
idunno
Visitor

Re: Problem with getOneLineWidth

Good catch, renojim. When you export the files to the Roku Box through eclipse, you have the ability to check and uncheck the files that are uploaded in the zip file. I checked inside the zip file and the fonts folder wasn't there, as I had neglected to select it when I was exporting the zip file. I have checked the box to add the fonts folder to the zip file, and that appears to have solved the problem. Thank you for your help.
0 Kudos
malloys
Visitor

Re: Problem with getOneLineWidth

"idunno" wrote:
Good catch, renojim. When you export the files to the Roku Box through eclipse, you have the ability to check and uncheck the files that are uploaded in the zip file. I checked inside the zip file and the fonts folder wasn't there, as I had neglected to select it when I was exporting the zip file. I have checked the box to add the fonts folder to the zip file, and that appears to have solved the problem. Thank you for your help.


FWIW, I've just modified an eclipse plugin enhancement request entry in the bug queue to check for missing "pkg:" resources as part of the export process (there was already an item for checking for pkg: resources completely missing from the project, but now it includes the export selection list as well).

Cheers
0 Kudos
TheEndless
Channel Surfer

Re: Problem with getOneLineWidth

"malloys" wrote:
FWIW, I've just modified an eclipse plugin enhancement request entry in the bug queue to check for missing "pkg:" resources as part of the export process (there was already an item for checking for pkg: resources completely missing from the project, but now it includes the export selection list as well).

(you know it was coming...) Any word on when the update will be available? I'm still pretty desperate to see some of the other features and fixes you mentioned a few weeks back.
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
malloys
Visitor

Re: Problem with getOneLineWidth

"TheEndless" wrote:
"malloys" wrote:
FWIW, I've just modified an eclipse plugin enhancement request entry in the bug queue to check for missing "pkg:" resources as part of the export process (there was already an item for checking for pkg: resources completely missing from the project, but now it includes the export selection list as well).

(you know it was coming...) Any word on when the update will be available? I'm still pretty desperate to see some of the other features and fixes you mentioned a few weeks back.


It's overdue, I agree. I'll ping my benevolent Roku overlords and see what they say, but it should be soon.

UPDATE: I've been informed that we're targeting a release for the last week of August, but it could come sooner.

Cheers
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.