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

using external fonts (.ttf)

I have a Roku XD/S.
I'm trying to use external font(s) for my application.
From what i've read, it seems that it should work, but I don't see the resulting font on display - just using the system font.

Do I have the BrightScript syntax wrong ? Or should it even work ?
Here's the code snippet:

    reg = CreateObject("roFontRegistry")
reg.Register("pkg:/fonts/ROCKB.TTF")
reg.Register("pkg:/fonts/tahoma.ttf")
reg.Register("pkg:/fonts/tahomabd.ttf")

rockwellFont = reg.Get("Rockwell", 30, true, false)
tahomaFont = reg.Get("Tahoma", 30, false, false)
tahomaBold = reg.Get("Tahoma", 20, true, false)

fonts = reg.GetFamilies()
print "the fonts are " fonts ---this is actually showing that i'm using the Rockwell/Tahoma font family.

m.ItemSKU = {
Text: "",
TextAttrs: {
Font: tahomaBold,
Color: "#FFFF00 ",
VAlign: "Middle",
HAlign: "Center"
},
TargetRect: {
x: m.ItemSKUBackground.TargetRect.x,
y: m.ItemSKUBackground.TargetRect.y + 5
w: m.ItemSKUBackground.TargetRect.w,
h: m.ItemSKUBackground.TargetRect.h - 5
}
}

Thanks in advance for any suggestions.....

Scott
0 Kudos
12 REPLIES 12
squirreltown
Roku Guru

Re: using external fonts (.ttf)

This seems like an issue, calling two things with the same name.

tahomaFont = reg.Get("Tahoma", 30, false, false)
tahomaBold = reg.Get("Tahoma", 20, true, false)


External fonts do work. Maybe creating new reg object for each different font would help, not sure, never used more than one.
Kinetics Screensavers
0 Kudos
NewManLiving
Visitor

Re: using external fonts (.ttf)

I have come across similar issues with same names. What I did was get a open-source font editor and rename them
For example name one TahomaReg, and the other TahomaBld. Save them as separate files names accordingly.
You can do a lot with those editors. Remove a lot of junk that you don't use
reducing the size sometimes by 80%. Just save them as separate copies and load them as if you were loading two different fonts. May be a
better way or something we both are missing, but the fact that I significantly reduced the size of the files is a bigger plus for me
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
TheEndless
Channel Surfer

Re: using external fonts (.ttf)

On a side note, if you're planning on publishing the channel publicly, you may want to check the licensing for the fonts you're using to ensure you're allowed to distribute them with the channel.
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
wpcs
Visitor

Re: using external fonts (.ttf)

ok. thanks all.
i'll try to rename them using one of the font editors.
i think i read somewhere that the font file needs to be less than 50k ? is that true ?
0 Kudos
NewManLiving
Visitor

Re: using external fonts (.ttf)

Since it consumes memory, it is recommended that you keep it ( I believe ) < 50 or something close to that. But you will find that if you remove a few things from the "font options" and create another font file from the new settings, you can significantly reduce it, depending upon the type of font and what the options are
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
NewManLiving
Visitor

Re: using external fonts (.ttf)

"TheEndless" wrote:
On a side note, if you're planning on publishing the channel publicly, you may want to check the licensing for the fonts you're using to ensure you're allowed to distribute them with the channel.


Hopefully that is already understood. And when I say change options, just deselect options you will not use in a particular channel, without altering the font face
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
wpcs
Visitor

Re: using external fonts (.ttf)

i went back and changed some code:

    reg = CreateObject("roFontRegistry")
reg.Register("pkg:/fonts/BRITANIC.TTF")

BritBold = reg.Get("Britannic Bold", 20, true, false)

...

m.ItemSKU = {
Text: "",
TextAttrs: {
Font: BritBold,
Color: "#FFFF00 ",
VAlign: "Middle",
HAlign: "Center"
},
TargetRect: {
x: m.ItemSKUBackground.TargetRect.x,
y: m.ItemSKUBackground.TargetRect.y + 5
w: m.ItemSKUBackground.TargetRect.w,
h: m.ItemSKUBackground.TargetRect.h - 5
}
}

and verified the font is 40k. its a basic windows font Britannic Bold.
but the font on the Roku device is still the same basic Roku Font.
And i have done a full factory reset, and resent my channel on the local roku.

any suggestions ?
0 Kudos
NewManLiving
Visitor

Re: using external fonts (.ttf)

"NewManLiving" wrote:
BritBold = reg.Get("Britannic Bold", 20, true, false)


Print the returned string. What does it say. Been awhile since I used the string version
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
wpcs
Visitor

Re: using external fonts (.ttf)

This is what was returned:

Britannic Bold,20,-1,5,2,0,0,0,0,0
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.