Linuxでフォントを使う時のメモ。

フリーフォント

フォントファミリー

  • sans-serif (ゴシック体・サンセリフ体)
  • serif (明朝体・セリフ体)
  • monospace (等幅)
  • cursive (手書き文字)
  • fantasy (装飾書体)
$ fc-match sans-serif
NotoSansCJKjp-Regular.otf: "Noto Sans CJK JP" "Regular"
$ fc-match sans-serif:weight=bold
NotoSansCJKjp-Bold.otf: "Noto Sans CJK JP" "Bold"
$ fc-match "Source Han Serif"
NotoSansCJKjp-Regular.otf: "Noto Sans CJK JP" "Regular"

使えるフォントの確認

$ fc-list
/usr/share/fonts/ja/TrueType/JosefinSans-Regular.ttf: Josefin Sans:style=Regular
/usr/share/fonts/ja/TrueType/mplus-1p-light.ttf: M+ 1p,M+ 1p light:style=light,Regular
/usr/share/fonts/ja/TrueType/NotoSansCJKjp-Regular.otf: Noto Sans CJK JP,Noto Sans CJK JP Regular:style=Regular
/usr/share/fonts/ja/TrueType/aoyagikouzanfontsousyo2.ttf: AoyagiKouzanFontSousyo2:style=Regular
/usr/share/fonts/ja/TrueType/Raleway-Regular.ttf: Raleway:style=Regular
/usr/share/fonts/ja/TrueType/UtsukushiFONT.otf: 02うつくし明朝体:style=Regular
/usr/share/fonts/ja/TrueType/flower1.ttf: flower1:style=Regular
/usr/share/fonts/ja/TrueType/COM4FBL_.ttf: COM4t Famie:style=Black
/usr/share/fonts/ja/TrueType/flower3.ttf: flower3:style=Regular
/usr/share/fonts/ja/TrueType/COM4FBLO.ttf: COM4t Famie:style=BlackOblique
/usr/share/fonts/ja/TrueType/OpenBaskerville-0.0.75.otf: Open Baskerville 0.0.75:style=Normal
/usr/share/fonts/abattis-cantarell/Cantarell-Bold.otf: Cantarell:style=Bold
/usr/share/fonts/ja/TrueType/aquafont.ttf: aquafont:style=Regular
/usr/share/fonts/ja/TrueType/TheanoOldStyle-Regular.ttf: Theano Old Style:style=Regular
/usr/share/fonts/ja/TrueType/Hanken-Book.ttf: Hanken:style=Book
/usr/share/fonts/ja/TrueType/Capsuula.ttf: Capsuula:style=Regular
/usr/share/fonts/ja/TrueType/NotoSansJP-Bold.otf: Noto Sans JP Bold:style=Regular
/usr/share/fonts/ja/TrueType/MTLmr3m.ttf: MotoyaLMaru:style=W3 mono
/usr/share/fonts/ja/TrueType/NotoSerifCJKjp-Bold.ttf: NotoSerifCJKjp\-Bold.min:style=Regular
/usr/share/fonts/ja/TrueType/PlayfairDisplay-Regular.otf: Playfair Display:style=Regular
/usr/share/fonts/ja/TrueType/MTLc3m.ttf: MotoyaLCedar:style=W3 mono
/usr/share/fonts/abattis-cantarell/Cantarell-Regular.otf: Cantarell:style=Regular
/usr/share/fonts/ja/TrueType/garto16.ttf: Garton:style=Medium
/usr/share/fonts/ja/TrueType/mplus-1m-regular.ttf: M+ 1m:style=regular
/usr/share/fonts/abattis-cantarell/Cantarell-Oblique.otf: Cantarell:style=Oblique
/usr/share/fonts/ja/TrueType/Inconsolata.otf: Inconsolata:style=Medium
/usr/share/fonts/ja/TrueType/mplus-1p-regular.ttf: M+ 1p:style=regular
/usr/share/fonts/ja/TrueType/XANO-mincho-U32.ttf: XANO\-mincho\-U32:style=Regular
/usr/share/fonts/abattis-cantarell/Cantarell-BoldOblique.otf: Cantarell:style=BoldOblique
/usr/share/fonts/ja/TrueType/mikachan.ttf: mikachan:style=Regular
/usr/share/fonts/ja/TrueType/NotoSerifJP-Regular.otf: Noto Serif JP:style=Regular
/usr/share/fonts/ja/TrueType/mplus-1p-black.ttf: M+ 1p,M+ 1p black:style=black,Regular
/usr/share/fonts/ja/TrueType/ComicNeue_Bold.otf: Comic Neue:style=Bold
/usr/share/fonts/ja/TrueType/mplus-1p-thin.ttf: M+ 1p,M+ 1p thin:style=thin,Regular
/usr/share/fonts/ja/TrueType/aoyagikouzanfont2.ttf: AoyagiKouzanFont2:style=Regular
/usr/share/fonts/ja/TrueType/aqua_pfont.ttf: aqua_pfont:style=Regular
/usr/share/fonts/ja/TrueType/keifont-kana.ttf: Keifont Kana:style=Regular

/etc/fonts/local.conf

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
	<match target="font">
		<edit mode="assign" name="antialias">
			<bool>true</bool>
		</edit>
		<edit mode="assign" name="embeddedbitmap">
			<bool>false</bool>
		</edit>
		<edit mode="assign" name="hinting">
			<bool>true</bool>
		</edit>
		<edit mode="assign" name="autohint">
			<bool>true</bool>
		</edit>
		<edit mode="assign" name="hintstyle">
			<const>hintslight</const>
		</edit>
		<edit mode="assign" name="lcdfilter">
			<const>lcddefault</const>
		</edit>
		<edit name="lcdfilter" mode="assign">
			<const>lcddefault</const>
		</edit>
		<edit mode="assign" name="rgba">
			<const>rgb</const>
		</edit>
	</match>

	<!--<match target="pattern">
		<test qual="any" name="family"><string>serif</string></test>
		<edit name="family" mode="prepend" binding="same"><string>Noto Serif JP</string></edit>
	</match>

	<match target="pattern">
		<test qual="any" name="family"><string>sans-serif</string></test>
		<edit name="family" mode="prepend" binding="same"><string>Noto Sans CJK JP</string></edit>
	</match>

	<match target="pattern">
		<test qual="any" name="family"><string>monospace</string></test>
		<edit name="family" mode="prepend" binding="same"><string>MotoyaLMaru</string></edit>
	</match>-->
</fontconfig>

/etc/fonts/conf.d/59-aliases.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

	<alias>
		<family>sans-serif</family>
		<prefer>
			<family>M+ 1p</family>
			<family>Raleway</family>
			<family>W3 mono</family>
		</prefer>
	</alias>
	<alias>
		<family>serif</family>
		<prefer>
			<family>Playfair Display</family>
			<family>Noto Serif JP</family>
			<family>XANO-mincho-U32</family>
		</prefer>
	</alias>
	<alias>
		<family>fantasy</family>
		<prefer>
			<family>COM4t Famie</family>
			<family>aqua_pfont</family>
		</prefer>
	</alias>
	<alias>
		<family>cursive</family>
		<prefer>
			<family>Hanken</family>
			<family>02うつくし明朝体</family>
		</prefer>
	</alias>
	<alias>
		<family>monospace</family>
		<prefer>
			<family>Inconsolata</family>
			<family>W3 mono</family>
			<family>MotoyaLMaru</family>
		</prefer>
	</alias>

	<alias binding="same">
	  <family>Josefin Sans</family>
	  <default>
	  <family>Arial</family>
	  <family>sans-serif</family>
	  </default>
	</alias>
	<alias binding="same">
	  <!--<family>Theano Old Style</family>-->
	  <family>Playfair Display</family>
	  <default>
	  <family>Times New Roman</family>
	  <family>serif</family>
	  </default>
	</alias>

	<match target="pattern">
		<test qual="any" name="family">
			<string>MS PGothic</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>M+ 1p</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>MS Gothic</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>MotoyaLCedar</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>MS PMincho</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Serif JP</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>MS Mincho</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>02うつくし明朝体</string>
		</edit>
	</match>

	<match target="pattern">
		<test qual="any" name="family">
			<string>Hiragino Kaku Gothic Pro</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>Hiragino Kaku Gothic ProN</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>HiraKakuPro-W6</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>HiraKakuProN-W6</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>

	<match target="pattern">
		<test qual="any" name="family">
			<string>Droid Sans</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>W3 mono</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>Roboto</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>W3 mono</string>
		</edit>
	</match>

	<match target="pattern">
		<test qual="any" name="family">
			<string>Century Gothic</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Raleway</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>Century</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Playfair Display</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>MS Serif</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Playfair Display</string>
		</edit>
	</match>
	<match target="pattern">
		<test qual="any" name="family">
			<string>Script</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Garton</string>
		</edit>
	</match>
	<!-- Replace Comic Sans with Comic Neue bold -->
	<match>
		<test name="family">
			<string>Comic Sans MS</string>
		</test>
		<edit binding="same" mode="assign" name="family">
			<string>Comic Neue</string>
		</edit>
		<edit binding="weak" mode="assign" name="style">
			<string>Bold</string>
		</edit>
	</match>

	<!-- Flash Player mojibake -->
	<match target="pattern">
		<test qual="any" name="family">
			<!--<string>AR PL UMing CN</string>-->
			<string>Meiryo</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>
	<!-- Xine Player mojibake -->
	<match target="pattern">
		<test qual="any" name="family">
			<string>Helvetica</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>M+ 1p</string>
		</edit>
	</match>
	<!-- Wine mojibake -->
	<match target="pattern">
		<test qual="any" name="family">
			<string>Tahoma</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>Noto Sans CJK JP</string>
		</edit>
	</match>

	<!-- bold, italic -->
	<match target="font">
		<!-- check to see if the font is roman -->
		<test name="slant">
			<const>roman</const>
		</test>
		<!-- check to see if the pattern requested non-roman -->
		<test target="pattern" name="slant" compare="not_eq">
			<const>roman</const>
		</test>
		<!-- multiply the matrix to slant the font -->
		<edit name="matrix" mode="assign">
			<times>
				<name>matrix</name>
				<matrix>
					<double>1</double><double>0.2</double>
					<double>0</double><double>1</double>
				</matrix>
			</times>
		</edit>
		<!-- pretend the font is oblique now -->
		<edit name="slant" mode="assign">
			<const>oblique</const>
		</edit>
	</match>
	<match target="font">
		<!-- check to see if the font is just regular -->
		<test name="weight" compare="less_eq">
			<const>medium</const>
		</test>
		<!-- check to see if the pattern requests bold -->
		<test target="pattern" name="weight" compare="more">
			<const>medium</const>
		</test>
		<!-- set the embolden flag -->
		<edit name="embolden" mode="assign">
			<bool>true</bool>
		</edit>
	</match>

</fontconfig>