pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1753719 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
Date Thu, 21 Jul 2016 18:09:19 GMT
Author: tilman
Date: Thu Jul 21 18:09:19 2016
New Revision: 1753719

URL: http://svn.apache.org/viewvc?rev=1753719&view=rev
Log:
PDFBOX-3432: use bit arithmetic instead of modulo, by Michael Doswald

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

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java?rev=1753719&r1=1753718&r2=1753719&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java Thu Jul 21
18:09:19 2016
@@ -354,7 +354,7 @@ public class CmapSubtable
         for (int i = 0; i < entryCount; i++)
         {
             tmpGlyphToChar.put(glyphIdArray[i], firstCode + i);
-            characterCodeToGlyphId.put((firstCode + i), glyphIdArray[i]);
+            characterCodeToGlyphId.put(firstCode + i, glyphIdArray[i]);
         }
         glyphIdToCharacterCode = newGlyphIdToCharacterCode(Collections.max(tmpGlyphToChar.keySet())
+ 1);
         for (Entry<Integer, Integer> entry : tmpGlyphToChar.entrySet())
@@ -401,7 +401,7 @@ public class CmapSubtable
                 {
                     if (rangeOffset == 0)
                     {
-                        int glyphid = (j + delta) % 65536;
+                        int glyphid = (j + delta) & 0xFFFF;
                         tmpGlyphToChar.put(glyphid, j);
                         characterCodeToGlyphId.put(j, glyphid);
                     }
@@ -414,8 +414,7 @@ public class CmapSubtable
                         int glyphIndex = data.readUnsignedShort();
                         if (glyphIndex != 0)
                         {
-                            glyphIndex += delta;
-                            glyphIndex %= 65536;
+                            glyphIndex = (glyphIndex + delta) & 0xFFFF;
                             if (!tmpGlyphToChar.containsKey(glyphIndex))
                             {
                                 tmpGlyphToChar.put(glyphIndex, j);



Mime
View raw message