User defined font in layout doesn't work!

I have a custom font and defined in resources as fonts/font with an id id_font_watch and filename fonts/watch.fnt

The watch.fnt and .png is in the fonts folder.

Then in the layout resource I have defined the font attribute to id_font_watch

The docs say the font id can be...

Gfx Font constant or the ID of a user defined font.

But I get an error

BUILD: ERROR: Attribute "font" in ID "TimeLabel" has an invalid value "id_font_watch".

Does the layout support user defined fonts?

HELP!
  • You need to use the font name from the Rez module. When you load a custom font in code, you use Ui.loadResource(Rez.Fonts.{font id}). When using a layout, you set the font attribute as font="Rez.Fonts.{font id}" where {font id} is the id of the font as described by your font resource.
  • You need to use the font name from the Rez module. When you load a custom font in code, you use Ui.loadResource(Rez.Fonts.{font id}). When using a layout, you set the font attribute as font="Rez.Fonts.{font id}" where {font id} is the id of the font as described by your font resource.


    Thats exactly what I did! In both cases it doesn't work. If I use the SAME font as the C64Face and config it does;'t show the font. If I use gfx.font_large for example it does.
  • You are definitely doing something wrong. According to the error message, they our layout has an entry like this...

    <label id="TimeLabel" font="id_font_watch" ... />


    As mentioned above, you need this...

    <label id="TimeLabel" font="Rez.Fonts.id_font_watch" ... />


    If the font resource is in resources/fonts/fonts.xml, and the fnt file is resources/fonts/watch.fnt, the file name attribute is just watch.fnt. The path to the fnt file is relative to the resource file that describes it.

    I know this works because I use it often. If you're still stuck, try putting a layout in the C64Face sample.
  • You are definitely doing something wrong. According to the error message, they our layout has an entry like this...

    <label id="TimeLabel" font="id_font_watch" ... />


    As mentioned above, you need this...

    <label id="TimeLabel" font="Rez.Fonts.id_font_watch" ... />


    If the font resource is in resources/fonts/fonts.xml, and the fnt file is resources/fonts/watch.fnt, the file name attribute is just watch.fnt. The path to the fnt file is relative to the resource file that describes it.

    I know this works because I use it often. If you're still stuck, try putting a layout in the C64Face sample.


    Ah! OK thank you very much and sorry for all my basic question but hopefully they will help others. It's a GREAT product and WAY better than the Apple Watch!