[ https://issues.apache.org/jira/browse/PDFBOX-5123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17297695#comment-17297695 ]
Gábor Stefanik commented on PDFBOX-5123: ---------------------------------------- Yes, versions 1, 2 and 5 are the ones that introduce new fields. (5 seems to be unsupported in PDFBox.) Also related to PDFBOX-5124, as warned in that specification, there is actually an early variant of version 0 in circulation, "version -1" if you wish, that ends at usLastCharIndex (so 5 fields shorter than the canonical version 0). So, it would be wise to also treat those 5 fields as optional. > OS2WindowsMetricsTable "version" variable confused with OpenType > specification version > -------------------------------------------------------------------------------------- > > Key: PDFBOX-5123 > URL: https://issues.apache.org/jira/browse/PDFBOX-5123 > Project: PDFBox > Issue Type: Bug > Components: FontBox > Affects Versions: 2.0.22 > Reporter: Gábor Stefanik > Priority: Minor > Attachments: > SZAMLA-20190417-20190012706-ININET-BroadBitHungary-11646-HUF.pdf > > > OS2WindowsMetricsTable contains the following code: > {code:java} > /** > * This will read the required data from the stream. > * > * @param ttf The font that is being read. > * @param data The stream to read the data from. > * @throws IOException If there is an error reading the data. > */ > @Override > void read(TrueTypeFont ttf, TTFDataStream data) throws IOException > { > version = data.readUnsignedShort(); > averageCharWidth = data.readSignedShort(); > weightClass = data.readUnsignedShort(); > widthClass = data.readUnsignedShort(); > fsType = data.readSignedShort(); > subscriptXSize = data.readSignedShort(); > subscriptYSize = data.readSignedShort(); > subscriptXOffset = data.readSignedShort(); > subscriptYOffset = data.readSignedShort(); > superscriptXSize = data.readSignedShort(); > superscriptYSize = data.readSignedShort(); > superscriptXOffset = data.readSignedShort(); > superscriptYOffset = data.readSignedShort(); > strikeoutSize = data.readSignedShort(); > strikeoutPosition = data.readSignedShort(); > familyClass = data.readSignedShort(); > panose = data.read(10); > unicodeRange1 = data.readUnsignedInt(); > unicodeRange2 = data.readUnsignedInt(); > unicodeRange3 = data.readUnsignedInt(); > unicodeRange4 = data.readUnsignedInt(); > achVendId = data.readString(4); > fsSelection = data.readUnsignedShort(); > firstCharIndex = data.readUnsignedShort(); > lastCharIndex = data.readUnsignedShort(); > typoAscender = data.readSignedShort(); > typoDescender = data.readSignedShort(); > typoLineGap = data.readSignedShort(); > winAscent = data.readUnsignedShort(); > winDescent = data.readUnsignedShort(); > if (version >= 1) > { > codePageRange1 = data.readUnsignedInt(); > codePageRange2 = data.readUnsignedInt(); > } > if (version >= 1.2) > { > sxHeight = data.readSignedShort(); > sCapHeight = data.readSignedShort(); > usDefaultChar = data.readUnsignedShort(); > usBreakChar = data.readUnsignedShort(); > usMaxContext = data.readUnsignedShort(); > } > initialized = true; > } > {code} > Here, "version" is an integer, local to this class, which is supposed to > represent the version number of the metrics table itself (not the whole > font). In the case of the first font in the attached PDF, this has a value of > 3. (Note that this PDF is itself buggy, declaring a table version of 3 for > what's clearly a version 0 table, but that's PDFBOX-5124.) > However, at the end of the code, this is seemingly confused with the font > version number, and is compared against the float value 1.2. Java allows > comparison between int and float, so no compile-time error or warning is > raised. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org