font-face fallback order
See original GitHub issueExample:
'@font-face': {
fontFamily: '"icon-fonts"',
src: `url(/assets/fonts/icon-fonts.eot)`,
fallbacks: [
{ src: `url(/assets/fonts/icon-fonts.eot?#iefix) format(embedded-opentype)` },
{ src: `url(/assets/fonts/icon-fonts.ttf) format(truetype)` },
{ src: `url(/assets/fonts/icon-fonts.svg#icon-fonts) format(svg)` },
{ src: `url(/assets/fonts/icon-fonts.woff) format(woff)` },
{ src: `url(/assets/fonts/icon-fonts.woff2) format(woff2)` },
],
fontWeight: 'normal',
fontStyle: 'normal',
}
Expected:
@font-face {
font-family: "icon-fonts";
src: url(/assets/fonts/icon-fonts.eot);
src: url(/assets/fonts/icon-fonts.eot?#iefix) format(embedded-opentype),
url(/assets/fonts/icon-fonts.ttf) format(truetype),
url(/assets/fonts/icon-fonts.svg#icon-fonts) format(svg),
url(/assets/fonts/icon-fonts.woff) format(woff),
url(/assets/fonts/icon-fonts.woff2) format(woff2);
font-weight: normal;
font-style: normal;
}
Received:
@font-face {
src: url(/assets/fonts/icon-fonts.eot?#iefix) format(embedded-opentype);
src: url(/assets/fonts/icon-fonts.ttf) format(truetype);
src: url(/assets/fonts/icon-fonts.svg#icon-fonts) format(svg);
src: url(/assets/fonts/icon-fonts.woff) format(woff);
src: url(/assets/fonts/icon-fonts.woff2) format(woff2);
font-family: "icon-fonts";
src: url(/assets/fonts/icon-fonts.eot);
font-weight: normal;
font-style: normal;
}
due to fallback goes first, browser does not load fonts properly
Issue Analytics
- State:
- Created 5 years ago
- Comments:22 (8 by maintainers)
Top Results From Across the Web
Adding fallback fonts to the @font-face definition - css
No, you cannot specify any fallback fonts inside a @font-face rule, because such a rule defines a font face and assigns a name...
Read more >CSS Font Fallbacks - W3Schools
Below are some commonly used font fallbacks, organized by the 5 generic font families: Serif; Sans-serif; Monospace; Cursive; Fantasy. Serif Fonts. font-family ......
Read more >font-display - CSS: Cascading Style Sheets - MDN Web Docs
font-display ; Font block period. If the font face is not loaded, any element attempting to use it must render an invisible fallback...
Read more >CSS Basics: Fallback Font Stacks for More Robust Web ...
The whole idea here is fallbacks. The browser will try to use the font you specified first (Lato, in this case), but if...
Read more >Which fallback fonts should we choose to make FOUT less ...
So I go with Verdana as the first fallback font, followed by the generic sans-serif . According to the Font Family Reunion, this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Array syntax is already used for complex values, that’s why we have fallbacks syntax in the first place, it was intentional. Let’s try fixing the examples
I think you need to reverse the order of what you consider to be a fallback. CSS will fall back to a previously defined property if the next one fails.
So fallback properties should always be defined first.
Second point: you want a src property with multiple values, comma separated. This is also supported: