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

Game development with Board Game Arena Studio
Post Reply
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

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

Post 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.)
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

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

Post 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
Post Reply

Return to “Developers”