pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1818300 - /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
Date Fri, 15 Dec 2017 16:28:46 GMT
Author: tilman
Date: Fri Dec 15 16:28:46 2017
New Revision: 1818300

URL: http://svn.apache.org/viewvc?rev=1818300&view=rev
Log:
PDFBOX-4038: read BlueValues and other delta encoded lists correctly

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1818300&r1=1818299&r2=1818300&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Fri Dec
15 16:28:46 2017
@@ -648,17 +648,17 @@ public class CFFParser
     private Map<String, Object> readPrivateDict(DictData privateDict)
     {
         Map<String, Object> privDict = new LinkedHashMap<String, Object>(17);
-        privDict.put("BlueValues", privateDict.getArray("BlueValues", null));
-        privDict.put("OtherBlues", privateDict.getArray("OtherBlues", null));
-        privDict.put("FamilyBlues", privateDict.getArray("FamilyBlues", null));
-        privDict.put("FamilyOtherBlues", privateDict.getArray("FamilyOtherBlues", null));
+        privDict.put("BlueValues", privateDict.getDelta("BlueValues", null));
+        privDict.put("OtherBlues", privateDict.getDelta("OtherBlues", null));
+        privDict.put("FamilyBlues", privateDict.getDelta("FamilyBlues", null));
+        privDict.put("FamilyOtherBlues", privateDict.getDelta("FamilyOtherBlues", null));
         privDict.put("BlueScale", privateDict.getNumber("BlueScale", 0.039625));
         privDict.put("BlueShift", privateDict.getNumber("BlueShift", 7));
         privDict.put("BlueFuzz", privateDict.getNumber("BlueFuzz", 1));
         privDict.put("StdHW", privateDict.getNumber("StdHW", null));
         privDict.put("StdVW", privateDict.getNumber("StdVW", null));
-        privDict.put("StemSnapH", privateDict.getArray("StemSnapH", null));
-        privDict.put("StemSnapV", privateDict.getArray("StemSnapV", null));
+        privDict.put("StemSnapH", privateDict.getDelta("StemSnapH", null));
+        privDict.put("StemSnapV", privateDict.getDelta("StemSnapV", null));
         privDict.put("ForceBold", privateDict.getBoolean("ForceBold", false));
         privDict.put("LanguageGroup", privateDict.getNumber("LanguageGroup", 0));
         privDict.put("ExpansionFactor", privateDict.getNumber("ExpansionFactor", 0.06));
@@ -1168,6 +1168,12 @@ public class CFFParser
             return entry != null && entry.getArray().size() > 0 ? entry.getNumber(0)
: defaultValue;
         }
 
+        public List<Number> getDelta(String name, List<Number> defaultValue)

+        {
+            Entry entry = getEntry(name);
+            return entry != null && entry.getDelta().size() > 0 ? entry.getDelta()
: defaultValue;
+        }
+
         /**
          * {@inheritDoc} 
          */
@@ -1213,6 +1219,19 @@ public class CFFParser
                 return operands;
             }
 
+            public List<Number> getDelta()
+            {
+                List<Number> result = new ArrayList<Number>(operands);
+                for (int i = 1; i < result.size(); i++)
+                {
+                    Number previous = result.get(i - 1);
+                    Number current = result.get(i);
+                    Integer sum = previous.intValue() + current.intValue();
+                    result.set(i, sum);
+                }
+                return result;
+            }
+
             @Override
             public String toString()
             {



Mime
View raw message