Closed crystalfp closed 2 years ago
Same error if I move my fonts files under public/
changing the url. Now the message is:
Failed to decode downloaded font: http://localhost:8080/public/fonts/QuattrocentoSans-Regular.ttf
OTS parsing error: invalid sfntVersion: 1008813135
Also the same message using truetype fonts or woff2 ones
Can you provide a repo to get that reproduced?
Not yet. I'll prepare it soon. Thanks for your patience.
Assembling the example revealed the source of the error. The problem has been generated by a wrong path in @font-face
src
item. If I put the font files under /public/fonts
, the url should start with /fonts
. Leaving /public
in front of it generates the curious error mistakenly taken as a file corruption. Maybe a better error message could have made the debugging faster, but I don't know who should generate it. So, this works:
@font-face {
font-family: "Quattrocento Sans";
font-style: normal;
font-weight: normal;
src: url(/fonts/QuattrocentoSans-Regular.woff2) format("woff2"),
url(/fonts/QuattrocentoSans-Regular.ttf) format("truetype");
font-display: swap;
}
Sorry for the noise mario
Version
4.5.15
Reproduction link
Environment info
Steps to reproduce
1) Download a font from Google fonts (I use Quattrocento font) 2) Put the .ttf files in src/styles/fonts 3) Create a css file containing:
4) The font is not loaded and the following message appears in the browser console:
5) If I bypass the vue-cli server and load the font directly from Google, it works. I use:
What is expected?
The font loaded as happens with the same font files in another application not based on Vue.
What is actually happening?
See above the error message. Seems like the vue-cli development server is corrupting the file, like a wrong mime type or a CR LF issue.
Thanks for looking! mario