• R/O
  • SSH
  • HTTPS

pdf-brewer: コミット


コミットメタ情報

リビジョン14 (tree)
日時2020-04-13 13:43:16
作者hirukawa_ryo

ログメッセージ

* pdf-brewer 0.4.1
FontLoaderのnomalize処理でNullPointerExceptionが発生するバグを修正しました。

変更サマリ

差分

--- pdf-brewer/trunk/src/main/java/net/osdn/pdf_brewer/FontLoader.java (revision 13)
+++ pdf-brewer/trunk/src/main/java/net/osdn/pdf_brewer/FontLoader.java (revision 14)
@@ -69,6 +69,10 @@
6969 }
7070
7171 public TrueTypeFont get(String name) {
72+ if(name == null || name.isBlank()) {
73+ return null;
74+ }
75+
7276 TrueTypeFont ttf = fonts.get(normalize(name));
7377 if(ttf != null) {
7478 return ttf;
@@ -147,16 +151,22 @@
147151
148152 List<String> names = new ArrayList<String>();
149153 String fontName = ttf.getName();
150- names.add(normalize(fontName));
151-
154+ if(fontName != null && !fontName.isBlank()) {
155+ names.add(normalize(fontName));
156+ }
157+
152158 NamingTable table = ttf.getNaming();
153159 String fontFamily = table.getFontFamily();
154160 String fontSubFamily = table.getFontSubFamily();
155- names.add(normalize(fontFamily + "-" + fontSubFamily));
156-
161+ if(fontFamily != null && !fontFamily.isBlank() && fontSubFamily != null && !fontSubFamily.isBlank()) {
162+ names.add(normalize(fontFamily + "-" + fontSubFamily));
163+ }
164+
157165 String postScriptName = table.getPostScriptName();
158- names.add(normalize(postScriptName));
159-
166+ if(postScriptName != null && !postScriptName.isBlank()) {
167+ names.add(normalize(postScriptName));
168+ }
169+
160170 Set<Integer> languages = new HashSet<Integer>();
161171 Map<Integer, String> fontFamilies1 = new HashMap<Integer, String>();
162172 Map<Integer, String> fontSubFamilies2 = new HashMap<Integer, String>();
@@ -180,9 +190,9 @@
180190 }
181191 for(Integer languageId : languages) {
182192 fontFamily = fontFamilies1.get(languageId);
183- if(fontFamily != null) {
193+ if(fontFamily != null && !fontFamily.isBlank()) {
184194 fontSubFamily = fontSubFamilies2.get(languageId);
185- if(fontSubFamily != null) {
195+ if(fontSubFamily != null && !fontSubFamily.isBlank()) {
186196 names.add(normalize(fontFamily + "-" + fontSubFamily));
187197 } else {
188198 names.add(normalize(fontFamily));
@@ -189,9 +199,9 @@
189199 }
190200 }
191201 fontFamily = fontFamilies16.get(languageId);
192- if(fontFamily != null) {
202+ if(fontFamily != null && !fontFamily.isBlank()) {
193203 fontSubFamily = fontSubFamilies17.get(languageId);
194- if(fontSubFamily != null) {
204+ if(fontSubFamily != null && !fontSubFamily.isBlank()) {
195205 names.add(normalize(fontFamily + "-" + fontSubFamily));
196206 } else {
197207 names.add(normalize(fontFamily));
旧リポジトリブラウザで表示