Page 1 of 1

@import in CSS file - can I load external fonts from CSP-approved domains?

Posted: 16 May 2023, 20:12
by salty-horse
I asked this on Discord, but am looking for an official answer.

The top of the default project's CSS file says:
@import url(../../../css/csslayer.css); /* Note: you must not use any @import directive other than this one */
What does this mean in practice? Are other @import rules stripped away when a game is deployed to production?

I would like to use a font from fonts.googleapis.com and would rather import from it directly rather keeping a local copy of the font, or copy-pasting the code in the generated page (as it feels like the URLs there are not guaranteed to always be available.)

Re: @import in CSS file - can I load external fonts from CSP-approved domains?

Posted: 20 May 2023, 15:10
by quietmint
Basically it means nothing. @import from Google Fonts will work. I've used it in my games for years without issue. See https://github.com/quietmint/bga-coupci ... ystate.css

But better is to use a <link> tag instead. It will allow the fonts to load quicker (removes dependency on downloading your CSS first). I did this in the .tpl file: https://github.com/quietmint/bga-hardba ... rdback.tpl

Re: @import in CSS file - can I load external fonts from CSP-approved domains?

Posted: 21 May 2023, 21:03
by salty-horse
Thanks!