pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r907461 [2/3] - in /pdfbox/fontbox/trunk/src: main/java/org/apache/fontbox/cff/ main/java/org/apache/fontbox/cff/charset/ main/java/org/apache/fontbox/cff/encoding/ test/java/org/apache/fontbox/cff/
Date Sun, 07 Feb 2010 18:09:21 GMT
Added: 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=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringConverter.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,340 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A class to convert for a sequence of Type1/Type2 commands into a sequence of CharStringCommands.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class CharStringConverter extends CharStringHandler
+{
+
+    private int defaultWidthX = 0;
+    private int nominalWidthX = 0;
+    private List<Object> sequence = null;
+    private int pathCount = 0;
+
+    /**
+     * Constructor.
+     * 
+     * @param defaultWidth default width
+     * @param nominalWidth nominal width
+     */
+    public CharStringConverter(int defaultWidth, int nominalWidth)
+    {
+        defaultWidthX = defaultWidth;
+        nominalWidthX = nominalWidth;
+    }
+
+    /**
+     * Converts a sequence of Type1/Type2 commands into a sequence of CharStringCommands.
+     * @param commandSequence the type1/type2 sequence
+     * @return the CHarStringCommandSequence
+     */
+    public List<Object> convert(List<Object> commandSequence)
+    {
+        sequence = new ArrayList<Object>();
+        pathCount = 0;
+        handleSequence(commandSequence);
+        return sequence;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void handleCommand(List<Integer> numbers, CharStringCommand command)
+    {
+
+        if (CharStringCommand.TYPE1_VOCABULARY.containsKey(command.getKey()))
+        {
+            handleType1Command(numbers, command);
+        } 
+        else
+        {
+            handleType2Command(numbers, command);
+        }
+    }
+
+    private void handleType1Command(List<Integer> numbers,
+            CharStringCommand command)
+    {
+        String name = CharStringCommand.TYPE1_VOCABULARY.get(command.getKey());
+
+        if ("hstem".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() % 2 != 0);
+            expandStemHints(numbers, true);
+        } 
+        else if ("vstem".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() % 2 != 0);
+            expandStemHints(numbers, false);
+        } 
+        else if ("vmoveto".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() > 1);
+            markPath();
+            addCommand(numbers, command);
+        } 
+        else if ("rlineto".equals(name))
+        {
+            addCommandList(split(numbers, 2), command);
+        } 
+        else if ("hlineto".equals(name))
+        {
+            drawAlternatingLine(numbers, true);
+        } 
+        else if ("vlineto".equals(name))
+        {
+            drawAlternatingLine(numbers, false);
+        } 
+        else if ("rrcurveto".equals(name))
+        {
+            addCommandList(split(numbers, 6), command);
+        } 
+        else if ("endchar".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() > 0);
+            closePath();
+            addCommand(numbers, command);
+        } 
+        else if ("rmoveto".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() > 2);
+            markPath();
+            addCommand(numbers, command);
+        } 
+        else if ("hmoveto".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() > 1);
+            markPath();
+            addCommand(numbers, command);
+        } 
+        else if ("vhcurveto".equals(name))
+        {
+            drawAlternatingCurve(numbers, false);
+        } 
+        else if ("hvcurveto".equals(name))
+        {
+            drawAlternatingCurve(numbers, true);
+        } 
+        else
+        {
+            addCommand(numbers, command);
+        }
+    }
+
+    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))
+        {
+            throw new UnsupportedOperationException();
+        } 
+        else if ("hstemhm".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() % 2 != 0);
+            expandStemHints(numbers, true);
+        } 
+        else if ("hintmask".equals(name) || "cntrmask".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() % 2 != 0);
+            if (numbers.size() > 0)
+            {
+                expandStemHints(numbers, false);
+            }
+        } 
+        else if ("vstemhm".equals(name))
+        {
+            numbers = clearStack(numbers, numbers.size() % 2 != 0);
+            expandStemHints(numbers, false);
+        } 
+        else if ("rcurveline".equals(name))
+        {
+            addCommandList(split(numbers.subList(0, numbers.size() - 2), 6),
+                    new CharStringCommand(8));
+            addCommand(numbers.subList(numbers.size() - 2, numbers.size()),
+                    new CharStringCommand(5));
+        } 
+        else if ("rlinecurve".equals(name))
+        {
+            addCommandList(split(numbers.subList(0, numbers.size() - 6), 2),
+                    new CharStringCommand(5));
+            addCommand(numbers.subList(numbers.size() - 6, numbers.size()),
+                    new CharStringCommand(8));
+        } 
+        else if ("vvcurveto".equals(name))
+        {
+            drawCurve(numbers, false);
+        } 
+        else if ("hhcurveto".equals(name))
+        {
+            drawCurve(numbers, true);
+        } 
+        else
+        {
+            // System.out.println("Not implemented: numbers=" + numbers +
+            // " command=" +command+ " (" +name+ ")");
+        }
+    }
+
+    private List<Integer> clearStack(List<Integer> numbers, boolean flag)
+    {
+
+        if (sequence.size() == 0)
+        {
+            if (flag)
+            {
+                addCommand(Arrays.asList(Integer.valueOf(0), Integer
+                        .valueOf(numbers.get(0).intValue() + nominalWidthX)),
+                        new CharStringCommand(13));
+
+                numbers = numbers.subList(1, numbers.size());
+            } 
+            else
+            {
+                addCommand(Arrays.asList(Integer.valueOf(0), Integer
+                        .valueOf(defaultWidthX)), new CharStringCommand(13));
+            }
+        }
+
+        return numbers;
+    }
+
+    private void expandStemHints(List<Integer> numbers, boolean horizontal)
+    {
+        // TODO
+    }
+
+    private void markPath()
+    {
+        if (pathCount > 0)
+        {
+            closePath();
+        }
+        pathCount++;
+    }
+
+    private void closePath()
+    {
+        CharStringCommand command = pathCount > 0 ? (CharStringCommand) sequence
+                .get(sequence.size() - 1)
+                : null;
+
+        CharStringCommand closepathCommand = new CharStringCommand(9);
+        if (command != null && !closepathCommand.equals(command))
+        {
+            addCommand(Collections.<Integer> emptyList(), closepathCommand);
+        }
+    }
+
+    private void drawAlternatingLine(List<Integer> numbers, boolean horizontal)
+    {
+        while (numbers.size() > 0)
+        {
+            addCommand(numbers.subList(0, 1), new CharStringCommand(
+                    horizontal ? 6 : 7));
+            numbers = numbers.subList(1, numbers.size());
+            horizontal = !horizontal;
+        }
+    }
+
+    private void drawAlternatingCurve(List<Integer> numbers, boolean horizontal)
+    {
+        while (numbers.size() > 0)
+        {
+            boolean last = numbers.size() == 5;
+            if (horizontal)
+            {
+                addCommand(Arrays.asList(numbers.get(0), Integer.valueOf(0),
+                        numbers.get(1), numbers.get(2), last ? numbers.get(4)
+                                : Integer.valueOf(0), numbers.get(3)),
+                        new CharStringCommand(8));
+            } 
+            else
+            {
+                addCommand(Arrays.asList(Integer.valueOf(0), numbers.get(0),
+                        numbers.get(1), numbers.get(2), numbers.get(3),
+                        last ? numbers.get(4) : Integer.valueOf(0)),
+                        new CharStringCommand(8));
+            }
+            numbers = numbers.subList(last ? 5 : 4, numbers.size());
+            horizontal = !horizontal;
+        }
+    }
+
+    private void drawCurve(List<Integer> numbers, boolean horizontal)
+    {
+        while (numbers.size() > 0)
+        {
+            boolean first = numbers.size() % 4 == 1;
+
+            if (horizontal)
+            {
+                addCommand(Arrays.asList(numbers.get(first ? 1 : 0),
+                        first ? numbers.get(0) : Integer.valueOf(0), numbers
+                                .get(first ? 2 : 1),
+                        numbers.get(first ? 3 : 2), numbers.get(first ? 4 : 3),
+                        Integer.valueOf(0)), new CharStringCommand(8));
+            } 
+            else
+            {
+                addCommand(Arrays.asList(first ? numbers.get(0) : Integer
+                        .valueOf(0), numbers.get(first ? 1 : 0), numbers
+                        .get(first ? 2 : 1), numbers.get(first ? 3 : 2),
+                        Integer.valueOf(0), numbers.get(first ? 4 : 3)),
+                        new CharStringCommand(8));
+            }
+            numbers = numbers.subList(first ? 5 : 4, numbers.size());
+        }
+    }
+
+    private void addCommandList(List<List<Integer>> numbers,
+            CharStringCommand command)
+    {
+        for (int i = 0; i < numbers.size(); i++)
+        {
+            addCommand(numbers.get(i), command);
+        }
+    }
+
+    private void addCommand(List<Integer> numbers, CharStringCommand command)
+    {
+        sequence.addAll(numbers);
+        sequence.add(command);
+    }
+
+    private static <E> List<List<E>> split(List<E> list, int size)
+    {
+        List<List<E>> result = new ArrayList<List<E>>();
+        for (int i = 0; i < list.size() / size; i++)
+        {
+            result.add(list.subList(i * size, (i + 1) * size));
+        }
+        return result;
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringHandler.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringHandler.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringHandler.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.util.List;
+
+/**
+ * A Handler for CharStringCommands.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public abstract class CharStringHandler
+{
+
+    /**
+     * Handler for a sequence of CharStringCommands.
+     * 
+     * @param sequence of CharStringCommands
+     */
+    @SuppressWarnings(value = { "unchecked" })
+    public void handleSequence(List<Object> sequence)
+    {
+        int offset = 0;
+        for (int i = 0; i < sequence.size(); i++)
+        {
+            Object object = sequence.get(i);
+            if (object instanceof CharStringCommand)
+            {
+                List<Integer> numbers = (List) sequence.subList(offset, i);
+                CharStringCommand command = (CharStringCommand) object;
+                handleCommand(numbers, command);
+                offset = i + 1;
+            }
+        }
+    }
+    /**
+     * Handler for CharStringCommands.
+     *  
+     * @param numbers a list of numbers
+     * @param command the CharStringCommand
+     */
+    public abstract void handleCommand(List<Integer> numbers, CharStringCommand command);
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringRenderer.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringRenderer.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/CharStringRenderer.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.List;
+
+/**
+ * This class represents a renderer for a charstring.
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class CharStringRenderer extends CharStringHandler
+{
+
+    private GeneralPath path = null;
+    private Point2D sidebearingPoint = null;
+    private Point2D referencePoint = null;
+    private int width = 0;
+
+    /**
+     * Renders the given sequence and returns the result as a GeneralPath.
+     * @param sequence the given charstring sequence
+     * @return the rendered GeneralPath 
+     */
+    public GeneralPath render(List<Object> sequence)
+    {
+        path = new GeneralPath();
+        sidebearingPoint = new Point2D.Float(0, 0);
+        referencePoint = null;
+        setWidth(0);
+        handleSequence(sequence);
+        return path;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleCommand(List<Integer> numbers, CharStringCommand command)
+    {
+        String name = CharStringCommand.TYPE1_VOCABULARY.get(command.getKey());
+
+        if ("vmoveto".equals(name))
+        {
+            rmoveTo(Integer.valueOf(0), numbers.get(0));
+        } 
+        else if ("rlineto".equals(name))
+        {
+            rlineTo(numbers.get(0), numbers.get(1));
+        } 
+        else if ("hlineto".equals(name))
+        {
+            rlineTo(numbers.get(0), Integer.valueOf(0));
+        } 
+        else if ("vlineto".equals(name))
+        {
+            rlineTo(Integer.valueOf(0), numbers.get(0));
+        } 
+        else if ("rrcurveto".equals(name))
+        {
+            rrcurveTo(numbers.get(0), numbers.get(1), numbers.get(2), numbers
+                    .get(3), numbers.get(4), numbers.get(5));
+        } 
+        else if ("closepath".equals(name))
+        {
+            closePath();
+        } 
+        else if ("sbw".equals(name))
+        {
+            pointSb(numbers.get(0), numbers.get(1));
+            setWidth(numbers.get(2).intValue());
+        } 
+        else if ("hsbw".equals(name))
+        {
+            pointSb(numbers.get(0), Integer.valueOf(0));
+            setWidth(numbers.get(1).intValue());
+        } 
+        else if ("rmoveto".equals(name))
+        {
+            rmoveTo(numbers.get(0), numbers.get(1));
+        } 
+        else if ("hmoveto".equals(name))
+        {
+            rmoveTo(numbers.get(0), Integer.valueOf(0));
+        } 
+        else if ("vhcurveto".equals(name))
+        {
+            rrcurveTo(Integer.valueOf(0), numbers.get(0), numbers.get(1),
+                    numbers.get(2), numbers.get(3), Integer.valueOf(0));
+        } 
+        else if ("hvcurveto".equals(name))
+        {
+            rrcurveTo(numbers.get(0), Integer.valueOf(0), numbers.get(1),
+                    numbers.get(2), Integer.valueOf(0), numbers.get(3));
+        }
+    }
+
+    private void rmoveTo(Number dx, Number dy)
+    {
+        Point2D point = referencePoint;
+        if (point == null)
+        {
+            point = sidebearingPoint;
+        }
+        referencePoint = null;
+        path.moveTo(point.getX() + dx.floatValue(), point.getY()
+                + dy.floatValue());
+    }
+
+    private void rlineTo(Number dx, Number dy)
+    {
+        Point2D point = path.getCurrentPoint();
+        path.lineTo(point.getX() + dx.floatValue(), point.getY()
+                + dy.floatValue());
+    }
+
+    private void rrcurveTo(Number dx1, Number dy1, Number dx2, Number dy2,
+            Number dx3, Number dy3)
+    {
+        Point2D point = path.getCurrentPoint();
+        float x1 = (float) point.getX() + dx1.floatValue();
+        float y1 = (float) point.getY() + dy1.floatValue();
+        float x2 = x1 + dx2.floatValue();
+        float y2 = y1 + dy2.floatValue();
+        float x3 = x2 + dx3.floatValue();
+        float y3 = y2 + dy3.floatValue();
+        path.curveTo(x1, y1, x2, y2, x3, y3);
+    }
+
+    private void closePath()
+    {
+        referencePoint = path.getCurrentPoint();
+        path.closePath();
+    }
+
+    private void pointSb(Number x, Number y)
+    {
+        sidebearingPoint = new Point2D.Float(x.floatValue(), y.floatValue());
+    }
+
+    /**
+     * Returns the bounds of the renderer path.
+     * @return the bounds as Rectangle2D
+     */
+    public Rectangle2D getBounds()
+    {
+        return path.getBounds2D();
+    }
+
+    /**
+     * Returns the width of the current command.
+     * @return the width
+     */
+    public int getWidth()
+    {
+        return width;
+    }
+
+    private void setWidth(int width)
+    {
+        this.width = width;
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataInput.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataInput.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataInput.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataInput.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.EOFException;
+import java.io.IOException;
+
+/**
+ * This class contains some functionality to read a byte buffer.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class DataInput
+{
+
+    private byte[] inputBuffer = null;
+    private int bufferPosition = 0;
+
+    /**
+     * Constructor.
+     * @param buffer the buffer to be read
+     */
+    public DataInput(byte[] buffer)
+    {
+        inputBuffer = buffer;
+    }
+
+    /**
+     * Determines if there are any bytes left to read or not. 
+     * @return true if there are any bytes left to read
+     */
+    public boolean hasRemaining()
+    {
+        return bufferPosition < inputBuffer.length;
+    }
+
+    /**
+     * Returns the current position.
+     * @return current position
+     */
+    public int getPosition()
+    {
+        return bufferPosition;
+    }
+
+    /**
+     * Sets the current position to the given value.
+     * @param position the given position
+     */
+    public void setPosition(int position)
+    {
+        bufferPosition = position;
+    }
+
+    /** 
+     * Returns the buffer as an ISO-8859-1 string.
+     * @return the buffer as string
+     * @throws IOException if an error occurs during reading
+     */
+    public String getString() throws IOException
+    {
+        return new String(inputBuffer, "ISO-8859-1");
+    }
+
+    /**
+     * Read one single byte from the buffer.
+     * @return the byte
+     * @throws IOException if an error occurs during reading
+     */
+    public byte readByte() throws IOException
+    {
+        return (byte) readUnsignedByte();
+    }
+
+    /**
+     * Read one single unsigned byte from the buffer.
+     * @return the unsigned byte as int
+     * @throws IOException if an error occurs during reading
+     */
+    public int readUnsignedByte() throws IOException
+    {
+        int b = read();
+        if (b < 0)
+        {
+            throw new EOFException();
+        }
+        return b;
+    }
+
+    /**
+     * Read one single short value from the buffer.
+     * @return the short value
+     * @throws IOException if an error occurs during reading
+     */
+    public short readShort() throws IOException
+    {
+        return (short) readUnsignedShort();
+    }
+
+    /**
+     * Read one single unsigned short (2 bytes) value from the buffer.
+     * @return the unsigned short value as int
+     * @throws IOException if an error occurs during reading
+     */
+    public int readUnsignedShort() throws IOException
+    {
+        int b1 = read();
+        int b2 = read();
+        if ((b1 | b2) < 0)
+        {
+            throw new EOFException();
+        }
+        return b1 << 8 | b2;
+    }
+
+    /**
+     * Read one single int (4 bytes) from the buffer.
+     * @return the int value
+     * @throws IOException if an error occurs during reading
+     */
+    public int readInt() throws IOException
+    {
+        int b1 = read();
+        int b2 = read();
+        int b3 = read();
+        int b4 = read();
+        if ((b1 | b2 | b3 | b4) < 0)
+        {
+            throw new EOFException();
+        }
+        return b1 << 24 | b2 << 16 | b3 << 8 | b4;
+    }
+
+    /**
+     * Read a number of single byte values from the buffer.
+     * @param length the number of bytes to be read
+     * @return an array with containing the bytes from the buffer 
+     * @throws IOException if an error occurs during reading
+     */
+    public byte[] readBytes(int length) throws IOException
+    {
+        byte[] bytes = new byte[length];
+        for (int i = 0; i < length; i++)
+        {
+            bytes[i] = readByte();
+        }
+        return bytes;
+    }
+
+    private int read()
+    {
+        try
+        {
+            int value = inputBuffer[bufferPosition] & 0xff;
+            bufferPosition++;
+            return value;
+        } 
+        catch (RuntimeException re)
+        {
+            return -1;
+        }
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataOutput.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataOutput.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataOutput.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/DataOutput.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * 
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class DataOutput
+{
+
+    private ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
+
+    private String outputEncoding = null;
+
+    /**
+     * Constructor.
+     */
+    public DataOutput()
+    {
+        this("ISO-8859-1");
+    }
+
+    /**
+     * Constructor with a given encoding.
+     * @param encoding the encoding to be used for writing
+     */
+    public DataOutput(String encoding)
+    {
+        this.outputEncoding = encoding;
+    }
+
+    /**
+     * Returns the written data buffer as byte array.
+     * @return the data buffer as byte array
+     */
+    public byte[] getBytes()
+    {
+        return outputBuffer.toByteArray();
+    }
+
+    /**
+     * Write an int value to the buffer.
+     * @param value the given value
+     */
+    public void write(int value)
+    {
+        outputBuffer.write(value);
+    }
+
+    /**
+     * Write a byte array to the buffer.
+     * @param buffer the given byte array
+     */
+    public void write(byte[] buffer)
+    {
+        outputBuffer.write(buffer, 0, buffer.length);
+    }
+
+    /**
+     * Write a part of a byte array to the buffer.
+     * @param buffer the given byte buffer
+     * @param offset the offset where to start 
+     * @param length the amount of bytes to be written from the array
+     */
+    public void write(byte[] buffer, int offset, int length)
+    {
+        outputBuffer.write(buffer, offset, length);
+    }
+
+    /**
+     * Write the given string to the buffer using the given encoding.
+     * @param string the given string
+     * @throws IOException If an error occurs during writing the data to the buffer
+     */
+    public void print(String string) throws IOException
+    {
+        write(string.getBytes(outputEncoding));
+    }
+
+    /**
+     * Write the given string to the buffer using the given encoding.
+     * A newline is added after the given string
+     * @param string the given string
+     * @throws IOException If an error occurs during writing the data to the buffer
+     */
+    public void println(String string) throws IOException
+    {
+        write(string.getBytes(outputEncoding));
+        write('\n');
+    }
+
+    /**
+     * Add a newline to the given string.
+     */
+    public void println()
+    {
+        write('\n');
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringFormatter.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringFormatter.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringFormatter.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringFormatter.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.ByteArrayOutputStream;
+import java.util.List;
+
+/**
+ * This class represents a formatter for CharString commands of a Type1 font.
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class Type1CharStringFormatter
+{
+
+    private ByteArrayOutputStream output = null;
+
+    /**
+     * Formats the given command sequence to a byte array.
+     * @param sequence the given command sequence
+     * @return the formatted seuqence as byte array
+     */
+    public byte[] format(List<Object> sequence)
+    {
+        output = new ByteArrayOutputStream();
+
+        for (Object object : sequence)
+        {
+            if (object instanceof CharStringCommand)
+            {
+                writeCommand((CharStringCommand) object);
+            } 
+            else if (object instanceof Integer)
+            {
+                writeNumber((Integer) object);
+            } 
+            else
+            {
+                throw new IllegalArgumentException();
+            }
+        }
+        return output.toByteArray();
+    }
+
+    private void writeCommand(CharStringCommand command)
+    {
+        int[] value = command.getKey().getValue();
+        for (int i = 0; i < value.length; i++)
+        {
+            output.write(value[i]);
+        }
+    }
+
+    private void writeNumber(Integer number)
+    {
+        int value = number.intValue();
+        if (value >= -107 && value <= 107)
+        {
+            output.write(value + 139);
+        } 
+        else if (value >= 108 && value <= 1131)
+        {
+            int b1 = (value - 108) % 256;
+            int b0 = (value - 108 - b1) / 256 + 247;
+            output.write(b0);
+            output.write(b1);
+        } 
+        else if (value >= -1131 && value <= -108)
+        {
+            int b1 = -((value + 108) % 256);
+            int b0 = -((value + 108 + b1) / 256 - 251);
+            output.write(b0);
+            output.write(b1);
+        } 
+        else
+        {
+            int b1 = value >>> 24 & 0xff;
+            int b2 = value >>> 16 & 0xff;
+            int b3 = value >>> 8 & 0xff;
+            int b4 = value >>> 0 & 0xff;
+            output.write(255);
+            output.write(b1);
+            output.write(b2);
+            output.write(b3);
+            output.write(b4);
+        }
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringParser.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringParser.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringParser.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1CharStringParser.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class represents a converter for a mapping into a Type1-sequence.
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class Type1CharStringParser
+{
+
+    private DataInput input = null;
+    private List<Object> sequence = null;
+
+    /**
+     * The given byte array will be parsed and converted to a Type1 sequence.
+     * @param bytes the given mapping as byte array
+     * @return the Type1 sequence
+     * @throws IOException if an error occurs during reading
+     */
+    public List<Object> parse(byte[] bytes) throws IOException
+    {
+        input = new DataInput(bytes);
+        sequence = new ArrayList<Object>();
+        while (input.hasRemaining())
+        {
+            int b0 = input.readUnsignedByte();
+
+            if (b0 >= 0 && b0 <= 31)
+            {
+                sequence.add(readCommand(b0));
+            } 
+            else if (b0 >= 32 && b0 <= 255)
+            {
+                sequence.add(readNumber(b0));
+            } 
+            else
+            {
+                throw new IllegalArgumentException();
+            }
+        }
+        return sequence;
+    }
+
+    private CharStringCommand readCommand(int b0) throws IOException
+    {
+        if (b0 == 12)
+        {
+            int b1 = input.readUnsignedByte();
+            return new CharStringCommand(b0, b1);
+        }
+        return new CharStringCommand(b0);
+    }
+
+    private Integer readNumber(int b0) throws IOException
+    {
+        if (b0 >= 32 && b0 <= 246)
+        {
+            return Integer.valueOf(b0 - 139);
+        } 
+        else if (b0 >= 247 && b0 <= 250)
+        {
+            int b1 = input.readUnsignedByte();
+            return Integer.valueOf((b0 - 247) * 256 + b1 + 108);
+        } 
+        else if (b0 >= 251 && b0 <= 254)
+        {
+            int b1 = input.readUnsignedByte();
+            return Integer.valueOf(-(b0 - 251) * 256 - b1 - 108);
+        } 
+        else if (b0 == 255)
+        {
+            int b1 = input.readUnsignedByte();
+            int b2 = input.readUnsignedByte();
+            int b3 = input.readUnsignedByte();
+            int b4 = input.readUnsignedByte();
+
+            return Integer.valueOf(b1 << 24 | b2 << 16 | b3 << 8 | b4);
+        } 
+        else
+        {
+            throw new IllegalArgumentException();
+        }
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontFormatter.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontFormatter.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontFormatter.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontFormatter.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * This class represents a formatter for a given Type1 font.  
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class Type1FontFormatter
+{
+
+    private Type1FontFormatter()
+    {
+    }
+
+    /**
+     * Read and convert a given CFFFont.
+     * @param font the given CFFFont
+     * @return the Type1 font
+     * @throws IOException if an error occurs during reading the given font
+     */
+    public static byte[] format(CFFFont font) throws IOException
+    {
+        DataOutput output = new DataOutput();
+        printFont(font, output);
+        return output.getBytes();
+    }
+
+    private static void printFont(CFFFont font, DataOutput output)
+            throws IOException
+    {
+        output.println("%!FontType1-1.0 " + font.getName() + " "
+                + font.getProperty("version"));
+
+        printFontDictionary(font, output);
+
+        for (int i = 0; i < 8; i++)
+        {
+            StringBuilder sb = new StringBuilder();
+
+            for (int j = 0; j < 64; j++)
+            {
+                sb.append("0");
+            }
+
+            output.println(sb.toString());
+        }
+
+        output.println("cleartomark");
+    }
+
+    private static void printFontDictionary(CFFFont font, DataOutput output)
+            throws IOException
+    {
+        output.println("10 dict begin");
+        output.println("/FontInfo 10 dict dup begin");
+        output.println("/version (" + font.getProperty("version")
+                + ") readonly def");
+        output.println("/Notice (" + font.getProperty("Notice")
+                + ") readonly def");
+        output.println("/FullName (" + font.getProperty("FullName")
+                + ") readonly def");
+        output.println("/FamilyName (" + font.getProperty("FamilyName")
+                + ") readonly def");
+        output.println("/Weight (" + font.getProperty("Weight")
+                + ") readonly def");
+        output.println("/ItalicAngle " + font.getProperty("ItalicAngle")
+                + " def");
+        output.println("/isFixedPitch " + font.getProperty("isFixedPitch")
+                + " def");
+        output.println("/UnderlinePosition "
+                + font.getProperty("UnderlinePosition") + " def");
+        output.println("/UnderlineThickness "
+                + font.getProperty("UnderlineThickness") + " def");
+        output.println("end readonly def");
+        output.println("/FontName /" + font.getName() + " def");
+        output.println("/PaintType " + font.getProperty("PaintType") + " def");
+        output.println("/FontType 1 def");
+        output.println("/FontMatrix "
+                + formatArray(font.getProperty("FontMatrix"), false)
+                + " readonly def");
+        output.println("/FontBBox "
+                + formatArray(font.getProperty("FontBBox"), false)
+                + " readonly def");
+        output.println("/StrokeWidth " + font.getProperty("StrokeWidth")
+                + " def");
+
+        Collection<CFFFont.Mapping> mappings = font.getMappings();
+
+        output.println("/Encoding 256 array");
+        output.println("0 1 255 {1 index exch /.notdef put} for");
+
+        for (CFFFont.Mapping mapping : mappings)
+        {
+            output.println("dup " + mapping.getCode() + " /"
+                    + mapping.getName() + " put");
+        }
+
+        output.println("readonly def");
+        output.println("currentdict end");
+
+        DataOutput eexecOutput = new DataOutput();
+
+        printEexecFontDictionary(font, eexecOutput);
+
+        output.println("currentfile eexec");
+
+        byte[] eexecBytes = Type1FontUtil.eexecEncrypt(eexecOutput.getBytes());
+
+        String hexString = Type1FontUtil.hexEncode(eexecBytes);
+        for (int i = 0; i < hexString.length();)
+        {
+            String hexLine = hexString.substring(i, Math.min(i + 72, hexString
+                    .length()));
+
+            output.println(hexLine);
+
+            i += hexLine.length();
+        }
+    }
+
+    private static void printEexecFontDictionary(CFFFont font, DataOutput output)
+            throws IOException
+    {
+        output.println("dup /Private 15 dict dup begin");
+        output
+                .println("/RD {string currentfile exch readstring pop} executeonly def");
+        output.println("/ND {noaccess def} executeonly def");
+        output.println("/NP {noaccess put} executeonly def");
+        output.println("/BlueValues "
+                + formatArray(font.getProperty("BlueValues"), true) + " ND");
+        output.println("/OtherBlues "
+                + formatArray(font.getProperty("OtherBlues"), true) + " ND");
+        output.println("/BlueScale " + font.getProperty("BlueScale") + " def");
+        output.println("/BlueShift " + font.getProperty("BlueShift") + " def");
+        output.println("/BlueFuzz " + font.getProperty("BlueFuzz") + " def");
+        output.println("/StdHW " + formatArray(font.getProperty("StdHW"), true)
+                + " ND");
+        output.println("/StdVW " + formatArray(font.getProperty("StdVW"), true)
+                + " ND");
+        output.println("/ForceBold " + font.getProperty("ForceBold") + " def");
+        output.println("/MinFeature {16 16} def");
+        output.println("/password 5839 def");
+
+        Collection<CFFFont.Mapping> mappings = font.getMappings();
+
+        output.println("2 index /CharStrings " + mappings.size()
+                + " dict dup begin");
+
+        Type1CharStringFormatter formatter = new Type1CharStringFormatter();
+
+        for (CFFFont.Mapping mapping : mappings)
+        {
+            byte[] type1Bytes = formatter.format(mapping.toType1Sequence());
+
+            byte[] charstringBytes = Type1FontUtil.charstringEncrypt(
+                    type1Bytes, 4);
+
+            output.print("/" + mapping.getName() + " " + charstringBytes.length
+                    + " RD ");
+            output.write(charstringBytes);
+            output.print(" ND");
+
+            output.println();
+        }
+
+        output.println("end");
+        output.println("end");
+
+        output.println("readonly put");
+        output.println("noaccess put");
+        output.println("dup /FontName get exch definefont pop");
+        output.println("mark currentfile closefile");
+    }
+
+    private static String formatArray(Object object, boolean executable)
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append(executable ? "{" : "[");
+
+        if (object instanceof Collection)
+        {
+            String sep = "";
+
+            Collection<?> elements = (Collection<?>) object;
+            for (Object element : elements)
+            {
+                sb.append(sep).append(element);
+
+                sep = " ";
+            }
+        } 
+        else if (object instanceof Number)
+        {
+            sb.append(object);
+        }
+
+        sb.append(executable ? "}" : "]");
+
+        return sb.toString();
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontUtil.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontUtil.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontUtil.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type1FontUtil.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+/**
+ * This class contains some helper methods handling Type1-Fonts.
+ *
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class Type1FontUtil
+{
+
+    private Type1FontUtil()
+    {
+    }
+
+    /**
+     * Converts a byte-array into a string with the corresponding hex value. 
+     * @param bytes the byte array
+     * @return the string with the hex value
+     */
+    public static String hexEncode(byte[] bytes)
+    {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < bytes.length; i++)
+        {
+            String string = Integer.toHexString(bytes[i] & 0xff);
+            if (string.length() == 1)
+            {
+                sb.append("0");
+            }
+            sb.append(string.toUpperCase());
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Converts a string representing a hex value into a byte array.
+     * @param string the string representing the hex value
+     * @return the hex value as byte array
+     */
+    public static byte[] hexDecode(String string)
+    {
+        if (string.length() % 2 != 0)
+        {
+            throw new IllegalArgumentException();
+        }
+        byte[] bytes = new byte[string.length() / 2];
+        for (int i = 0; i < string.length(); i += 2)
+        {
+            bytes[i / 2] = (byte) Integer.parseInt(string.substring(i, i + 2), 16);
+        }
+        return bytes;
+    }
+
+    /**
+     * Encrypt eexec.
+     * @param buffer the given data
+     * @return the encrypted data
+     */
+    public static byte[] eexecEncrypt(byte[] buffer)
+    {
+        return encrypt(buffer, 55665, 4);
+    }
+
+    /**
+     * Encrypt charstring.
+     * @param buffer the given data
+     * @param n blocksize?
+     * @return the encrypted data
+     */
+    public static byte[] charstringEncrypt(byte[] buffer, int n)
+    {
+        return encrypt(buffer, 4330, n);
+    }
+
+    private static byte[] encrypt(byte[] plaintextBytes, int r, int n)
+    {
+        byte[] buffer = new byte[plaintextBytes.length + n];
+
+        for (int i = 0; i < n; i++)
+        {
+            buffer[i] = 0;
+        }
+
+        System.arraycopy(plaintextBytes, 0, buffer, n, buffer.length - n);
+
+        int c1 = 52845;
+        int c2 = 22719;
+
+        byte[] ciphertextBytes = new byte[buffer.length];
+
+        for (int i = 0; i < buffer.length; i++)
+        {
+            int plain = buffer[i] & 0xff;
+            int cipher = plain ^ r >> 8;
+
+            ciphertextBytes[i] = (byte) cipher;
+
+            r = (cipher + r) * c1 + c2 & 0xffff;
+        }
+
+        return ciphertextBytes;
+    }
+
+    /**
+     * Decrypt eexec.
+     * @param buffer the given encrypted data
+     * @return the decrypted data
+     */
+    public static byte[] eexecDecrypt(byte[] buffer)
+    {
+        return decrypt(buffer, 55665, 4);
+    }
+
+    /**
+     * Decrypt charstring.
+     * @param buffer the given encrypted data
+     * @param n blocksize?
+     * @return the decrypted data
+     */
+    public static byte[] charstringDecrypt(byte[] buffer, int n)
+    {
+        return decrypt(buffer, 4330, n);
+    }
+
+    private static byte[] decrypt(byte[] ciphertextBytes, int r, int n)
+    {
+        byte[] buffer = new byte[ciphertextBytes.length];
+
+        int c1 = 52845;
+        int c2 = 22719;
+
+        for (int i = 0; i < ciphertextBytes.length; i++)
+        {
+            int cipher = ciphertextBytes[i] & 0xff;
+            int plain = cipher ^ r >> 8;
+
+            buffer[i] = (byte) plain;
+
+            r = (cipher + r) * c1 + c2 & 0xffff;
+        }
+
+        byte[] plaintextBytes = new byte[ciphertextBytes.length - n];
+        System.arraycopy(buffer, n, plaintextBytes, 0, plaintextBytes.length);
+
+        return plaintextBytes;
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class represents a converter for a mapping into a Type2-sequence.
+ * @author Villu Russmann
+ * @version $Revision: 1.0 $
+ */
+public class Type2CharStringParser
+{
+
+    private DataInput input = null;
+    private int hstemCount = 0;
+    private int vstemCount = 0;
+    private List<Object> sequence = null;
+
+    /**
+     * The given byte array will be parsed and converted to a Type2 sequence.
+     * @param bytes the given mapping as byte array
+     * @return the Type2 sequence
+     * @throws IOException if an error occurs during reading
+     */
+    public List<Object> parse(byte[] bytes) throws IOException
+    {
+        input = new DataInput(bytes);
+
+        hstemCount = 0;
+        vstemCount = 0;
+
+        sequence = new ArrayList<Object>();
+
+        while (input.hasRemaining())
+        {
+            int b0 = input.readUnsignedByte();
+
+            if (b0 >= 0 && b0 <= 27)
+            {
+                sequence.add(readCommand(b0));
+            } 
+            else if (b0 == 28)
+            {
+                sequence.add(readNumber(b0));
+            } 
+            else if (b0 >= 29 && b0 <= 31)
+            {
+                sequence.add(readCommand(b0));
+            } 
+            else if (b0 >= 32 && b0 <= 255)
+            {
+                sequence.add(readNumber(b0));
+            }
+            else
+            {
+                throw new IllegalArgumentException();
+            }
+        }
+
+        return sequence;
+    }
+
+    private CharStringCommand readCommand(int b0) throws IOException
+    {
+
+        if (b0 == 1 || b0 == 18)
+        {
+            hstemCount += peekNumbers().size() / 2;
+        } 
+        else if (b0 == 3 || b0 == 19 || b0 == 20 || b0 == 23)
+        {
+            vstemCount += peekNumbers().size() / 2;
+        } // End if
+
+        if (b0 == 12)
+        {
+            int b1 = input.readUnsignedByte();
+
+            return new CharStringCommand(b0, b1);
+        } 
+        else if (b0 == 19 || b0 == 20)
+        {
+            int[] value = new int[1 + getMaskLength()];
+            value[0] = b0;
+
+            for (int i = 1; i < value.length; i++)
+            {
+                value[i] = input.readUnsignedByte();
+            }
+
+            return new CharStringCommand(value);
+        }
+
+        return new CharStringCommand(b0);
+    }
+
+    private Integer readNumber(int b0) throws IOException
+    {
+
+        if (b0 == 28)
+        {
+            int b1 = input.readUnsignedByte();
+            int b2 = input.readUnsignedByte();
+
+            return Integer.valueOf((short) (b1 << 8 | b2));
+        } 
+        else if (b0 >= 32 && b0 <= 246)
+        {
+            return Integer.valueOf(b0 - 139);
+        } 
+        else if (b0 >= 247 && b0 <= 250)
+        {
+            int b1 = input.readUnsignedByte();
+
+            return Integer.valueOf((b0 - 247) * 256 + b1 + 108);
+        } 
+        else if (b0 >= 251 && b0 <= 254)
+        {
+            int b1 = input.readUnsignedByte();
+
+            return Integer.valueOf(-(b0 - 251) * 256 - b1 - 108);
+        } 
+        else if (b0 == 255)
+        {
+            int b1 = input.readUnsignedByte();
+            int b2 = input.readUnsignedByte();
+            int b3 = input.readUnsignedByte();
+            int b4 = input.readUnsignedByte();
+
+            return Integer
+                    .valueOf((short) (b1 << 24 | b2 << 16 | b3 << 8 | b4));
+        } 
+        else
+        {
+            throw new IllegalArgumentException();
+        }
+    }
+
+    private int getMaskLength()
+    {
+        int length = 1;
+
+        int hintCount = hstemCount + vstemCount;
+        while ((hintCount -= 8) > 0)
+        {
+            length++;
+        }
+
+        return length;
+    }
+
+    private List<Number> peekNumbers()
+    {
+        List<Number> numbers = new ArrayList<Number>();
+
+        for (int i = sequence.size() - 1; i > -1; i--)
+        {
+            Object object = sequence.get(i);
+
+            if (object instanceof Number)
+            {
+                Number number = (Number) object;
+
+                numbers.add(0, number);
+
+                continue;
+            }
+
+            return numbers;
+        }
+
+        return numbers;
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFCharset.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFCharset.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFCharset.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFCharset.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff.charset;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This is the superclass for all CFFFont charsets.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public abstract class CFFCharset
+{
+    private List<Entry> entries = new ArrayList<Entry>();
+
+    /**
+     * Determines if the charset is font specific or not.
+     * @return if the charset is font specific
+     */
+    public boolean isFontSpecific()
+    {
+        return false;
+    }
+
+    /**
+     * Returns the SID corresponding to the given name.
+     * @param name the given SID
+     * @return the corresponding SID
+     */
+    public int getSID(String name)
+    {
+        for(Entry entry : this.entries)
+        {
+            if((entry.entryName).equals(name))
+            {
+                return entry.entrySID;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Returns the name corresponding to the given SID.
+     * @param sid the given SID
+     * @return the corresponding name
+     */
+    public String getName(int sid)
+    {
+        for(Entry entry : this.entries)
+        {
+            if(entry.entrySID == sid)
+            {
+                return entry.entryName;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Adds a new SID/name combination to the charset.
+     * @param sid the given SID
+     * @param name the given name
+     */
+    public void register(int sid, String name)
+    {
+        entries.add(new Entry(sid,name));
+    }
+
+    /**
+     * A list of all entries within this charset.
+     * @return a list of all entries
+     */
+    public List<Entry> getEntries()
+    {
+        return entries;
+    }
+
+    /**
+     * This class represents a single name/SID mapping of the charset.
+     *
+     */
+    public static class Entry
+    {
+        private int entrySID;
+        private String entryName;
+
+        /**
+         * Create a new instance of Entry with the given values.
+         * @param sid the SID
+         * @param name the Name
+         */
+        protected Entry(int sid, String name) 
+        {
+            this.entrySID = sid;
+            this.entryName = name;
+        }
+
+        /**
+         * The SID of this entry.
+         * @return the SID
+         */
+        public int getSID()
+        {
+            return entrySID;
+        }
+
+        /**
+         * The Name of this entry.
+         * @return the name
+         */
+        public String getName()
+        {
+            return entryName;
+        }
+        
+        /**
+         * {@inheritDoc}
+         */
+        public String toString()
+        {
+            return "[sid=" + entrySID + ", name=" + entryName + "]";
+        }
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertCharset.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertCharset.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertCharset.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertCharset.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff.charset;
+
+/**
+ * This is specialized CFFCharset. It's used if the CharsetId of a font is set to 1.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class CFFExpertCharset extends CFFCharset
+{
+
+    private CFFExpertCharset()
+    {
+    }
+
+    /**
+     * Returns an instance of the CFFExpertCharset class.
+     * @return an instance of CFFExpertCharset
+     */
+    public static CFFExpertCharset getInstance()
+    {
+        return CFFExpertCharset.INSTANCE;
+    }
+
+    private static final CFFExpertCharset INSTANCE = new CFFExpertCharset();
+
+    static
+    {
+        INSTANCE.register(1, "space");
+        INSTANCE.register(13, "comma");
+        INSTANCE.register(14, "hyphen");
+        INSTANCE.register(15, "period");
+        INSTANCE.register(27, "colon");
+        INSTANCE.register(28, "semicolon");
+        INSTANCE.register(99, "fraction");
+        INSTANCE.register(109, "fi");
+        INSTANCE.register(110, "fl");
+        INSTANCE.register(150, "onesuperior");
+        INSTANCE.register(155, "onehalf");
+        INSTANCE.register(158, "onequarter");
+        INSTANCE.register(163, "threequarters");
+        INSTANCE.register(164, "twosuperior");
+        INSTANCE.register(169, "threesuperior");
+        INSTANCE.register(229, "exclamsmall");
+        INSTANCE.register(230, "Hungarumlautsmall");
+        INSTANCE.register(231, "dollaroldstyle");
+        INSTANCE.register(232, "dollarsuperior");
+        INSTANCE.register(233, "ampersandsmall");
+        INSTANCE.register(234, "Acutesmall");
+        INSTANCE.register(235, "parenleftsuperior");
+        INSTANCE.register(236, "parenrightsuperior");
+        INSTANCE.register(237, "twodotenleader");
+        INSTANCE.register(238, "onedotenleader");
+        INSTANCE.register(239, "zerooldstyle");
+        INSTANCE.register(240, "oneoldstyle");
+        INSTANCE.register(241, "twooldstyle");
+        INSTANCE.register(242, "threeoldstyle");
+        INSTANCE.register(243, "fouroldstyle");
+        INSTANCE.register(244, "fiveoldstyle");
+        INSTANCE.register(245, "sixoldstyle");
+        INSTANCE.register(246, "sevenoldstyle");
+        INSTANCE.register(247, "eightoldstyle");
+        INSTANCE.register(248, "nineoldstyle");
+        INSTANCE.register(249, "commasuperior");
+        INSTANCE.register(250, "threequartersemdash");
+        INSTANCE.register(251, "periodsuperior");
+        INSTANCE.register(252, "questionsmall");
+        INSTANCE.register(253, "asuperior");
+        INSTANCE.register(254, "bsuperior");
+        INSTANCE.register(255, "centsuperior");
+        INSTANCE.register(256, "dsuperior");
+        INSTANCE.register(257, "esuperior");
+        INSTANCE.register(258, "isuperior");
+        INSTANCE.register(259, "lsuperior");
+        INSTANCE.register(260, "msuperior");
+        INSTANCE.register(261, "nsuperior");
+        INSTANCE.register(262, "osuperior");
+        INSTANCE.register(263, "rsuperior");
+        INSTANCE.register(264, "ssuperior");
+        INSTANCE.register(265, "tsuperior");
+        INSTANCE.register(266, "ff");
+        INSTANCE.register(267, "ffi");
+        INSTANCE.register(268, "ffl");
+        INSTANCE.register(269, "parenleftinferior");
+        INSTANCE.register(270, "parenrightinferior");
+        INSTANCE.register(271, "Circumflexsmall");
+        INSTANCE.register(272, "hyphensuperior");
+        INSTANCE.register(273, "Gravesmall");
+        INSTANCE.register(274, "Asmall");
+        INSTANCE.register(275, "Bsmall");
+        INSTANCE.register(276, "Csmall");
+        INSTANCE.register(277, "Dsmall");
+        INSTANCE.register(278, "Esmall");
+        INSTANCE.register(279, "Fsmall");
+        INSTANCE.register(280, "Gsmall");
+        INSTANCE.register(281, "Hsmall");
+        INSTANCE.register(282, "Ismall");
+        INSTANCE.register(283, "Jsmall");
+        INSTANCE.register(284, "Ksmall");
+        INSTANCE.register(285, "Lsmall");
+        INSTANCE.register(286, "Msmall");
+        INSTANCE.register(287, "Nsmall");
+        INSTANCE.register(288, "Osmall");
+        INSTANCE.register(289, "Psmall");
+        INSTANCE.register(290, "Qsmall");
+        INSTANCE.register(291, "Rsmall");
+        INSTANCE.register(292, "Ssmall");
+        INSTANCE.register(293, "Tsmall");
+        INSTANCE.register(294, "Usmall");
+        INSTANCE.register(295, "Vsmall");
+        INSTANCE.register(296, "Wsmall");
+        INSTANCE.register(297, "Xsmall");
+        INSTANCE.register(298, "Ysmall");
+        INSTANCE.register(299, "Zsmall");
+        INSTANCE.register(300, "colonmonetary");
+        INSTANCE.register(301, "onefitted");
+        INSTANCE.register(302, "rupiah");
+        INSTANCE.register(303, "Tildesmall");
+        INSTANCE.register(304, "exclamdownsmall");
+        INSTANCE.register(305, "centoldstyle");
+        INSTANCE.register(306, "Lslashsmall");
+        INSTANCE.register(307, "Scaronsmall");
+        INSTANCE.register(308, "Zcaronsmall");
+        INSTANCE.register(309, "Dieresissmall");
+        INSTANCE.register(310, "Brevesmall");
+        INSTANCE.register(311, "Caronsmall");
+        INSTANCE.register(312, "Dotaccentsmall");
+        INSTANCE.register(313, "Macronsmall");
+        INSTANCE.register(314, "figuredash");
+        INSTANCE.register(315, "hypheninferior");
+        INSTANCE.register(316, "Ogoneksmall");
+        INSTANCE.register(317, "Ringsmall");
+        INSTANCE.register(318, "Cedillasmall");
+        INSTANCE.register(319, "questiondownsmall");
+        INSTANCE.register(320, "oneeighth");
+        INSTANCE.register(321, "threeeighths");
+        INSTANCE.register(322, "fiveeighths");
+        INSTANCE.register(323, "seveneighths");
+        INSTANCE.register(324, "onethird");
+        INSTANCE.register(325, "twothirds");
+        INSTANCE.register(326, "zerosuperior");
+        INSTANCE.register(327, "foursuperior");
+        INSTANCE.register(328, "fivesuperior");
+        INSTANCE.register(329, "sixsuperior");
+        INSTANCE.register(330, "sevensuperior");
+        INSTANCE.register(331, "eightsuperior");
+        INSTANCE.register(332, "ninesuperior");
+        INSTANCE.register(333, "zeroinferior");
+        INSTANCE.register(334, "oneinferior");
+        INSTANCE.register(335, "twoinferior");
+        INSTANCE.register(336, "threeinferior");
+        INSTANCE.register(337, "fourinferior");
+        INSTANCE.register(338, "fiveinferior");
+        INSTANCE.register(339, "sixinferior");
+        INSTANCE.register(340, "seveninferior");
+        INSTANCE.register(341, "eightinferior");
+        INSTANCE.register(342, "nineinferior");
+        INSTANCE.register(343, "centinferior");
+        INSTANCE.register(344, "dollarinferior");
+        INSTANCE.register(345, "periodinferior");
+        INSTANCE.register(346, "commainferior");
+        INSTANCE.register(347, "Agravesmall");
+        INSTANCE.register(348, "Aacutesmall");
+        INSTANCE.register(349, "Acircumflexsmall");
+        INSTANCE.register(350, "Atildesmall");
+        INSTANCE.register(351, "Adieresissmall");
+        INSTANCE.register(352, "Aringsmall");
+        INSTANCE.register(353, "AEsmall");
+        INSTANCE.register(354, "Ccedillasmall");
+        INSTANCE.register(355, "Egravesmall");
+        INSTANCE.register(356, "Eacutesmall");
+        INSTANCE.register(357, "Ecircumflexsmall");
+        INSTANCE.register(358, "Edieresissmall");
+        INSTANCE.register(359, "Igravesmall");
+        INSTANCE.register(360, "Iacutesmall");
+        INSTANCE.register(361, "Icircumflexsmall");
+        INSTANCE.register(362, "Idieresissmall");
+        INSTANCE.register(363, "Ethsmall");
+        INSTANCE.register(364, "Ntildesmall");
+        INSTANCE.register(365, "Ogravesmall");
+        INSTANCE.register(366, "Oacutesmall");
+        INSTANCE.register(367, "Ocircumflexsmall");
+        INSTANCE.register(368, "Otildesmall");
+        INSTANCE.register(369, "Odieresissmall");
+        INSTANCE.register(370, "OEsmall");
+        INSTANCE.register(371, "Oslashsmall");
+        INSTANCE.register(372, "Ugravesmall");
+        INSTANCE.register(373, "Uacutesmall");
+        INSTANCE.register(374, "Ucircumflexsmall");
+        INSTANCE.register(375, "Udieresissmall");
+        INSTANCE.register(376, "Yacutesmall");
+        INSTANCE.register(377, "Thornsmall");
+        INSTANCE.register(378, "Ydieresissmall");
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertSubsetCharset.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertSubsetCharset.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertSubsetCharset.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFExpertSubsetCharset.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff.charset;
+
+
+/**
+ * This is specialized CFFCharset. It's used if the CharsetId of a font is set to 2.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class CFFExpertSubsetCharset extends CFFCharset
+{
+
+    private CFFExpertSubsetCharset()
+    {
+    }
+
+    /**
+     * Returns an instance of the CFFExpertSubsetCharset class.
+     * @return an instance of CFFExpertSubsetCharset
+     */
+    public static CFFExpertSubsetCharset getInstance()
+    {
+        return CFFExpertSubsetCharset.INSTANCE;
+    }
+
+    private static final CFFExpertSubsetCharset INSTANCE = new CFFExpertSubsetCharset();
+
+    static
+    {
+        INSTANCE.register(1, "space");
+        INSTANCE.register(13, "comma");
+        INSTANCE.register(14, "hyphen");
+        INSTANCE.register(15, "period");
+        INSTANCE.register(27, "colon");
+        INSTANCE.register(28, "semicolon");
+        INSTANCE.register(99, "fraction");
+        INSTANCE.register(109, "fi");
+        INSTANCE.register(110, "fl");
+        INSTANCE.register(150, "onesuperior");
+        INSTANCE.register(155, "onehalf");
+        INSTANCE.register(158, "onequarter");
+        INSTANCE.register(163, "threequarters");
+        INSTANCE.register(164, "twosuperior");
+        INSTANCE.register(169, "threesuperior");
+        INSTANCE.register(231, "dollaroldstyle");
+        INSTANCE.register(232, "dollarsuperior");
+        INSTANCE.register(235, "parenleftsuperior");
+        INSTANCE.register(236, "parenrightsuperior");
+        INSTANCE.register(237, "twodotenleader");
+        INSTANCE.register(238, "onedotenleader");
+        INSTANCE.register(239, "zerooldstyle");
+        INSTANCE.register(240, "oneoldstyle");
+        INSTANCE.register(241, "twooldstyle");
+        INSTANCE.register(242, "threeoldstyle");
+        INSTANCE.register(243, "fouroldstyle");
+        INSTANCE.register(244, "fiveoldstyle");
+        INSTANCE.register(245, "sixoldstyle");
+        INSTANCE.register(246, "sevenoldstyle");
+        INSTANCE.register(247, "eightoldstyle");
+        INSTANCE.register(248, "nineoldstyle");
+        INSTANCE.register(249, "commasuperior");
+        INSTANCE.register(250, "threequartersemdash");
+        INSTANCE.register(251, "periodsuperior");
+        INSTANCE.register(253, "asuperior");
+        INSTANCE.register(254, "bsuperior");
+        INSTANCE.register(255, "centsuperior");
+        INSTANCE.register(256, "dsuperior");
+        INSTANCE.register(257, "esuperior");
+        INSTANCE.register(258, "isuperior");
+        INSTANCE.register(259, "lsuperior");
+        INSTANCE.register(260, "msuperior");
+        INSTANCE.register(261, "nsuperior");
+        INSTANCE.register(262, "osuperior");
+        INSTANCE.register(263, "rsuperior");
+        INSTANCE.register(264, "ssuperior");
+        INSTANCE.register(265, "tsuperior");
+        INSTANCE.register(266, "ff");
+        INSTANCE.register(267, "ffi");
+        INSTANCE.register(268, "ffl");
+        INSTANCE.register(269, "parenleftinferior");
+        INSTANCE.register(270, "parenrightinferior");
+        INSTANCE.register(272, "hyphensuperior");
+        INSTANCE.register(300, "colonmonetary");
+        INSTANCE.register(301, "onefitted");
+        INSTANCE.register(302, "rupiah");
+        INSTANCE.register(305, "centoldstyle");
+        INSTANCE.register(314, "figuredash");
+        INSTANCE.register(315, "hypheninferior");
+        INSTANCE.register(320, "oneeighth");
+        INSTANCE.register(321, "threeeighths");
+        INSTANCE.register(322, "fiveeighths");
+        INSTANCE.register(323, "seveneighths");
+        INSTANCE.register(324, "onethird");
+        INSTANCE.register(325, "twothirds");
+        INSTANCE.register(326, "zerosuperior");
+        INSTANCE.register(327, "foursuperior");
+        INSTANCE.register(328, "fivesuperior");
+        INSTANCE.register(329, "sixsuperior");
+        INSTANCE.register(330, "sevensuperior");
+        INSTANCE.register(331, "eightsuperior");
+        INSTANCE.register(332, "ninesuperior");
+        INSTANCE.register(333, "zeroinferior");
+        INSTANCE.register(334, "oneinferior");
+        INSTANCE.register(335, "twoinferior");
+        INSTANCE.register(336, "threeinferior");
+        INSTANCE.register(337, "fourinferior");
+        INSTANCE.register(338, "fiveinferior");
+        INSTANCE.register(339, "sixinferior");
+        INSTANCE.register(340, "seveninferior");
+        INSTANCE.register(341, "eightinferior");
+        INSTANCE.register(342, "nineinferior");
+        INSTANCE.register(343, "centinferior");
+        INSTANCE.register(344, "dollarinferior");
+        INSTANCE.register(345, "periodinferior");
+        INSTANCE.register(346, "commainferior");
+    }
+}
\ No newline at end of file

Added: pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFISOAdobeCharset.java
URL: http://svn.apache.org/viewvc/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFISOAdobeCharset.java?rev=907461&view=auto
==============================================================================
--- pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFISOAdobeCharset.java (added)
+++ pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/cff/charset/CFFISOAdobeCharset.java Sun Feb  7 18:09:19 2010
@@ -0,0 +1,275 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.cff.charset;
+
+
+/**
+ * This is specialized CFFCharset. It's used if the CharsetId of a font is set to 0.
+ * 
+ * @author Villu Russmann
+ * @version $Revision$
+ */
+public class CFFISOAdobeCharset extends CFFCharset
+{
+
+    private CFFISOAdobeCharset()
+    {
+    }
+
+    /**
+     * Returns an instance of the CFFExpertSubsetCharset class.
+     * @return an instance of CFFExpertSubsetCharset
+     */
+    public static CFFISOAdobeCharset getInstance()
+    {
+        return CFFISOAdobeCharset.INSTANCE;
+    }
+
+    private static final CFFISOAdobeCharset INSTANCE = new CFFISOAdobeCharset();
+
+    static
+    {
+        INSTANCE.register(1, "space");
+        INSTANCE.register(2, "exclam");
+        INSTANCE.register(3, "quotedbl");
+        INSTANCE.register(4, "numbersign");
+        INSTANCE.register(5, "dollar");
+        INSTANCE.register(6, "percent");
+        INSTANCE.register(7, "ampersand");
+        INSTANCE.register(8, "quoteright");
+        INSTANCE.register(9, "parenleft");
+        INSTANCE.register(10, "parenright");
+        INSTANCE.register(11, "asterisk");
+        INSTANCE.register(12, "plus");
+        INSTANCE.register(13, "comma");
+        INSTANCE.register(14, "hyphen");
+        INSTANCE.register(15, "period");
+        INSTANCE.register(16, "slash");
+        INSTANCE.register(17, "zero");
+        INSTANCE.register(18, "one");
+        INSTANCE.register(19, "two");
+        INSTANCE.register(20, "three");
+        INSTANCE.register(21, "four");
+        INSTANCE.register(22, "five");
+        INSTANCE.register(23, "six");
+        INSTANCE.register(24, "seven");
+        INSTANCE.register(25, "eight");
+        INSTANCE.register(26, "nine");
+        INSTANCE.register(27, "colon");
+        INSTANCE.register(28, "semicolon");
+        INSTANCE.register(29, "less");
+        INSTANCE.register(30, "equal");
+        INSTANCE.register(31, "greater");
+        INSTANCE.register(32, "question");
+        INSTANCE.register(33, "at");
+        INSTANCE.register(34, "A");
+        INSTANCE.register(35, "B");
+        INSTANCE.register(36, "C");
+        INSTANCE.register(37, "D");
+        INSTANCE.register(38, "E");
+        INSTANCE.register(39, "F");
+        INSTANCE.register(40, "G");
+        INSTANCE.register(41, "H");
+        INSTANCE.register(42, "I");
+        INSTANCE.register(43, "J");
+        INSTANCE.register(44, "K");
+        INSTANCE.register(45, "L");
+        INSTANCE.register(46, "M");
+        INSTANCE.register(47, "N");
+        INSTANCE.register(48, "O");
+        INSTANCE.register(49, "P");
+        INSTANCE.register(50, "Q");
+        INSTANCE.register(51, "R");
+        INSTANCE.register(52, "S");
+        INSTANCE.register(53, "T");
+        INSTANCE.register(54, "U");
+        INSTANCE.register(55, "V");
+        INSTANCE.register(56, "W");
+        INSTANCE.register(57, "X");
+        INSTANCE.register(58, "Y");
+        INSTANCE.register(59, "Z");
+        INSTANCE.register(60, "bracketleft");
+        INSTANCE.register(61, "backslash");
+        INSTANCE.register(62, "bracketright");
+        INSTANCE.register(63, "asciicircum");
+        INSTANCE.register(64, "underscore");
+        INSTANCE.register(65, "quoteleft");
+        INSTANCE.register(66, "a");
+        INSTANCE.register(67, "b");
+        INSTANCE.register(68, "c");
+        INSTANCE.register(69, "d");
+        INSTANCE.register(70, "e");
+        INSTANCE.register(71, "f");
+        INSTANCE.register(72, "g");
+        INSTANCE.register(73, "h");
+        INSTANCE.register(74, "i");
+        INSTANCE.register(75, "j");
+        INSTANCE.register(76, "k");
+        INSTANCE.register(77, "l");
+        INSTANCE.register(78, "m");
+        INSTANCE.register(79, "n");
+        INSTANCE.register(80, "o");
+        INSTANCE.register(81, "p");
+        INSTANCE.register(82, "q");
+        INSTANCE.register(83, "r");
+        INSTANCE.register(84, "s");
+        INSTANCE.register(85, "t");
+        INSTANCE.register(86, "u");
+        INSTANCE.register(87, "v");
+        INSTANCE.register(88, "w");
+        INSTANCE.register(89, "x");
+        INSTANCE.register(90, "y");
+        INSTANCE.register(91, "z");
+        INSTANCE.register(92, "braceleft");
+        INSTANCE.register(93, "bar");
+        INSTANCE.register(94, "braceright");
+        INSTANCE.register(95, "asciitilde");
+        INSTANCE.register(96, "exclamdown");
+        INSTANCE.register(97, "cent");
+        INSTANCE.register(98, "sterling");
+        INSTANCE.register(99, "fraction");
+        INSTANCE.register(100, "yen");
+        INSTANCE.register(101, "florin");
+        INSTANCE.register(102, "section");
+        INSTANCE.register(103, "currency");
+        INSTANCE.register(104, "quotesingle");
+        INSTANCE.register(105, "quotedblleft");
+        INSTANCE.register(106, "guillemotleft");
+        INSTANCE.register(107, "guilsinglleft");
+        INSTANCE.register(108, "guilsinglright");
+        INSTANCE.register(109, "fi");
+        INSTANCE.register(110, "fl");
+        INSTANCE.register(111, "endash");
+        INSTANCE.register(112, "dagger");
+        INSTANCE.register(113, "daggerdbl");
+        INSTANCE.register(114, "periodcentered");
+        INSTANCE.register(115, "paragraph");
+        INSTANCE.register(116, "bullet");
+        INSTANCE.register(117, "quotesinglbase");
+        INSTANCE.register(118, "quotedblbase");
+        INSTANCE.register(119, "quotedblright");
+        INSTANCE.register(120, "guillemotright");
+        INSTANCE.register(121, "ellipsis");
+        INSTANCE.register(122, "perthousand");
+        INSTANCE.register(123, "questiondown");
+        INSTANCE.register(124, "grave");
+        INSTANCE.register(125, "acute");
+        INSTANCE.register(126, "circumflex");
+        INSTANCE.register(127, "tilde");
+        INSTANCE.register(128, "macron");
+        INSTANCE.register(129, "breve");
+        INSTANCE.register(130, "dotaccent");
+        INSTANCE.register(131, "dieresis");
+        INSTANCE.register(132, "ring");
+        INSTANCE.register(133, "cedilla");
+        INSTANCE.register(134, "hungarumlaut");
+        INSTANCE.register(135, "ogonek");
+        INSTANCE.register(136, "caron");
+        INSTANCE.register(137, "emdash");
+        INSTANCE.register(138, "AE");
+        INSTANCE.register(139, "ordfeminine");
+        INSTANCE.register(140, "Lslash");
+        INSTANCE.register(141, "Oslash");
+        INSTANCE.register(142, "OE");
+        INSTANCE.register(143, "ordmasculine");
+        INSTANCE.register(144, "ae");
+        INSTANCE.register(145, "dotlessi");
+        INSTANCE.register(146, "lslash");
+        INSTANCE.register(147, "oslash");
+        INSTANCE.register(148, "oe");
+        INSTANCE.register(149, "germandbls");
+        INSTANCE.register(150, "onesuperior");
+        INSTANCE.register(151, "logicalnot");
+        INSTANCE.register(152, "mu");
+        INSTANCE.register(153, "trademark");
+        INSTANCE.register(154, "Eth");
+        INSTANCE.register(155, "onehalf");
+        INSTANCE.register(156, "plusminus");
+        INSTANCE.register(157, "Thorn");
+        INSTANCE.register(158, "onequarter");
+        INSTANCE.register(159, "divide");
+        INSTANCE.register(160, "brokenbar");
+        INSTANCE.register(161, "degree");
+        INSTANCE.register(162, "thorn");
+        INSTANCE.register(163, "threequarters");
+        INSTANCE.register(164, "twosuperior");
+        INSTANCE.register(165, "registered");
+        INSTANCE.register(166, "minus");
+        INSTANCE.register(167, "eth");
+        INSTANCE.register(168, "multiply");
+        INSTANCE.register(169, "threesuperior");
+        INSTANCE.register(170, "copyright");
+        INSTANCE.register(171, "Aacute");
+        INSTANCE.register(172, "Acircumflex");
+        INSTANCE.register(173, "Adieresis");
+        INSTANCE.register(174, "Agrave");
+        INSTANCE.register(175, "Aring");
+        INSTANCE.register(176, "Atilde");
+        INSTANCE.register(177, "Ccedilla");
+        INSTANCE.register(178, "Eacute");
+        INSTANCE.register(179, "Ecircumflex");
+        INSTANCE.register(180, "Edieresis");
+        INSTANCE.register(181, "Egrave");
+        INSTANCE.register(182, "Iacute");
+        INSTANCE.register(183, "Icircumflex");
+        INSTANCE.register(184, "Idieresis");
+        INSTANCE.register(185, "Igrave");
+        INSTANCE.register(186, "Ntilde");
+        INSTANCE.register(187, "Oacute");
+        INSTANCE.register(188, "Ocircumflex");
+        INSTANCE.register(189, "Odieresis");
+        INSTANCE.register(190, "Ograve");
+        INSTANCE.register(191, "Otilde");
+        INSTANCE.register(192, "Scaron");
+        INSTANCE.register(193, "Uacute");
+        INSTANCE.register(194, "Ucircumflex");
+        INSTANCE.register(195, "Udieresis");
+        INSTANCE.register(196, "Ugrave");
+        INSTANCE.register(197, "Yacute");
+        INSTANCE.register(198, "Ydieresis");
+        INSTANCE.register(199, "Zcaron");
+        INSTANCE.register(200, "aacute");
+        INSTANCE.register(201, "acircumflex");
+        INSTANCE.register(202, "adieresis");
+        INSTANCE.register(203, "agrave");
+        INSTANCE.register(204, "aring");
+        INSTANCE.register(205, "atilde");
+        INSTANCE.register(206, "ccedilla");
+        INSTANCE.register(207, "eacute");
+        INSTANCE.register(208, "ecircumflex");
+        INSTANCE.register(209, "edieresis");
+        INSTANCE.register(210, "egrave");
+        INSTANCE.register(211, "iacute");
+        INSTANCE.register(212, "icircumflex");
+        INSTANCE.register(213, "idieresis");
+        INSTANCE.register(214, "igrave");
+        INSTANCE.register(215, "ntilde");
+        INSTANCE.register(216, "oacute");
+        INSTANCE.register(217, "ocircumflex");
+        INSTANCE.register(218, "odieresis");
+        INSTANCE.register(219, "ograve");
+        INSTANCE.register(220, "otilde");
+        INSTANCE.register(221, "scaron");
+        INSTANCE.register(222, "uacute");
+        INSTANCE.register(223, "ucircumflex");
+        INSTANCE.register(224, "udieresis");
+        INSTANCE.register(225, "ugrave");
+        INSTANCE.register(226, "yacute");
+        INSTANCE.register(227, "ydieresis");
+        INSTANCE.register(228, "zcaron");
+    }
+}
\ No newline at end of file



Mime
View raw message