You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2023/04/13 18:20:28 UTC
svn commit: r1909122 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
Author: tilman
Date: Thu Apr 13 18:20:28 2023
New Revision: 1909122
URL: http://svn.apache.org/viewvc?rev=1909122&view=rev
Log:
PDFBOX-5587: avoid NullPointerException if glyf table is missing
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java?rev=1909122&r1=1909121&r2=1909122&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java Thu Apr 13 18:20:28 2023
@@ -28,6 +28,7 @@ import org.apache.fontbox.FontBoxFont;
import org.apache.fontbox.ttf.CmapSubtable;
import org.apache.fontbox.ttf.CmapTable;
import org.apache.fontbox.ttf.GlyphData;
+import org.apache.fontbox.ttf.GlyphTable;
import org.apache.fontbox.ttf.PostScriptTable;
import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
@@ -470,7 +471,14 @@ public class PDTrueTypeFont extends PDSi
public GeneralPath getPath(int code) throws IOException
{
int gid = codeToGID(code);
- GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+ GlyphTable glyphTable = ttf.getGlyph();
+ if (glyphTable == null)
+ {
+ // needs to be caught earlier, see PDFBOX-5587 and PDFBOX-3488
+ throw new IOException("glyf table is missing in font " + getName() +
+ ", please report this file");
+ }
+ GlyphData glyph = glyphTable.getGlyph(gid);
// some glyphs have no outlines (e.g. space, table, newline)
if (glyph == null)