pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1747911 - /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
Date Sat, 11 Jun 2016 16:34:39 GMT
Author: tilman
Date: Sat Jun 11 16:34:39 2016
New Revision: 1747911

URL: http://svn.apache.org/viewvc?rev=1747911&view=rev
Log:
PDFBOX-3379: correct handling of partially monospaced fonts, increase hmetrics only when last
gid wasn't already part of the set

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java

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=1747911&r1=1747910&r2=1747911&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 Sat
Jun 11 16:34:39 2016
@@ -250,9 +250,10 @@ public final class TTFSubsetter
         writeSInt16(out, h.getReserved5());
         writeSInt16(out, h.getMetricDataFormat());
 
-        // is there a GID >= numberOfHMetrics ? Then keep the last entry of original hmtx
table
+        // is there a GID >= numberOfHMetrics ? Then keep the last entry of original hmtx
table,
+        // (add if it isn't in our set of GIDs), see also in buildHmtxTable()
         int hmetrics = glyphIds.subSet(0, h.getNumberOfHMetrics()).size();
-        if (glyphIds.last() >= h.getNumberOfHMetrics())
+        if (glyphIds.last() >= h.getNumberOfHMetrics() && !glyphIds.contains(h.getNumberOfHMetrics()-1))
         {
             ++hmetrics;
         }
@@ -873,12 +874,14 @@ public final class TTFSubsetter
         InputStream is = ttf.getOriginalData();
         
         // is there a GID >= numberOfHMetrics ? Then keep the last entry of original hmtx
table
+        // add it if it isn't in the set
+        int lastgid = h.getNumberOfHMetrics() - 1;
         SortedSet<Integer> gidSet = glyphIds;
-        if (glyphIds.last() >= h.getNumberOfHMetrics())
+        if (glyphIds.last() > lastgid && !glyphIds.contains(lastgid))
         {
-            // Create a deep copy of the glyph set that has the last entry
+            // Create a deep copy of the glyph set and add the last entry
             gidSet = new TreeSet<Integer>(glyphIds);
-            gidSet.add(ttf.getHorizontalHeader().getNumberOfHMetrics() - 1);
+            gidSet.add(lastgid);
         }
         
         try



Mime
View raw message