pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1752459 - in /pdfbox/branches/2.0: fontbox/src/main/java/org/apache/fontbox/ttf/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/
Date Wed, 13 Jul 2016 17:05:12 GMT
Author: tilman
Date: Wed Jul 13 17:05:12 2016
New Revision: 1752459

URL: http://svn.apache.org/viewvc?rev=1752459&view=rev
Log:
PDFBOX-3395: allow missing glyf table

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java?rev=1752459&r1=1752458&r2=1752459&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java Wed Jul
13 17:05:12 2016
@@ -209,11 +209,6 @@ public class TTFParser
             {
                 throw new IOException("loca is mandatory");
             }
-
-            if (font.getGlyph() == null)
-            {
-                throw new IOException("glyf is mandatory");
-            }
         }
 
         if (font.getNaming() == null && !isEmbedded)

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java?rev=1752459&r1=1752458&r2=1752459&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java Wed
Jul 13 17:05:12 2016
@@ -479,6 +479,10 @@ public final class TTFSubsetter
         do
         {
             GlyphTable g = ttf.getGlyph();
+            if (g == null)
+            {
+                throw new IOException("source font " + ttf.getName() + " must have a glyf
table");
+            }
             long[] offsets = ttf.getIndexToLocation().getOffsets();
             InputStream is = ttf.getOriginalData();
             Set<Integer> glyphIdsToAdd = null;
@@ -560,6 +564,10 @@ public final class TTFSubsetter
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
         GlyphTable g = ttf.getGlyph();
+        if (g == null)
+        {
+            throw new IOException("source font " + ttf.getName() + " must have a glyf table");
+        }
         long[] offsets = ttf.getIndexToLocation().getOffsets();
         InputStream is = ttf.getOriginalData();
         try

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java?rev=1752459&r1=1752458&r2=1752459&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
Wed Jul 13 17:05:12 2016
@@ -27,6 +27,7 @@ import org.apache.fontbox.cff.Type2CharS
 import org.apache.fontbox.cmap.CMap;
 import org.apache.fontbox.ttf.CmapSubtable;
 import org.apache.fontbox.ttf.GlyphData;
+import org.apache.fontbox.ttf.GlyphTable;
 import org.apache.fontbox.ttf.OTFParser;
 import org.apache.fontbox.ttf.OpenTypeFont;
 import org.apache.fontbox.ttf.TrueTypeFont;
@@ -438,7 +439,12 @@ public class PDCIDFontType2 extends PDCI
         else
         {
             int gid = codeToGID(code);
-            GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+            GlyphTable glyphTable = ttf.getGlyph();
+            if (glyphTable == null)
+            {
+                return new GeneralPath();
+            }
+            GlyphData glyph = glyphTable.getGlyph(gid);
             if (glyph != null)
             {
                 return glyph.getPath();

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=1752459&r1=1752458&r2=1752459&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
Wed Jul 13 17:05:12 2016
@@ -29,6 +29,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;
@@ -350,7 +351,12 @@ public class PDTrueTypeFont extends PDSi
     public float getHeight(int code) throws IOException
     {
         int gid = codeToGID(code);
-        GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+        GlyphTable glyphTable = ttf.getGlyph();
+        if (glyphTable == null)
+        {
+            return 0;
+        }
+        GlyphData glyph = glyphTable.getGlyph(gid);
         if (glyph != null)
         {
             return glyph.getBoundingBox().getHeight();
@@ -442,7 +448,12 @@ 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)
+        {
+            return new GeneralPath();
+        }
+        GlyphData glyph = glyphTable.getGlyph(gid);
         
         // some glyphs have no outlines (e.g. space, table, newline)
         if (glyph == null)
@@ -482,7 +493,12 @@ public class PDTrueTypeFont extends PDSi
             return new GeneralPath();
         }
         
-        GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+        GlyphTable glyphTable = ttf.getGlyph();
+        if (glyphTable == null)
+        {
+            return new GeneralPath();
+        }
+        GlyphData glyph = glyphTable.getGlyph(gid);
         if (glyph != null)
         {
             return glyph.getPath();



Mime
View raw message