pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1615977 - in /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff: CharStringCommand.java Type1CharString.java Type2CharString.java
Date Tue, 05 Aug 2014 18:51:50 GMT
Author: jahewson
Date: Tue Aug  5 18:51:50 2014
New Revision: 1615977

URL: http://svn.apache.org/r1615977
Log:
PDFBOX-2244: Improved debugging messages

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java?rev=1615977&r1=1615976&r2=1615977&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CharStringCommand.java Tue Aug
 5 18:51:50 2014
@@ -82,7 +82,19 @@ public class CharStringCommand
      */
     public String toString()
     {
-        return getKey().toString();
+        String str = TYPE2_VOCABULARY.get(getKey());
+        if (str == null)
+        {
+            str = TYPE1_VOCABULARY.get(getKey());
+        }
+        if (str == null)
+        {
+            return getKey().toString() + '|';
+        }
+        else
+        {
+            return str + '|';
+        }
     }
 
     /**

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java?rev=1615977&r1=1615976&r2=1615977&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java Tue Aug
 5 18:51:50 2014
@@ -49,13 +49,15 @@ public class Type1CharString
     private boolean isFlex = false;
     private List<Point.Float> flexPoints = new ArrayList<Point2D.Float>();
     protected List<Object> type1Sequence;
+    protected int commandCount;
 
     /**
      * Constructs a new Type1CharString object.
      * @param reader Parent Type 1 CharString reader
      * @param sequence Type 1 char string sequence
      */
-    public Type1CharString(Type1CharStringReader reader, String fontName, String glyphName,
List<Object> sequence)
+    public Type1CharString(Type1CharStringReader reader, String fontName, String glyphName,
+                           List<Object> sequence)
     {
         this(reader, fontName, glyphName);
         type1Sequence = sequence;
@@ -140,6 +142,7 @@ public class Type1CharString
 
     private List<Integer> handleCommand(List<Integer> numbers, CharStringCommand
command)
     {
+        commandCount++;
         String name = CharStringCommand.TYPE1_VOCABULARY.get(command.getKey());
 
         if ("rmoveto".equals(name))
@@ -287,9 +290,17 @@ public class Type1CharString
             // end flex
             isFlex = false;
 
+            if (flexPoints.size() < 7)
+            {
+                LOG.warn("flex without moveTo in font " + fontName + ", glyph " + glyphName
+
+                         ", command " + commandCount);
+                return;
+            }
+
             // reference point is relative to start point
             Point.Float reference = flexPoints.get(0);
-            reference.setLocation(current.getX() + reference.getX(), current.getY() + reference.getY());
+            reference.setLocation(current.getX() + reference.getX(),
+                                  current.getY() + reference.getY());
 
             // first point is relative to reference point
             Point.Float first = flexPoints.get(1);
@@ -299,12 +310,12 @@ public class Type1CharString
             first.setLocation(first.getX() - current.getX(), first.getY() - current.getY());
 
             rrcurveTo(flexPoints.get(1).getX(), flexPoints.get(1).getY(),
-                    flexPoints.get(2).getX(), flexPoints.get(2).getY(),
-                    flexPoints.get(3).getX(), flexPoints.get(3).getY());
+                      flexPoints.get(2).getX(), flexPoints.get(2).getY(),
+                      flexPoints.get(3).getX(), flexPoints.get(3).getY());
 
             rrcurveTo(flexPoints.get(4).getX(), flexPoints.get(4).getY(),
-                    flexPoints.get(5).getX(), flexPoints.get(5).getY(),
-                    flexPoints.get(6).getX(), flexPoints.get(6).getY());
+                      flexPoints.get(5).getX(), flexPoints.get(5).getY(),
+                      flexPoints.get(6).getX(), flexPoints.get(6).getY());
 
             flexPoints.clear();
         }
@@ -429,4 +440,10 @@ public class Type1CharString
             }
         }
     }
+
+    @Override
+    public String toString()
+    {
+        return type1Sequence.toString().replace("|","\n").replace(",", " ");
+    }
 }
\ No newline at end of file

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java?rev=1615977&r1=1615976&r2=1615977&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java Tue Aug
 5 18:51:50 2014
@@ -101,6 +101,7 @@ public class Type2CharString extends Typ
     @SuppressWarnings(value = { "unchecked" })
     private List<Integer> handleCommand(List<Integer> numbers, CharStringCommand
command)
     {
+        commandCount++;
         String name = CharStringCommand.TYPE2_VOCABULARY.get(command.getKey());
 
         if ("hstem".equals(name))



Mime
View raw message