疯狂地说为什么字体不能在移动设备上加载

时间:2018-04-18 01:01:30

标签: css import font-face

我无法弄清楚为什么我的字体不能在移动设备上加载,但它们在桌面上工作正常。我最初在标题中添加了我的字体内联(严格来说,我正在使用的环境)。我现在将我的字体导入为单独的scss文件,但这是我的导入:

@font-face {
  font-family: 'Regular';
  font-weight: 400;
  src: url("/../fontPath/../Regular-Regular.otf") format("opentype")
       url("/../fontPath/../Regular-Regular.woff2") format("woff2"),
       url("/../fontPath/../Regular-Regular.woff") format("woff"),
       url("/../fontPath/../Regular-Regular.eot") format("eot");
}

@font-face {
  font-family: 'Regular';
  font-weight: 600;
  src: url("/../fontPath/../Regular-Semibold.otf") format("opentype")
       url("/../fontPath/../Regular-Semibold.woff2") format("woff2"),
       url("/../fontPath/../Regular-Semibold.woff") format("woff"),
       url("/../fontPath/../Regular-Semibold.eot") format("eot");
}

@font-face {
  font-family: 'Regular';
  font-weight: 600;
  font-style: italic;
  src: url("/../fontPath/../Regular-SemiboldItalic.otf") format("opentype")
       url("/../fontPath/../Regular-SemiboldItalic.woff2") format("woff2"),
       url("/../fontPath/../Regular-SemiboldItalic.woff") format("woff"),
       url("/../fontPath/../Regular-SemiboldItalic.eot") format("eot");
}

@font-face {
  font-family: 'Regular';
  font-weight: 800;
  src: url("/../fontPath/../Regular-BlackItalic.otf") format("opentype")
       url("/../fontPath/../Regular-BlackItalic.woff2") format("woff2"),
       url("/../fontPath/../Regular-BlackItalic.woff") format("woff"),
       url("/../fontPath/../Regular-BlackItalic.eot") format("eot");
}

html {
  font-family: 'Regular', sans-serif;
  font-style: italic;
}

2 个答案:

答案 0 :(得分:0)

您似乎缺少可在移动设备上使用的字体。

你需要truetype(ttf)在Android和iOS上运行良好:

@font-face {
  font-family: 'MyWebFont';
  src: url('webfont.eot'); /* IE9 Compat Modes */
  src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
       url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
       url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}

您可以在此处查看更多详细信息:https://css-tricks.com/snippets/css/using-font-face/

干杯

答案 1 :(得分:0)

我觉得有点傻,但我发现问题是我在otf文件后丢失了一个逗号