【问题标题】:how to load .ttf fonts from a URL path?如何从 URL 路径加载 .ttf 字体?
【发布时间】:2014-03-31 02:56:02
【问题描述】:

我正在尝试从URL path 在页面中加载外部.ttf 字体。

如果我像这样在本地加载它会正常工作:

@font-face {
    font-family: 'myFnt';
         url('fonts/Font.ttf') format('truetype'),

}

但它在Firefox 中不起作用,如果我尝试像这样加载它也不会加载字体:

@font-face {
    font-family: 'myFnt';
         url('http://www.mywebsite.com/fonts/Font.ttf') format('truetype'),

}

我在Google Chrome 中对其进行了测试,无论哪种方式都可以正常工作,但是如果我按照第二个代码中显示的方式进行操作,它不会在Firefox 中加载字体!

有人可以帮我解决这个问题吗?

【问题讨论】:

标签: css fonts


【解决方案1】:

这也适用于 4 in chrome 和 firefox

@font-face {
    font-family: 'myFnt';
    src: url('webfonts/name.ttf');
    font-weight: normal;
    font-style: normal;
}

您使用的是 .htaccess 文件吗?如果是,请将 theae 放在您的 .htaccess 文件中

<FilesMatch "\.(ttf|otf|eot)$">
    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>

在这里你可以阅读解决方案font-face not working only firefox

【讨论】:

  • 你在使用 .htaccess 文件吗??
  • 我正在使用 htaccess 文件,但我需要在 ebay 模板中加载字体,因此 .htaccess 无济于事!
猜你喜欢
  • 2012-05-29
  • 1970-01-01
  • 2015-02-07
  • 1970-01-01
  • 2018-09-27
  • 2011-02-11
  • 2015-07-12
  • 2014-05-24
  • 2017-02-02
相关资源
最近更新 更多