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 2014/04/25 00:03:56 UTC

svn commit: r1589893 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java

Author: tilman
Date: Thu Apr 24 22:03:55 2014
New Revision: 1589893

URL: http://svn.apache.org/r1589893
Log:
PDFBOX-2044: read Truetype glyphs even if endOfGlyphs entry in table is 0

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1589893&r1=1589892&r2=1589893&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Thu Apr 24 22:03:55 2014
@@ -49,19 +49,23 @@ public class GlyphTable extends TTFTable
         // number of glyphs
         int numGlyphs = maxp.getNumGlyphs();
         // the end of the glyph table
-        long endOfGlyphs = offsets[numGlyphs];
+        // should not be 0, but sometimes is, see PDFBOX-2044
+        // structure of this table: see
+        // https://developer.apple.com/fonts/TTRefMan/RM06/Chap6loca.html
+        long endOfGlyphs = offsets[numGlyphs]; 
         long offset = getOffset();
         glyphs = new GlyphData[numGlyphs];
         for (int i = 0; i < numGlyphs; i++)
         {
             // end of glyphs reached?
-            if (endOfGlyphs == offsets[i])
+            if (endOfGlyphs != 0 &&
+                    endOfGlyphs == offsets[i]) 
             {
                 break;
             }
             // the current glyph isn't defined
-            // if the next offset equals the current index
-            if (offsets[i] == offsets[i + 1])
+            // if the next offset is equal or smaller to the current offset
+            if (offsets[i + 1] <= offsets[i])
             {
                 continue;
             }