Am 10.02.26 um 20:09 schrieb Tilman Hausherr:
Re the recent posting by Daniel Gredler in the users
list: NonSeekableRandomAccessReadInputStream has length() 0 after start.
This is a problem if passed to TTFParser.parse() where it is fed to
a RandomAccessReadDataStream. There is a comment by me in one of the
tests which I added for better coverage, but I didn't do anything except
noticing it.
Good catch. The implementation of "available" and "readFully" is
problematic as well as both are using "length".
- "available" shall return is.available
- "readFully" can be implemented without using "length"
The implementation of the constructor of RandomAccessReadDataStream can
be changed to read the full data without using length() by reading the
data in chunks which are combined at the end.
The constructor of RandomAccessReadUnbufferedDataStream uses length as
well, so that we have to check it too. Fortunately it is an internal
class and can not be used outside.
I don't have a good solution; throwing an exception for length breaks
the COSParser constructor, which is also used for page content streams.
What we could do is to document it it in javadoc not to use it outside
of PDFBox, and to catch it early in TTFParser because like Daniel,
people might use an autocomplete feature in their IDE and chose the
"wrong" class.
Adjusting the documentation is always a good idea.
Somewhat related:
RandomAccessReadDataStream reads the entire input into a buffer. So this
means that if we pass the result of
RandomAccessReadBuffer.createBufferFromStream() to it, the buffering is
done twice, e.g. if PDTrueTypeFont.load(PDDocument doc, InputStream
input, Encoding encoding) is called.
Maybe we should refactor TTFDataStream using RandomAccessRead directly ...
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]