[
https://issues.apache.org/jira/browse/PDFBOX-5486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17576250#comment-17576250
]
Tilman Hausherr commented on PDFBOX-5486:
-----------------------------------------
I noticed the comment "we don't actually read the complete table here because
it can contain tens of thousands of glyphs" but now we do keep the entire
table, isn't it? That's 22410874 bytes for arialuni.ttf .
> "RandomAccessBuffer already closed" when opening smaller fonts
> --------------------------------------------------------------
>
> Key: PDFBOX-5486
> URL: https://issues.apache.org/jira/browse/PDFBOX-5486
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 3.0.0 PDFBox
> Reporter: Tilman Hausherr
> Assignee: Andreas Lehmkühler
> Priority: Major
> Fix For: 3.0.0 PDFBox
>
>
> I wonder if this is related to one of the memory management / inputstream
> changes, PDTrueTypeFont.load() can't load smaller ttf fonts (I discovered
> this while working with the font from PDFBOX-5484):
> {code}
> public static void main(String[] args) throws IOException
> {
> File fontDir = new File("C:/windows/fonts");
> File[] files = fontDir.listFiles((File dir, String name) ->
> name.toLowerCase().endsWith(".ttf"));
> for (File file : files)
> {
> PDDocument doc = new PDDocument();
> PDTrueTypeFont ttf = PDTrueTypeFont.load(doc, file,
> WinAnsiEncoding.INSTANCE);
> if (ttf.hasGlyph("A"))
> {
> try
> {
> ttf.getPath("A");
> }
> catch (IOException ex)
> {
> System.out.println("font " + ttf.getName() + " failed,
> size: " + file.length() +
> ", glyphs: " +
> ttf.getTrueTypeFont().getNumberOfGlyphs() + ": " + ex.getMessage());
> ex.printStackTrace();
> }
> }
> }
> }
> {code}
> {noformat}
> font BookAntiqua-Bold failed, size: 151000, glyphs: 669: RandomAccessBuffer
> already closed
> java.io.IOException: RandomAccessBuffer already closed
> at
> org.apache.pdfbox.io.RandomAccessReadBuffer.checkClosed(RandomAccessReadBuffer.java:337)
> at
> org.apache.pdfbox.io.RandomAccessReadBuffer.getPosition(RandomAccessReadBuffer.java:188)
> at
> org.apache.fontbox.ttf.RandomAccessReadDataStream.getCurrentPosition(RandomAccessReadDataStream.java:80)
> at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:135)
> at
> org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getPath(PDTrueTypeFont.java:498)
>
> {noformat}
> It does not happen with larger fonts, e.g. Arial.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]