self hosting fonts
1.0.0
| 永久链接 |
|---|
/index.html |
网站(git页)
我们中的许多人通过CDN使用Google字体。但是,德国决定违反GDPR,使现场所有者开放诉讼。
我们仍然可以通过:
注意:此页面集中在Google字体上,但是相同的原理适用于任何其他类型的Web字体。
字体松鼠这适用于“ Roboto”,但由于“ Lato”和“ Open Sans”的静态字体版本失败。
Creative Fabrica我将其用于“ Lato”和“ Open Sans”静态文件。我必须一次上传每个变体。
建议我在HTML页面的头部预加载字体。这应该可以加快字体的交付并提高Google的核心网络生命力(CWVS)性能。但是,我在执行此操作后看到了警告(请参阅下面的测试/Firefox和Firefox开发人员版)。
< head >
< link
rel =" preload "
href =" roboto-light-webfont.woff2 "
as =" font "
type =" font/woff2 "
crossorigin =" anonymous "
/>
< link
rel =" preload "
href =" roboto-regular-webfont.woff2 "
as =" font "
type =" font/woff2 "
crossorigin =" anonymous "
/>
< link
rel =" preload "
href =" roboto-medium-webfont.woff2 "
as =" font "
type =" font/woff2 "
crossorigin =" anonymous "
/>
...
<!-- CSS file comes after preload -->
</ head > @font-face {
font-family : "Roboto" ;
font-weight : 300 ;
src : url ( "roboto-light-webfont.woff2" ) format ( "woff2" ) , url ( "roboto-light-webfont.woff" )
format ( "woff" );
}
/** Regular: 400 **/
@font-face {
font-family : "Roboto" ;
font-weight : 400 ;
src : url ( "roboto-regular-webfont.woff2" ) format ( "woff2" ) , url ( "roboto-regular-webfont.woff" )
format ( "woff" );
}
/** Medium: 500 **/
@font-face {
font-family : "Roboto" ;
font-weight : 500 ;
src : url ( "roboto-medium-webfont.woff2" ) format ( "woff2" ) , url ( "roboto-medium-webfont.woff" )
format ( "woff" );
}大部分信息来自解释的自托管字体(包括Google字体)// @font-face教程(YouTube)。有关预加载/CWV和非GDPR依从性的信息从同一页面上的注释线程中出现。