LoginSignup
0
0

More than 1 year has passed since last update.

python, Pillow, フォントが読み込めないとき

Posted at

Google FontsからダウンロードしたフォントをPillowに読み込ませていろいろしたいなーというときにはまったので,備忘録です.

環境はWindows.

font = ImageFont.truetype( font="フォント名", size=font_size ) # だめ

font = ImageFont.truetype( font=r"C:\Windows\Fonts\フォント名", size=font_size ) # これもだめ

なときです.

フォントはC:\Users\<ユーザ名>\AppData\Local\Microsoft\Windows\Fontsにインストールされるケースもあるようなので,

font = ImageFont.truetype( font=r"C:\Users\<ユーザ名>\AppData\Local\Microsoft\Windows\Fonts\フォント名", size=font_size )

としてみましょう.

要するに,ファイルのプロパティをちゃんと見ることが大切,ということですね.

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