javascript - failed to download decoded font Roboto-Regular-webfont
问题描述
Facing issues while downloading the font for the first time(after clearing cache), post reloading for 2/3 times error is not there and font loaded properly.
Failed to decode downloaded font: /Roboto-Regular-webfont.ttf /Roboto-Bold-webfont.ttf
As per research tried few workarounds but still facing the issue
- tried updating the format('woff') to format('font-woff')
- tried with absolute url : https://example.com/Roboto-Regular-webfont.ttf
解决方案
我假设您想自己托管字体。
最简单的方法是使用 google webfonts 助手:https ://google-webfonts-helper.herokuapp.com/fonts/roboto?subsets=latin
在您的情况下,这样的事情就足够了:
/* roboto-regular - latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url('roboto-v27-latin-regular.eot'); /* IE9 Compat Modes */
src: local(''),
url('roboto-v27-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('roboto-v27-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('roboto-v27-latin-regular.woff') format('woff'), /* Modern Browsers */
url('roboto-v27-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('roboto-v27-latin-regular.svg#Roboto') format('svg'); /* Legacy iOS */
}
您可以从 google-webfonts-helper 或直接从 google 字体下载文件。
推荐阅读
- ibm-cloud-infrastructure - 如何获取 VLAN 的网络速度
- python - 如何创建带有类别的 Matplotlib 条形图?
- python - Azure 语音 SDK | 蟒蛇 | 实施关键字识别
- c# - .NET Query With list inside 无法翻译
- react-native - 如何在没有反应原生游戏引擎的情况下在反应原生中使用matterJS
- python - 抓取以 [some text] 开头的 json 对象
- python - 在脚本中执行 bash 函数并返回
- javascript - Number toLocaleString 不适用于 Angular 的测试
- c++ - 在 QWebView Qt5 中禁用水平滚动条
- typescript - 对类和接口属性使用不同的 eslint 命名规则