I think the summary is clear enough. To solve the issues: 1.) increase mark parameter of inStream. 2.) set a correct buffersize when convert it to a BufferdInputStream Here is the patch that is API compatible with older versions. 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) {
Created attachment 18805 [details] Patch for this issue
I've taken a look at your patch and the fix for the font name is clear enough. However, the buffer parameter for the BufferedInputStream puzzles me. You add a new method signature with a buffer parameter but you didn't also make a change in PFMReader so that the official command-line tool profits from the change. It looks more like you added this so you can work around the problem in your environment. I'd prefer a more general fix if possible. So, should we simply hard-code the buffer size to 16KB or something like that to avoid the seemingly rare problem you're experiencing?
I finally decided not to apply your patch and to use a more radical approach (buffering the whole file in memory). I still had problems with some PFMs even after applying the proposed patch. http://svn.apache.org/viewvc?view=rev&rev=474410
Hi Jeremias, sorry for my late answer. I saw accidentally that mails from bugzilla have been filtered as junkmail, so I didn't know about your last comments. For the rest, this was my first experience with projects like this, so please be a little bit lenient toward me. But I'll keep your feedback in mind. Regarding the buffer size - I'm not sure why, but with a larger size than 64 I experienced some other problems (too long ago to remember exactly). I think the error causes by the BufferdInputStrem itself, but therefore my experience with Java is too short. But using a ByteArrayInputStream instead seems to be best agreement.
Thank you for your feedback, Patrick. Hey, I'm glad for your patch even though I didn't apply it. It made me investigate the problem more closely. Don't let this scare you away please!!! Don't hesitate if have anything else to contribute at some point!
(In reply to comment #5) > Thank you for your feedback, Patrick. You are welcome. > Hey, I'm glad for your patch even though I didn't apply it. It made me > investigate the problem more closely. Don't let this scare you away please!!! > Don't hesitate if have anything else to contribute at some point! Oh no, I'm not scared. That's for sure. May be I have something else to contribute. Support for MAC fonts ie. Could I contact you directly by mail to arrange it with you?
(In reply to comment #6) > Oh no, I'm not scared. That's for sure. That's good. > May be I have something else to contribute. Support for MAC fonts ie. > > Could I contact you directly by mail to arrange it with you? No, please subscribe to the fop-dev mailing list and post there if there's anything development-specific. That way my colleagues can also help and everything is properly archived. I may not be always and immediately available. Thanks!
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed