Forum Discussion

downinit's avatar
downinit
Channel Surfer
3 years ago

Bug? roFontRegistry.Register("bad/path/nofile.ttf") returns true, even if fonts not registered

Is this a bug for anyone else?

 

reg = CreateObject("roFontRegistry")
ok = reg.Register("pkg:/bad-path/or-no-font.ttf")
if ok
    ?"Always true, despite:"
    ?" - not registering fonts (no file or corrupted file)"
    ?" - bad paths"
    ?"Font count: ";reg.GetFamilies().Count()
endif

 

 
Roku OS: 11.5.0 build 4312-C2
 

3 Replies

  • The font object will be create latter, I guess that roFontRegistry just hold file name and do nothing till you ask the registry to create a roFont object.

    Have a look how I do create the fonts in my game engine:

     

     

     

    m.fontRegistry = {}
                for each font in collection.fonts
                    uri = "pkg:/"+font.filename
                    if m.fontRegistry[uri] = invalid then
                        m.fontRegistry[uri] = CreateObject("roFontRegistry")
                        m.fontRegistry[uri].Register(uri)
                    end if
                    rokuFont = m.fontRegistry[uri].GetFont(m.fontRegistry[uri].GetFamilies()[0],font.fontSize, false, false)
                    m.fonts[font.name] = { 
                        font: rokuFont,
                        spacing: font.spacing
                    }
                end for

     

     

     

    • RokuBen's avatar
      RokuBen
      Community Moderator

      Yes, I just checked the code and the error reporting for bad filenames was lost during a refactor.  If you register an invalid file, it will just have no effect on the set of fonts available.  I'll file an internal bug to fix this in a future OS release.