@font-face practices
Hey, what are some best practices for using
@font-face
? Perhaps some properties that are a must? I currently use it like this, i'd appreciate any pointers, things i've missed or clarification that i've got it down. Thanks in advance.
16 Replies
ah cool thank you, what does it display if it can't download/render the font? The default one? I know it says it does this if you put the value to
auto
but how about the others? i still don't quite understand that.if it can't download the font, uses a fallback
if no fallback is provided, uses the default font by the browser
also
https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range <-- use this
So for both of those if i understand correctly, this is the premis of them?
font-display - specifies what fallback method is used either using the fallback in the declaration (
font-family: xyz, fallback;
) or making the text invisible
unicode-range - what characters the font can affectno, font-display specifies how the font should behave until it's file is downloaded
unicode-range specifies which character ranges the font includes, and the font won't be downloaded until a character in that range is displayed in the page
ohh i see, thank you
also just a secondary question, if i have a font and want let's say a regular and bold version it has to be two separate declarations like the example below right? there's no way i can include both in one declaration?
unless it is a variable font, yes
alright cool got it, i've seen people define two values in the
font-weight
property before e.g. font-weight: 400, 500
, what does that do?alright, thank you, everything there really helped out
you're welcome
by the way, the correct syntax is
font-weight: 400 500
yeah just noticed that myself haha, thanks
it means that the font has font-weights between 400 and 500, so, a variable font
ahh i see
that's good to know because I've been writing separate font-faces for each font-weight 😂 😂
if you use variable fonts, you don't need to do that, and this is understood as a range from 400 to 500 (441 is valid, as well as 499 or 401)