例如,我见过设计师这样做:
@font-face {
font-family: 'ProximaNovaRegular';
src: url("<%= font_path('PrimaNova-Regular.otf') %>");
src: url("<%= font_path('PrimaNova-Regular.otf') %>") format("opentype"),
url("<%= font_path('proximanova-regular-webfont.woff') %>") format('woff'),
url("<%= font_path('proximanova-regular-webfont.ttf') %>") format('truetype'),
url("<%= font_path('proximanova-regular-webfont.svg#ProximaNovaRegular') %>") format('svg');
}
拥有多种不同格式的目的是什么?一个就够了吗?我正在使用 @font-face 添加字体到我的应用程序,但我只有 .otf 格式 - 这样可以吗?
最佳答案
不同的类型是为了跨浏览器的兼容性。对于某些浏览器,甚至类型的顺序也很重要。
查看 Bulletproof @font-face Syntax和 How to use CSS @font-face .
要转换字体并使用正确的语法获取 CSS 文件,您可以使用 Font Squirrel - Webfont generator .
关于ruby-on-rails - @font-face,提供多个选项有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22097850/