【问题标题】:Unable to load @font-face with Chrome, error with jquery?无法使用 Chrome 加载 @font-face,jquery 出错?
【发布时间】:2018-11-21 09:06:40
【问题描述】:

尝试在 Chrome 中加载 @font-face,未经其他浏览器测试。

@font-face {
font-family: titleFont;
src: url('/fonts/VanadineBold.ttf') format("truetype");
/*Have also tried...*/
/*src: url('/fonts/VanadineBold.woff') format("woff");*/
/*src: url('/fonts/VanadineBold.woff2') format("woff2");*/
font-weight: normal;
font-style: normal;
}

p#title {
font-family: titleFont, sans-serif;
position: absolute;
top: 5%;
left: 50%;
transform: translate(-50%, -50%);
}

继续将字体加载为无衬线字体,并在控制台中抛出此错误..?

jquery.min.js:2 GET http://localhost:63342/fonts/VanadineBold.ttf 404 (Not Found)

这是我的文件夹结构...

根文件夹:

在字体文件夹中:

【问题讨论】:

标签: jquery css google-chrome font-face


【解决方案1】:

看this document,format('truetype') 似乎是为 Safari 准备的。

@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 */
}

尝试为 chrome 使用 .woff 字体:

src: url('webfont.woff') format('woff')

【讨论】:

  • 将类型转换为woff2还是不行(显然也改了代码),同样的jquery错误还是弹出来。
  • 也许尝试用你的新代码更新问题。可以改善您的项目结构照片(显示字体文件夹中的字体)......并向我们展示您的项目结构的根(如果它不在现有图像中。)
  • 刚刚更新了帖子,添加了更多图片和代码尝试也更新了。
猜你喜欢
  • 2016-02-07
  • 2016-12-24
  • 2017-12-20
  • 2012-02-04
  • 2021-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-20
相关资源
最近更新 更多