CentOSに 日本語TrueTypeフォント「IPAフォント」と「IPAexフォント」をインストールする。

Pythonの画像作成モジュール、PILで日本語を使う必要が出て来て、ServersMan@VPSCentOS)に日本語フリーTrueTypeフォントIPAフォントver.3(003.03) 4書体パックとIPAexフォント2書体パック(Ver.002.01)を入れてみました。

IPAexフォント・IPAフォントのダウンロード || OSS iPedia

IPAexフォント2書体パック(Ver.002.01)に含まれているフォントは以下の通り

  • IPAex明朝/IPAex Mincho (ipaexm.ttf)
  • IPAexゴシック/IPAex Gothic (ipaexg.ttf)

IPAフォント4書体パック(Ver.003.03)に含まれているフォントは以下の通り。

  • IPA明朝/IPA Mincho (ipam.ttf)
  • IPA P明朝/IPA P Mincho (ipamp.ttf)
  • IPAゴシック/IPA Gothic(Sans serif) (ipag.ttf)
  • IPA Pゴシック/IPA P Gothic(Sans serif) (ipagp.ttf)
wget http://ossipedia.ipa.go.jp/ipafont/IPAfont00303.php
unzip IPAfont00303.zip
mkdir /usr/share/fonts/japanese
mkdir /usr/share/fonts/japanese/TrueType
mv IPAfont00303/*.ttf /usr/share/fonts/japanese/TrueType/

wget http://ossipedia.ipa.go.jp/ipafont/ipaexfont/IPAexfont00201.php
unzip IPAexfont00201.zip
mv IPAexfont00201/*.ttf /usr/share/fonts/japanese/TrueType/
fc-cache -fv

PILからダウンロードしたフォントを使ってみる

python
>>> from PIL import Image, ImageDraw, ImageFont
>>> font = ImageFont.truetype('/usr/share/fonts/japanese/TrueType/ipamp.ttf', 18, encoding='unic')
>>> image = Image.new('RGBA', (100, 100), (200, 200, 200))
>>> draw = ImageDraw.Draw(image)
>>> draw.text((10, 40), u'こんにちわ', font = font, fill='#0000FF')
>>> image.save('hello.png', 'PNG')
>>>
>>> font = ImageFont.truetype('/usr/share/fonts/japanese/TrueType/ipaexg.ttf', 18, encoding='unic')
>>> image = Image.new('RGBA', (100, 100), (200, 200, 200))
>>> draw = ImageDraw.Draw(image)
>>> draw.text((5, 40), u'こんにちわ', font = font, fill='#0000FF')
>>> image.save('hello1.png', 'PNG')

それで、作成された画像は以下。
IPA プロポーショナル明朝体とIPAexゴシック体の2種類)