我现在有相当多的字体需要在我的网站上使用:
fonts/
├── Knockout-30.otf
├── Verlag-Black.otf
├── Verlag-Bold.otf
├── Verlag-Book.otf
├── Verlag-Light.otf
├── VerlagCond-Black.otf
└── VerlagCond-Bold.otf
现在我的 css
是这样的:
@font-face {
font-family: 'Knockout';
src: url('fonts/Knockout-30.otf') format('opentype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Verlag';
src: url('fonts/Verlag-Book.otf') format('opentype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Verlag';
src: url('fonts/Verlag-Bold.otf') format('opentype');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Verlag';
src: url('fonts/Verlag-Light.otf') format('opentype');
font-weight: lighter;
font-style: normal;
}
@font-face {
font-family: 'VerlagBlack';
src: url('fonts/Verlag-Black.otf') format('opentype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'VerlagCond';
src: url('fonts/VerlagCond-Black.otf') format('opentype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'VerlagCond';
src: url('fonts/VerlagCond-Bold.otf') format('opentype');
font-weight: bold;
font-style: normal;
}
目前,这些字体显然不受IE支持,因此我正在考虑使用https://onlinefontconverter.com/来生成IE友好的字体文件类型。对我来说,我需要为字体文件进行7次调用似乎有点繁琐。在合并这些文件方面是否有一个良好的标准,使我只需要进行一次调用?或者至少合并相似的字体系列类型?有人建议将所有东西都进行base64编码,并包含在css
中,但我知道从我的理解中,base64会增加文件大小,因此我不确定这种交换是否值得。非常感谢您的任何建议。
@font-face
时,调用将仅针对CSS请求的字体样式。因此,如果您只使用了几种字体样式,就不会有问题。因为它只会调用已使用的样式。 - Jerad Rutnam