• R/O
  • SSH
  • HTTPS

pdf-brewer: コミット


コミットメタ情報

リビジョン29 (tree)
日時2020-11-21 13:00:15
作者hirukawa_ryo

ログメッセージ

* pdf-brewer 0.4.6
アプリケーションフォルダーに fonts フォルダーが配置されている場合、fonts フォルダーからフォントをロードするようにしました。
ロード対象のファイルは IPAexフォント(ipaexg.ttf、ipaexm.ttf)、源真ゴシック(GenShinGothic-Regular.ttf、GenShinGothic-Bold.ttf)、源様明朝(GenYoMinJP-R.ttf、GenYoMinJP-B.ttf)です。
fonts フォルダーによって macOS/Linux にも対応できるようになります。
尚、macOS/Linuxのシステムフォントディレクトリーからのフォント検索には対応しません。現時点でpdfboxを使ったフォント埋め込みにOTFは対応しておらずTTFが必要になります。macOS/Linuxのシステムフォントの多くはOTFであるため、システムフォントディレクトリーを検索するべきではないと判断しました。

変更サマリ

差分

--- pdf-brewer/trunk/src/main/java/net/osdn/pdf_brewer/FontLoader.java (revision 28)
+++ pdf-brewer/trunk/src/main/java/net/osdn/pdf_brewer/FontLoader.java (revision 29)
@@ -26,8 +26,15 @@
2626
2727 public static final List<String> FILENAMES_YUGOTHIC;
2828 public static final List<String> FILENAMES_YUMINCHO;
29+ public static final List<String> FILENAMES_IPA_GOTHIC;
30+ public static final List<String> FILENAMES_IPA_MINCHO;
31+ public static final List<String> FILENAMES_NOTO_GOTHIC;
32+ public static final List<String> FILENAMES_NOTO_MINCHO;
2933
3034 static {
35+ //
36+ // for Windows
37+ //
3138 FILENAMES_YUGOTHIC = Arrays.asList(
3239 "yugothib.ttf",
3340 "yugothic-bold.ttf",
@@ -43,6 +50,28 @@
4350 "yumindb.ttf",
4451 "yuminl.ttf"
4552 );
53+
54+ //
55+ // for NOTO
56+ //
57+ FILENAMES_NOTO_GOTHIC = Arrays.asList(
58+ "GenShinGothic-Regular.ttf",
59+ "GenShinGothic-Bold.ttf"
60+ );
61+ FILENAMES_NOTO_MINCHO = Arrays.asList(
62+ "GenYoMinJP-R.ttf",
63+ "GenYoMinJP-B.ttf"
64+ );
65+
66+ //
67+ // for IPA
68+ //
69+ FILENAMES_IPA_GOTHIC = Arrays.asList(
70+ "ipaexg.ttf"
71+ );
72+ FILENAMES_IPA_MINCHO = Arrays.asList(
73+ "ipaexm.ttf"
74+ );
4675 }
4776
4877 public static File getDefaultFontDir() {
@@ -67,12 +96,41 @@
6796 TrueTypeFont serifBold;
6897 TrueTypeFont sansSerif;
6998 TrueTypeFont sansSerifBold;
70-
99+
100+ // for Windows
71101 serif = getFont("YuMincho-Regular");
72102 serifBold = getFont("YuMincho-Demibold");
73103 sansSerif = getFont("YuGothic-Regular");
74104 sansSerifBold = getFont("YuGothic-Bold");
75105
106+ // for Noto (fallback)
107+ if(serif == null) {
108+ serif = getFont("r-源様明朝");
109+ }
110+ if(serifBold == null) {
111+ serifBold = getFont("b-源様明朝");
112+ }
113+ if(sansSerif == null) {
114+ sansSerif = getFont("regular-源真ゴシック");
115+ }
116+ if(sansSerifBold == null) {
117+ sansSerifBold = getFont("bold-源真ゴシック");
118+ }
119+
120+ // for IPA (fallback)
121+ if(serif == null) {
122+ serif = getFont("ipaexmincho");
123+ }
124+ if(serifBold == null) {
125+ serifBold = getFont("ipaexmincho");
126+ }
127+ if(sansSerif == null) {
128+ sansSerif = getFont("ipaexgothic");
129+ }
130+ if(sansSerifBold == null) {
131+ sansSerifBold = getFont("ipaexgothic");
132+ }
133+
76134 if(serif != null && serifBold != null && sansSerif != null && sansSerifBold != null) {
77135 try {
78136 register("serif", serif);
@@ -130,6 +188,10 @@
130188 }
131189
132190 public void load(File dir, Collection<String> fileNames, Collection<String> fontNames) {
191+ if(dir == null) {
192+ return;
193+ }
194+
133195 Set<String> fileNameSet = null;
134196 if(fileNames != null) {
135197 fileNameSet = new HashSet<String>();
旧リポジトリブラウザで表示