lunafromthemoon/RenJS-V2

Font assets do not respect the `assetsPath` setting

Opened this issue · 2 comments

Attempting to use custom fonts when storing assets under a non-default URL causes all fonts to 404.

src/gui/RJSGUIByNewBuilder.ts doesn't leverage gui.assetsPath when building the URLs for fonts, so fonts either have to be stored in a different location from other assets, or cannot be used with custom asset URLs.

The technical fix is easy, but would break backwards compatibility with existing projects using a custom assetsPath and custom fonts. Looking for recommendations on how to proceed.

Hey @goakley, this is definitely a bug! Thanks for finding it. If you want to send a pull request, please do, and I will merge it in the next version.

As for the backwards compatibility, I don't think lots of people will be updating the library automatically, and if they want to I guess the fix for this should be very easy too. I'll write a note on it on the changelog too.

Actually, my apologies, this is not quite broken, but is a bit confusing:

Fonts aren't loaded directly by the engine:

The css font file will list all the fonts you will use in the game

The font file is defined in the RJSGameConfig (e.g. 'fonts': '/assets/gui/fonts.css'). That css file is what contains the paths to the font files, and is why I was having trouble with my game. However, the sample GUI.yaml suggests that each font has a fileName property which describes how to load the font:

  fonts:
    fontsaudimat-mono:
      fileName: fontsfontsaudimat-mono.ttf
      name: fontsaudimat-mono

As far as I can tell, the fileName property is completely unused (and the only point of the fonts property at all is to tell the engine what fonts were separately loaded by the css file). Should fileName be removed from the yaml config entirely, or does/will it have some use?