1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

typefaceが非推奨になっていたのでfontsourceを使おう

Last updated at Posted at 2024-12-26

タイトル以上でも以下でもないメモです

経緯

google fontなどをお手軽にかつセルフホストする手段として
typefaceがありました
npm install typeface-フォント名
からの
import typeface-フォント名
と行うだけでフォントが使用できるようになる便利ツールです。

ただGoogle Fontで日本語が対応しているフォントにもかかわらず、適用されないときがあり
「あれ?ライブラリ側で日本語サポートしていないのかな?」
とtypefaceのドキュメントを確認したところ以下の文言がありました。

The Typefaces project is now deprecated.

@DecliningLotus created FontSource which provides the same functionality as Typefaces but with automated releases & richer support for importing specific weights, styles, or language subsets.

To start using Fontsource, replace in your package.json any instances of "typeface-m-plus-rounded-1c" with "fontsource-m-plus-rounded-1c".

Then change imports from "import 'typeface-m-plus-rounded-1c'" to "import 'fontsource-m-plus-rounded-1c/latin.css'".

Typeface packages will continue working indefinitely so no immediate changes are necessary.

結論

言われている通りfontsourceを代わりに使いましょう。

https://fontsource.org/
から目的のフォントを探して

npm install @fontsource/フォント名
からの
import '@fontsource/m-plus-rounded-1c';

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?