Your Digital Media Has Never Looked So Good

 
User avatar
OG_OTT
Topic Author
Posts: 13
Joined: Mon Jul 30, 2018 3:52 pm

roFontRegistry

Fri Aug 03, 2018 7:05 am

Does `roFontRegistry` work with RSG?  Do I have a typo or is there a better way than below?  


     font_registry = CreateObject("roFontRegistry")
     font = font_registry.GetDefaultFont()
     fontRegistry = CreateObject("roFontRegistry")
     townFont = fontRegistry.GetDefaultFont()
     townFont.size = 80
     lineHeight = townFont.GetOneLineHeight()

///

Current Function:
005:  sub InitWidget()
006:      font_registry = CreateObject("roFontRegistry")
007:*     font = font_registry.GetDefaultFont()
008:      fontRegistry = CreateObject("roFontRegistry") 
009:      townFont = fontRegistry.GetDefaultFont()
010:      townFont.size = 80
011:      _lineHeight = townFont.GetOneLineHeight()
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in pkg:/components/widgets/LocationWidget.brs(7)
007:     font = font_registry.GetDefaultFont()

Last edited by OG_OTT on Sat Aug 04, 2018 1:19 pm, edited 1 time in total.
 
User avatar
RokuKC
Posts: 299
Joined: Wed Sep 10, 2014 10:44 am
Location: Roku HQ

Re: roFontRegistry

Fri Aug 03, 2018 5:15 pm

OG_OTT wrote:
Does `roFontRegistry` work with RSG?  Do I have a typo or is there a better way than below?  


It seems that you can only use roFontRegistry from the Main function or in a RSG Task node.

I don't know for myself whether you can get metrics from that that will work perfectly for RSG.

RSG has:
https://sdkdocs.roku.com/display/sdkdoc/Font

I'm not making any recommendation, but I have the impression that some people have used Label nodes along with https://sdkdocs.roku.com/display/sdkdoc ... undingRect to figure out other layout metrics.
 
User avatar
OG_OTT
Topic Author
Posts: 13
Joined: Mon Jul 30, 2018 3:52 pm

Re: roFontRegistry

Sat Aug 04, 2018 1:18 pm

Thank you.  The `BoundingRect()` idea did work for my purposes!

To future reviews of this thread, the below snippet shows setting of my primary label and I get `BoundingRect` so I can get the height to place an element just beneath it - this worked for me:  

sub init()
     InitWidget()
end sub
     
sub InitWidget()
     townLabel = m.top.findNode("TownName")
     townLabel.font.size = 80
     townLabelRect = townLabel.BoundingRect()
     
     stateLabel = m.top.findNode("StateName")
     stateLabel.font.size = 40
     stateLabel.translation = [0, townLabelRect.height+5]
end sub

Who is online

Users browsing this forum: No registered users and 6 guests