pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1607501 - in /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff: CFFFont.java CFFFontROS.java CFFParser.java Type2CharStringParser.java
Date Thu, 03 Jul 2014 00:09:17 GMT
Author: jahewson
Date: Thu Jul  3 00:09:16 2014
New Revision: 1607501

URL: http://svn.apache.org/r1607501
Log:
PDFBOX-2177: store Subrs for each Private dict and use FDSelect for CIDFonts

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java?rev=1607501&r1=1607500&r2=1607501&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java Thu Jul  3 00:09:16
2014
@@ -47,7 +47,6 @@ public class CFFFont implements Type1Cha
     private CFFCharset fontCharset = null;
     private Map<String, byte[]> charStringsDict = new LinkedHashMap<String, byte[]>();
     private IndexData globalSubrIndex = null;
-    private IndexData localSubrIndex = null;
     private Map<String, Type2CharString> charStringCache = new HashMap<String, Type2CharString>();
     private FontMetric fontMetric = null;
     
@@ -431,8 +430,8 @@ public class CFFFont implements Type1Cha
         Type2CharString type2 = charStringCache.get(name);
         if (type2 == null)
         {
-            Type2CharStringParser parser = new Type2CharStringParser();
-            List<Object> type2seq = parser.parse(charStringsDict.get(name), globalSubrIndex,
localSubrIndex);
+            Type2CharStringParser parser = new Type2CharStringParser(fontname, name);
+            List<Object> type2seq = parser.parse(charStringsDict.get(name), globalSubrIndex,
getLocalSubrIndex(sid));
             type2 = new Type2CharString(this, fontname, name, type2seq, getDefaultWidthX(sid),
getNominalWidthX(sid));
             charStringCache.put(name, type2);
         }
@@ -506,19 +505,9 @@ public class CFFFont implements Type1Cha
      * 
      * @return the dictionary
      */
-    public IndexData getLocalSubrIndex()
+    protected IndexData getLocalSubrIndex(int sid)
     {
-        return localSubrIndex;
-    }
-
-    /**
-     * Sets the local subroutine index data.
-     * 
-     * @param localSubrIndexValue the IndexData object containing the local subroutines
-     */
-    public void setLocalSubrIndex(IndexData localSubrIndexValue)
-    {
-        localSubrIndex = localSubrIndexValue;
+        return (IndexData)privateDict.get("Subrs");
     }
 
     public class Mapping implements Type1Mapping

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java?rev=1607501&r1=1607500&r2=1607501&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java Thu Jul  3 00:09:16
2014
@@ -240,4 +240,16 @@ public class CFFFontROS extends CFFFont
         Map<String, Object> privDict = this.privateDictionaries.get(fdArrayIndex);
         return privDict.containsKey("nominalWidthX") ? ((Number)privDict.get("nominalWidthX")).intValue()
: 0;
     }
-}
\ No newline at end of file
+
+    @Override
+    protected IndexData getLocalSubrIndex(int cid)
+    {
+        int fdArrayIndex = this.fdSelect.getFd(cid);
+        if (fdArrayIndex == -1)
+        {
+            return new IndexData(0);
+        }
+        Map<String, Object> privDict = this.privateDictionaries.get(fdArrayIndex);
+        return (IndexData)privDict.get("Subrs");
+    }
+}

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1607501&r1=1607500&r2=1607501&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Thu Jul  3 00:09:16
2014
@@ -47,7 +47,6 @@ import org.apache.fontbox.util.BoundingB
  */
 public class CFFParser
 {
-
     private static final String TAG_OTTO = "OTTO";
     private static final String TAG_TTCF = "ttcf";
     private static final String TAG_TTFONLY = "\u0000\u0001\u0000\u0000";
@@ -509,12 +508,13 @@ public class CFFParser
                 int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
                 if (localSubrOffset == 0)
                 {
-                    font.setLocalSubrIndex(new IndexData(0));
+                    privDict.put("Subrs", new IndexData(0));
                 }
                 else
                 {
                     input.setPosition(privateOffset + localSubrOffset);
-                    font.setLocalSubrIndex(readIndexData(input));
+                    IndexData idx = readIndexData(input);
+                    privDict.put("Subrs", idx);
                 }
 
                 privateDictionaries.add(privDict);
@@ -565,12 +565,14 @@ public class CFFParser
             int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
             if (localSubrOffset == 0)
             {
-                font.setLocalSubrIndex(new IndexData(0));
+                //font.setLocalSubrIndex(new IndexData(0));
+                font.addValueToPrivateDict("Subrs", new IndexData(0));
             }
             else
             {
                 input.setPosition(privateOffset + localSubrOffset);
-                font.setLocalSubrIndex(readIndexData(input));
+                //font.setLocalSubrIndex(readIndexData(input));
+                font.addValueToPrivateDict("Subrs", readIndexData(input));
             }
         }
         return font;

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java?rev=1607501&r1=1607500&r2=1607501&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java Thu
Jul  3 00:09:16 2014
@@ -23,14 +23,25 @@ import java.util.List;
 /**
  * This class represents a converter for a mapping into a Type2-sequence.
  * @author Villu Ruusmann
- * @version $Revision: 1.0 $
  */
 public class Type2CharStringParser
 {
-
     private int hstemCount = 0;
     private int vstemCount = 0;
     private List<Object> sequence = null;
+    private final String fontName, glyphName;
+
+    /**
+     * Constructs a new Type1CharStringParser object.
+     *
+     * @param fontName font name
+     * @param glyphName glyph name
+     */
+    public Type2CharStringParser(String fontName, String glyphName)
+    {
+        this.fontName = fontName;
+        this.glyphName = glyphName;
+    }
 
     /**
      * The given byte array will be parsed and converted to a Type2 sequence.



Mime
View raw message