Naoki Otsu

Font Awesomeで、「Failed to decode downloaded font」が出てしまう時

2016-11-11

Font Awesomeを使っていて、本番サイトで確認しようとしたら、
フォントが正しく出ていない... ローカルでは大丈夫だったのに..

そして、コンソールを見たら、
「Failed to decode downloaded font」
とか
「OTS parsing error: incorrect file size in WOFF header」
とか出ている様子..。

原因

調べてみると、git の改行コードを変換する仕組みによって起きてるようでした。
参考: 『Failed to decode downloaded font』から始まるエラー

対策

git のルートディレクトリにある、「.gitattributes」ファイルを開いて、
変換しないように下記を追加してあげると問題ありませんでした。

# Denote all files that are truly binary and should not be modified.
... 中略
*.otf binary
*.eot binary
*.svg binary
*.ttf binary
*.woff binary
*.woff2 binary

もう一度、正しいフォントを格納して、git push して確認したところ無事解決でした。