Index: PFMFile.java
===================================================================
--- PFMFile.java	(revision 439270)
+++ PFMFile.java	(working copy)
@@ -70,18 +70,37 @@
     protected Log log = LogFactory.getLog(PFMFile.class);
 
     /**
+     * Parses a PFM file.
+     * It is the same as load(inStream, 0);
+     *
+     * @param  inStream The stream from which to read the PFM file.
+     * @throws IOException In case of an I/O problem
+     */
+    public void load(InputStream inStream) throws IOException {
+        load(inStream, 0);
+    }
+
+    /**
      * Parses a PFM file
      *
      * @param  inStream The stream from which to read the PFM file.
+     * @param  bufferSize If inStream doesn't support marks and it is going to be buffered, the size the bufferd stream must have.
+     * Will be ignored if inStream supports marks. Should equal the full size of inStream.
      * @throws IOException In case of an I/O problem
      */
-    public void load(InputStream inStream) throws IOException {
+    public void load(InputStream inStream, int bufferSize) throws IOException {
         InputStream bufin = inStream;
         if (!bufin.markSupported()) {
-            bufin = new BufferedInputStream(bufin);
+            if (bufferSize > 0)
+                bufin = new BufferedInputStream(bufin, bufferSize);
+            else
+                bufin = new BufferedInputStream(bufin);
+
         }
         PFMInputStream in = new PFMInputStream(bufin);
-        bufin.mark(16);
+// increased buff.mark() four times to avoid errors when reading fontnames larger than 16 characters.
+//        bufin.mark(16);
+        bufin.mark(64);
         short sh1 = in.readByte();
         short sh2 = in.readByte();
         if (sh1 == 128 && sh2 == 1) {
