I search to preload a fonts from CSS file.
The Css Files cut the font by unicode-range
: It's pretty good, that load only the part of the font I want.
But : I want to preload (before this CSS file) the font will be used by the browser. And I don't know how to know what is the font I should preload ?
ex :
<head>
<!-- Which font ? a.woof2 / b.woff2 or c.woff2 ? -->
<link rel="preload" href="fonts/myFont_x.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<!-- other elements -->
<link rel="stylesheet" href="mystyleFont.css">
</head>
css file (mystyleFont.css) :
@font-face {
font-family: 'myFont';
font-display: swap;
src: url(https://example.com/a.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; // That is the unicode-range
}
@font-face {
font-family: 'myFont';
font-display: swap;
src: url(https://example.com/b.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129;
}
@font-face {
font-family: 'myFont';
font-display: swap;
src: url(https://example.com/c.woff2) format('woff2');
unicode-range: U+0460-052F;
}
In this sample, I want to preload only c.woff2
if the browser use the unicode-range U+0460-052F
...
And I don't want to preload all fonts on my page.
Do you have an idea for that ?
Thank you !