0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google fontの 'downloadable font: gasp: Changed the version number to 1' メッセージに対処する

Last updated at Posted at 2023-02-13

概要

Google Fontsをダウンロードし、CSSのfont-faceで定義したときに、Windows版Firefoxのコンソールに以下のメッセージが出ることがあります(ブラウザコンソールで表示されるため、Webページの動作には問題は無いと思います)。

downloadable font: gasp: Changed the version number to 1 (font-family: "Quicksand" style:normal weight:700 stretch:100 src index:0) source: https://hostname/webfonts/Quicksand/Quicksand-Bold.ttf

このメッセージ通り、gasp.version1にすることで解消します。対象TTFのgaspテーブルのversion0になっており、Pythonのfonttoolsモジュールを使い、gasp.version1にすることで回避することができました。

TTFのgaspテーブルとはGrid-fitting And Scan-conversion Procedure Tableというもののようです。Microsoftの仕様書の中でversionはset to 1と書かれており、1が正しい値のようです。

解決手順

環境

CSSではこのように定義しています。

@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 700;
  src: url(../webfonts/Quicksand/Quicksand-Bold.ttf) format('truetype');
}

これが適用されたときに上記の警告が出るみたいです。
Google FontsのGitHubで数年前に議論されていますが、再現性が低いとされてクローズされているみたいです。

私の場合はWindows10(22H2) Firefox 109.0.1で発生しました(ずっと以前のバージョンから出ていたと思います)。Edge 109.0.1518.70ではメッセージは表示されませんでした。

fonttoolsモジュールによるTTFファイルの修正

fonttoolsモジュールを使いTTFファイルのgasp.versionの値を1に書き換えて保存します。

fonttoolsのインストール

pipでインストールします。CentOS 7.9 + Python 3.6で実行しましたが、他の環境でも動作すると思います。

$ pip3 install fonttools

gasp.versionの値を修正して保存します

from fontTools.ttLib import TTFont
# フォントを読み込む
font = TTFont("Quicksand-Bold.ttf")
# gasp.versionが0の時に問題が発生しているように思うので1にする
if font["gasp"].version == 0:
    font["gasp"].version = 1
    font.save("Quicksand-Bold-v1.ttf")  # 修正後のttfを保存する

ここで保存したQuicksand-Bold-v1.ttfを使うことで警告が表示されなくなりました。Quicksandでしか試していないので他のフォントも同様かはわかりませんが。

動作には影響ありませんが、ずっと気になってたのが修正できました!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?