@@ -44,12 +44,9 @@ This file is part of the iText (R) project.
44
44
package com .itextpdf .io .font ;
45
45
46
46
import com .itextpdf .io .IOException ;
47
- import com .itextpdf .io .source .IRandomAccessSource ;
48
47
import com .itextpdf .io .source .RandomAccessFileOrArray ;
49
48
import com .itextpdf .io .source .RandomAccessSourceFactory ;
50
- import com .itextpdf .io .util .StreamUtil ;
51
49
52
- import java .io .FileInputStream ;
53
50
import java .text .MessageFormat ;
54
51
import java .util .Set ;
55
52
@@ -192,9 +189,9 @@ public static FontProgram createFont(String name, byte[] fontProgram, boolean ca
192
189
}
193
190
} else {
194
191
String fontFileExtension = null ;
195
- int extensionBeginIndex = name .lastIndexOf ('.' );
192
+ int extensionBeginIndex = baseName .lastIndexOf ('.' );
196
193
if (extensionBeginIndex > 0 ) {
197
- fontFileExtension = name .substring (extensionBeginIndex ).toLowerCase ();
194
+ fontFileExtension = baseName .substring (extensionBeginIndex ).toLowerCase ();
198
195
}
199
196
if (isBuiltinFonts14 || ".afm" .equals (fontFileExtension ) || ".pfm" .equals (fontFileExtension )) {
200
197
fontBuilt = new Type1Font (name , null , null , null );
@@ -203,7 +200,7 @@ public static FontProgram createFont(String name, byte[] fontProgram, boolean ca
203
200
} else if (".ttf" .equals (fontFileExtension ) || ".otf" .equals (fontFileExtension ) || ".woff" .equals (fontFileExtension )) {
204
201
if (".woff" .equals (fontFileExtension )) {
205
202
if (fontProgram == null ) {
206
- fontProgram = readBytesFromPath ( name );
203
+ fontProgram = readFontBytesFromPath ( baseName );
207
204
}
208
205
try {
209
206
fontProgram = WoffConverter .convert (fontProgram );
@@ -217,11 +214,11 @@ public static FontProgram createFont(String name, byte[] fontProgram, boolean ca
217
214
fontBuilt = new TrueTypeFont (name );
218
215
}
219
216
} else {
220
- int ttcSplit = name .toLowerCase ().indexOf (".ttc," );
217
+ int ttcSplit = baseName .toLowerCase ().indexOf (".ttc," );
221
218
if (ttcSplit > 0 ) {
222
219
try {
223
- String ttcName = name .substring (0 , ttcSplit + 4 ); // count(.ttc) = 4
224
- int ttcIndex = Integer .parseInt (name .substring (ttcSplit + 5 )); // count(.ttc,) = 5)
220
+ String ttcName = baseName .substring (0 , ttcSplit + 4 ); // count(.ttc) = 4
221
+ int ttcIndex = Integer .parseInt (baseName .substring (ttcSplit + 5 )); // count(.ttc,) = 5)
225
222
fontBuilt = new TrueTypeFont (ttcName , ttcIndex );
226
223
} catch (NumberFormatException nfe ) {
227
224
throw new IOException (nfe .getMessage (), nfe );
@@ -490,7 +487,7 @@ private static FontCacheKey createFontCacheKey(String name, byte[] fontProgram)
490
487
491
488
public static void clearRegisteredFontFamilies () { fontRegisterProvider .clearRegisteredFontFamilies (); }
492
489
493
- private static byte [] readBytesFromPath (String path ) throws java .io .IOException {
490
+ static byte [] readFontBytesFromPath (String path ) throws java .io .IOException {
494
491
RandomAccessFileOrArray raf = new RandomAccessFileOrArray (new RandomAccessSourceFactory ().createBestSource (path ));
495
492
int bufLen = (int ) raf .length ();
496
493
if (bufLen < raf .length ()) {
0 commit comments