aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fonts
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-11-13 17:42:28 +0000
committerJeremias Maerki <jeremias@apache.org>2006-11-13 17:42:28 +0000
commit195f60f264f5af9aaba5239e0a80b6ca29616bfb (patch)
tree21c23d3a82524bb55ffc906af97a48590603bded /src/java/org/apache/fop/fonts
parent652b3cbc5586d794a41bee4d2c824539e18b3cfc (diff)
downloadxmlgraphics-fop-195f60f264f5af9aaba5239e0a80b6ca29616bfb.tar.gz
xmlgraphics-fop-195f60f264f5af9aaba5239e0a80b6ca29616bfb.zip
Bugzilla #40387:
Dealing with IOExceptions for certain large PFM files in a more radical way: load everything into memory, since we basically need random access here. The biggest PFMs I've seen so far are around 20KB so this shouldn't be a big problem, especially as the memory is freed pretty quickly. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@474410 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fonts')
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFMFile.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/fonts/type1/PFMFile.java b/src/java/org/apache/fop/fonts/type1/PFMFile.java
index 4a009ae38..b2d2ee933 100644
--- a/src/java/org/apache/fop/fonts/type1/PFMFile.java
+++ b/src/java/org/apache/fop/fonts/type1/PFMFile.java
@@ -21,10 +21,12 @@ package org.apache.fop.fonts.type1;
// Java
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -76,12 +78,11 @@ public class PFMFile {
* @throws IOException In case of an I/O problem
*/
public void load(InputStream inStream) throws IOException {
+ byte[] pfmBytes = IOUtils.toByteArray(inStream);
InputStream bufin = inStream;
- if (!bufin.markSupported()) {
- bufin = new BufferedInputStream(bufin);
- }
+ bufin = new ByteArrayInputStream(pfmBytes);
PFMInputStream in = new PFMInputStream(bufin);
- bufin.mark(16);
+ bufin.mark(512);
short sh1 = in.readByte();
short sh2 = in.readByte();
if (sh1 == 128 && sh2 == 1) {