pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r908192 - /pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java
Date Tue, 09 Feb 2010 20:08:55 GMT
Author: lehmi
Date: Tue Feb  9 20:08:55 2010
New Revision: 908192

URL: http://svn.apache.org/viewvc?rev=908192&view=rev
Log:
PDFBOX-613: added some missing CFF/Type2 commands. Patch by Villu Ruusmann (villu dot ruusmann
at gmail dot com)

Modified:
    pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java

Modified: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java?rev=908192&r1=908191&r2=908192&view=diff
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java (original)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java Tue
Feb  9 20:08:55 2010
@@ -146,15 +146,48 @@
         }
     }
 
+    @SuppressWarnings(value = { "unchecked" })
     private void handleType2Command(List<Integer> numbers,
             CharStringCommand command)
     {
         String name = CharStringCommand.TYPE2_VOCABULARY.get(command.getKey());
-        if ("hflex".equals(name) || "flex".equals(name)
-                || "hflex1".equals(name) || "flex1".equals(name))
+        if ("hflex".equals(name))
         {
-            throw new UnsupportedOperationException();
-        } 
+            List<Integer> first = Arrays.asList(numbers.get(0), Integer.valueOf(0),

+                    numbers.get(1), numbers.get(2), numbers.get(3), Integer.valueOf(0));
+            List<Integer> second = Arrays.asList(numbers.get(4), Integer.valueOf(0),

+                    numbers.get(5), Integer.valueOf(-numbers.get(2).intValue()), 
+                    numbers.get(6), Integer.valueOf(0));
+            addCommandList(Arrays.asList(first, second), new CharStringCommand(8));
+        } 
+        else if ("flex".equals(name))
+        {
+            List<Integer> first = numbers.subList(0, 6);
+            List<Integer> second = numbers.subList(6, 12);
+            addCommandList(Arrays.asList(first, second), new CharStringCommand(8));
+        }
+        else if ("hflex1".equals(name))
+        {
+            List<Integer> first = Arrays.asList(numbers.get(0), numbers.get(1), 
+                    numbers.get(2), numbers.get(3), numbers.get(4), Integer.valueOf(0));
+            List<Integer> second = Arrays.asList(numbers.get(5), Integer.valueOf(0),
+                    numbers.get(6), numbers.get(7), numbers.get(8), Integer.valueOf(0));
+            addCommandList(Arrays.asList(first, second), new CharStringCommand(8));
+        }
+        else if ("flex1".equals(name))
+        {
+            int dx = 0;
+            int dy = 0;
+            for(int i = 0; i < 5; i++){
+                dx += numbers.get(i * 2).intValue();
+                dy += numbers.get(i * 2 + 1).intValue();
+            }
+            List<Integer> first = numbers.subList(0, 6);
+            List<Integer> second = Arrays.asList(numbers.get(6), numbers.get(7), numbers.get(8),

+                    numbers.get(9), (Math.abs(dx) > Math.abs(dy) ? numbers.get(10) : Integer.valueOf(-dx)),

+                    (Math.abs(dx) > Math.abs(dy) ? Integer.valueOf(-dy) : numbers.get(10)));
+            addCommandList(Arrays.asList(first, second), new CharStringCommand(8));
+        }
         else if ("hstemhm".equals(name))
         {
             numbers = clearStack(numbers, numbers.size() % 2 != 0);



Mime
View raw message