Skip to content

Commit

Permalink
#954 Speed up loading fonts from JAR (#955)
Browse files Browse the repository at this point in the history
wrapping InputStream to BufferedInputStream makes much faster loading fonts from openpdf-*.jar
  • Loading branch information
asolntsev authored Nov 1, 2023
1 parent 6444ade commit beb73f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openpdf/src/main/java/com/lowagie/text/pdf/BaseFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.lowagie.text.DocumentException;
import com.lowagie.text.error_messages.MessageLocalization;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.SecureRandom;
Expand Down Expand Up @@ -1723,7 +1724,7 @@ public static InputStream getResourceStream(String key, ClassLoader loader) {
if (loader != null) {
is = loader.getResourceAsStream(key);
if (is != null) {
return is;
return new BufferedInputStream(is);
}
}
// Try to use Context Class Loader to load the properties file.
Expand All @@ -1742,7 +1743,7 @@ public static InputStream getResourceStream(String key, ClassLoader loader) {
if (is == null) {
is = ClassLoader.getSystemResourceAsStream(key);
}
return is;
return is == null ? null : new BufferedInputStream(is);
}

/**
Expand Down

0 comments on commit beb73f8

Please sign in to comment.