[ https://issues.apache.org/jira/browse/PDFBOX-5904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17903801#comment-17903801 ]
Jxtps edited comment on PDFBOX-5904 at 12/7/24 6:53 AM: -------------------------------------------------------- The class as currently implemented is inconsistent. isPostscript() doesn't just look at the OTTO version (hasPostScriptTag), it also checks for the presence of the tables. This means that I as a user of the class can query isPostscript(), get true for a non-OTTO file, and then get an exception even though there is a CFF table in the file. That seems... weird. So the perspective I'm coming from is "hey, these two very related concepts are being used in a way that makes the class inconsistent, here's how to make it consistent". was (Author: jxtps): The class as currently implemented is inconsistent. `isPostscript()` doesn't just look at the OTTO version (hasPostScriptTag), it also checks for the presence of the tables. This means that I as a user of the class can query isPostscript(), get true for a non-OTTO file, and then get an exception even though there is a CFF table in the file. That seems... weird. So the perspective I'm coming from is "hey, these two very related concepts are being used in a way that makes the class inconsistent, here's how to make it consistent". > Fontbox OpenTypeFont should use isPostScript() internally, not isPostScript > --------------------------------------------------------------------------- > > Key: PDFBOX-5904 > URL: https://issues.apache.org/jira/browse/PDFBOX-5904 > Project: PDFBox > Issue Type: Bug > Components: FontBox > Affects Versions: 3.0.3 PDFBox > Reporter: Jxtps > Assignee: Andreas Lehmkühler > Priority: Major > > OpenTypeFont's isPostScript() is defined as: > {code:java} > public boolean isPostScript() > { > return isPostScript || tables.containsKey(CFFTable.TAG) || > tables.containsKey("CFF2"); > } {code} > See: > https://github.com/apache/pdfbox/blob/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/OpenTypeFont.java > So it checks for the presence of key tables (CFF, CFF2). > However, the getters in the class only checks the private variable > isPostScript, not the method. > This causes buggy font files with the wrong version tag but with a CFF table > to throw exceptions. > To fix: replace the internall references to isPostScript by calls to > isPostScript(). > Workaround: crack open the module and create a custom class in the same > package and have it call setVersion(Float.intBitsToFloat(0x4F54F4F4)), but > that kind of sucks. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org