You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (Jira)" <ji...@apache.org> on 2022/08/05 05:52:00 UTC
[jira] [Commented] (PDFBOX-5486) "RandomAccessBuffer already closed" when opening smaller fonts
[ https://issues.apache.org/jira/browse/PDFBOX-5486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17575591#comment-17575591 ]
Andreas Lehmkühler commented on PDFBOX-5486:
--------------------------------------------
I'm pretty sure it is related. I'm going to have a look
> "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
>
> I wonder if this is related to one of the memory management / inputstream changes, PDTrueTypeFont.load() can't load smaller ttf fonts:
> {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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org