You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2009/03/11 23:40:34 UTC

svn commit: r752669 [3/4] - in /incubator/pdfbox/fontbox/trunk/src/main/java/org: ./ apache/ apache/fontbox/ apache/fontbox/afm/ apache/fontbox/cmap/ apache/fontbox/encoding/ apache/fontbox/pfb/ apache/fontbox/ttf/ apache/fontbox/util/

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalHeaderTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalHeaderTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalHeaderTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalHeaderTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,318 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class HorizontalHeaderTable extends TTFTable
+{
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "hhea";
+    
+    private float version;
+    private short ascender;
+    private short descender;
+    private short lineGap;
+    private int advanceWidthMax;
+    private short minLeftSideBearing;
+    private short minRightSideBearing;
+    private short xMaxExtent;
+    private short caretSlopeRise;
+    private short caretSlopeRun;
+    private short reserved1;
+    private short reserved2;
+    private short reserved3;
+    private short reserved4;
+    private short reserved5;
+    private short metricDataFormat;
+    private int numberOfHMetrics;
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        version = data.read32Fixed();
+        ascender = data.readSignedShort();
+        descender = data.readSignedShort();
+        lineGap = data.readSignedShort();
+        advanceWidthMax = data.readUnsignedShort();
+        minLeftSideBearing = data.readSignedShort();
+        minRightSideBearing = data.readSignedShort();
+        xMaxExtent = data.readSignedShort();
+        caretSlopeRise = data.readSignedShort();
+        caretSlopeRun = data.readSignedShort();
+        reserved1 = data.readSignedShort();
+        reserved2 = data.readSignedShort();
+        reserved3 = data.readSignedShort();
+        reserved4 = data.readSignedShort();
+        reserved5 = data.readSignedShort();
+        metricDataFormat = data.readSignedShort();
+        numberOfHMetrics = data.readUnsignedShort();
+    }
+    
+    /**
+     * @return Returns the advanceWidthMax.
+     */
+    public int getAdvanceWidthMax()
+    {
+        return advanceWidthMax;
+    }
+    /**
+     * @param advanceWidthMaxValue The advanceWidthMax to set.
+     */
+    public void setAdvanceWidthMax(int advanceWidthMaxValue)
+    {
+        this.advanceWidthMax = advanceWidthMaxValue;
+    }
+    /**
+     * @return Returns the ascender.
+     */
+    public short getAscender()
+    {
+        return ascender;
+    }
+    /**
+     * @param ascenderValue The ascender to set.
+     */
+    public void setAscender(short ascenderValue)
+    {
+        this.ascender = ascenderValue;
+    }
+    /**
+     * @return Returns the caretSlopeRise.
+     */
+    public short getCaretSlopeRise()
+    {
+        return caretSlopeRise;
+    }
+    /**
+     * @param caretSlopeRiseValue The caretSlopeRise to set.
+     */
+    public void setCaretSlopeRise(short caretSlopeRiseValue)
+    {
+        this.caretSlopeRise = caretSlopeRiseValue;
+    }
+    /**
+     * @return Returns the caretSlopeRun.
+     */
+    public short getCaretSlopeRun()
+    {
+        return caretSlopeRun;
+    }
+    /**
+     * @param caretSlopeRunValue The caretSlopeRun to set.
+     */
+    public void setCaretSlopeRun(short caretSlopeRunValue)
+    {
+        this.caretSlopeRun = caretSlopeRunValue;
+    }
+    /**
+     * @return Returns the descender.
+     */
+    public short getDescender()
+    {
+        return descender;
+    }
+    /**
+     * @param descenderValue The descender to set.
+     */
+    public void setDescender(short descenderValue)
+    {
+        this.descender = descenderValue;
+    }
+    /**
+     * @return Returns the lineGap.
+     */
+    public short getLineGap()
+    {
+        return lineGap;
+    }
+    /**
+     * @param lineGapValue The lineGap to set.
+     */
+    public void setLineGap(short lineGapValue)
+    {
+        this.lineGap = lineGapValue;
+    }
+    /**
+     * @return Returns the metricDataFormat.
+     */
+    public short getMetricDataFormat()
+    {
+        return metricDataFormat;
+    }
+    /**
+     * @param metricDataFormatValue The metricDataFormat to set.
+     */
+    public void setMetricDataFormat(short metricDataFormatValue)
+    {
+        this.metricDataFormat = metricDataFormatValue;
+    }
+    /**
+     * @return Returns the minLeftSideBearing.
+     */
+    public short getMinLeftSideBearing()
+    {
+        return minLeftSideBearing;
+    }
+    /**
+     * @param minLeftSideBearingValue The minLeftSideBearing to set.
+     */
+    public void setMinLeftSideBearing(short minLeftSideBearingValue)
+    {
+        this.minLeftSideBearing = minLeftSideBearingValue;
+    }
+    /**
+     * @return Returns the minRightSideBearing.
+     */
+    public short getMinRightSideBearing()
+    {
+        return minRightSideBearing;
+    }
+    /**
+     * @param minRightSideBearingValue The minRightSideBearing to set.
+     */
+    public void setMinRightSideBearing(short minRightSideBearingValue)
+    {
+        this.minRightSideBearing = minRightSideBearingValue;
+    }
+    /**
+     * @return Returns the numberOfHMetrics.
+     */
+    public int getNumberOfHMetrics()
+    {
+        return numberOfHMetrics;
+    }
+    /**
+     * @param numberOfHMetricsValue The numberOfHMetrics to set.
+     */
+    public void setNumberOfHMetrics(int numberOfHMetricsValue)
+    {
+        this.numberOfHMetrics = numberOfHMetricsValue;
+    }
+    /**
+     * @return Returns the reserved1.
+     */
+    public short getReserved1()
+    {
+        return reserved1;
+    }
+    /**
+     * @param reserved1Value The reserved1 to set.
+     */
+    public void setReserved1(short reserved1Value)
+    {
+        this.reserved1 = reserved1Value;
+    }
+    /**
+     * @return Returns the reserved2.
+     */
+    public short getReserved2()
+    {
+        return reserved2;
+    }
+    /**
+     * @param reserved2Value The reserved2 to set.
+     */
+    public void setReserved2(short reserved2Value)
+    {
+        this.reserved2 = reserved2Value;
+    }
+    /**
+     * @return Returns the reserved3.
+     */
+    public short getReserved3()
+    {
+        return reserved3;
+    }
+    /**
+     * @param reserved3Value The reserved3 to set.
+     */
+    public void setReserved3(short reserved3Value)
+    {
+        this.reserved3 = reserved3Value;
+    }
+    /**
+     * @return Returns the reserved4.
+     */
+    public short getReserved4()
+    {
+        return reserved4;
+    }
+    /**
+     * @param reserved4Value The reserved4 to set.
+     */
+    public void setReserved4(short reserved4Value)
+    {
+        this.reserved4 = reserved4Value;
+    }
+    /**
+     * @return Returns the reserved5.
+     */
+    public short getReserved5()
+    {
+        return reserved5;
+    }
+    /**
+     * @param reserved5Value The reserved5 to set.
+     */
+    public void setReserved5(short reserved5Value)
+    {
+        this.reserved5 = reserved5Value;
+    }
+    /**
+     * @return Returns the version.
+     */
+    public float getVersion()
+    {
+        return version;
+    }
+    /**
+     * @param versionValue The version to set.
+     */
+    public void setVersion(float versionValue)
+    {
+        this.version = versionValue;
+    }
+    /**
+     * @return Returns the xMaxExtent.
+     */
+    public short getXMaxExtent()
+    {
+        return xMaxExtent;
+    }
+    /**
+     * @param maxExtentValue The xMaxExtent to set.
+     */
+    public void setXMaxExtent(short maxExtentValue)
+    {
+        xMaxExtent = maxExtentValue;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalHeaderTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,81 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class HorizontalMetricsTable extends TTFTable
+{
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "hmtx";
+    
+    private int[] advanceWidth;
+    private short[] leftSideBearing;
+    private short[] nonHorizontalLeftSideBearing;
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        HorizontalHeaderTable hHeader = ttf.getHorizontalHeader();
+        MaximumProfileTable maxp = ttf.getMaximumProfile();
+        int numHMetrics = hHeader.getNumberOfHMetrics();
+        int numGlyphs = maxp.getNumGlyphs();
+        
+        advanceWidth = new int[ numHMetrics ];
+        leftSideBearing = new short[ numHMetrics ];
+        for( int i=0; i<numHMetrics; i++ )
+        {
+            advanceWidth[i] = data.readUnsignedShort();
+            leftSideBearing[i] = data.readSignedShort();
+        }
+        
+        int numberNonHorizontal = numGlyphs - numHMetrics;
+        nonHorizontalLeftSideBearing = new short[ numberNonHorizontal ];
+        for( int i=0; i<numberNonHorizontal; i++ )
+        {
+            nonHorizontalLeftSideBearing[i] = data.readSignedShort();
+        }
+    }
+    /**
+     * @return Returns the advanceWidth.
+     */
+    public int[] getAdvanceWidth()
+    {
+        return advanceWidth;
+    }
+    /**
+     * @param advanceWidthValue The advanceWidth to set.
+     */
+    public void setAdvanceWidth(int[] advanceWidthValue)
+    {
+        this.advanceWidth = advanceWidthValue;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,82 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class IndexToLocationTable extends TTFTable
+{
+    private static final short SHORT_OFFSETS = 0;
+    private static final short LONG_OFFSETS = 1;
+    
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "loca";
+    
+    private long[] offsets;
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        HeaderTable head = ttf.getHeader();
+        MaximumProfileTable maxp = ttf.getMaximumProfile();
+        int numGlyphs = maxp.getNumGlyphs();
+        offsets = new long[ numGlyphs +1];
+        for( int i=0; i<numGlyphs+1; i++ )
+        {
+            if( head.getIndexToLocFormat() == SHORT_OFFSETS )
+            {
+                offsets[i] = data.readUnsignedShort() * 2;
+            }
+            else if(  head.getIndexToLocFormat() == LONG_OFFSETS )
+            {
+                offsets[i] = data.readUnsignedInt();
+            }
+            else
+            {
+                throw new IOException( "Error:TTF.loca unknown offset format.");
+            }
+        }
+    }
+    /**
+     * @return Returns the offsets.
+     */
+    public long[] getOffsets()
+    {
+        return offsets;
+    }
+    /**
+     * @param offsetsValue The offsets to set.
+     */
+    public void setOffsets(long[] offsetsValue)
+    {
+        this.offsets = offsetsValue;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/IndexToLocationTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,286 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class MaximumProfileTable extends TTFTable
+{
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "maxp";
+    
+    private float version;
+    private int numGlyphs;
+    private int maxPoints;
+    private int maxContours;
+    private int maxCompositePoints;
+    private int maxCompositeContours;
+    private int maxZones;
+    private int maxTwilightPoints;
+    private int maxStorage;
+    private int maxFunctionDefs;
+    private int maxInstructionDefs;
+    private int maxStackElements;
+    private int maxSizeOfInstructions;
+    private int maxComponentElements;
+    private int maxComponentDepth;
+    
+    /**
+     * @return Returns the maxComponentDepth.
+     */
+    public int getMaxComponentDepth()
+    {
+        return maxComponentDepth;
+    }
+    /**
+     * @param maxComponentDepthValue The maxComponentDepth to set.
+     */
+    public void setMaxComponentDepth(int maxComponentDepthValue)
+    {
+        this.maxComponentDepth = maxComponentDepthValue;
+    }
+    /**
+     * @return Returns the maxComponentElements.
+     */
+    public int getMaxComponentElements()
+    {
+        return maxComponentElements;
+    }
+    /**
+     * @param maxComponentElementsValue The maxComponentElements to set.
+     */
+    public void setMaxComponentElements(int maxComponentElementsValue)
+    {
+        this.maxComponentElements = maxComponentElementsValue;
+    }
+    /**
+     * @return Returns the maxCompositeContours.
+     */
+    public int getMaxCompositeContours()
+    {
+        return maxCompositeContours;
+    }
+    /**
+     * @param maxCompositeContoursValue The maxCompositeContours to set.
+     */
+    public void setMaxCompositeContours(int maxCompositeContoursValue)
+    {
+        this.maxCompositeContours = maxCompositeContoursValue;
+    }
+    /**
+     * @return Returns the maxCompositePoints.
+     */
+    public int getMaxCompositePoints()
+    {
+        return maxCompositePoints;
+    }
+    /**
+     * @param maxCompositePointsValue The maxCompositePoints to set.
+     */
+    public void setMaxCompositePoints(int maxCompositePointsValue)
+    {
+        this.maxCompositePoints = maxCompositePointsValue;
+    }
+    /**
+     * @return Returns the maxContours.
+     */
+    public int getMaxContours()
+    {
+        return maxContours;
+    }
+    /**
+     * @param maxContoursValue The maxContours to set.
+     */
+    public void setMaxContours(int maxContoursValue)
+    {
+        this.maxContours = maxContoursValue;
+    }
+    /**
+     * @return Returns the maxFunctionDefs.
+     */
+    public int getMaxFunctionDefs()
+    {
+        return maxFunctionDefs;
+    }
+    /**
+     * @param maxFunctionDefsValue The maxFunctionDefs to set.
+     */
+    public void setMaxFunctionDefs(int maxFunctionDefsValue)
+    {
+        this.maxFunctionDefs = maxFunctionDefsValue;
+    }
+    /**
+     * @return Returns the maxInstructionDefs.
+     */
+    public int getMaxInstructionDefs()
+    {
+        return maxInstructionDefs;
+    }
+    /**
+     * @param maxInstructionDefsValue The maxInstructionDefs to set.
+     */
+    public void setMaxInstructionDefs(int maxInstructionDefsValue)
+    {
+        this.maxInstructionDefs = maxInstructionDefsValue;
+    }
+    /**
+     * @return Returns the maxPoints.
+     */
+    public int getMaxPoints()
+    {
+        return maxPoints;
+    }
+    /**
+     * @param maxPointsValue The maxPoints to set.
+     */
+    public void setMaxPoints(int maxPointsValue)
+    {
+        this.maxPoints = maxPointsValue;
+    }
+    /**
+     * @return Returns the maxSizeOfInstructions.
+     */
+    public int getMaxSizeOfInstructions()
+    {
+        return maxSizeOfInstructions;
+    }
+    /**
+     * @param maxSizeOfInstructionsValue The maxSizeOfInstructions to set.
+     */
+    public void setMaxSizeOfInstructions(int maxSizeOfInstructionsValue)
+    {
+        this.maxSizeOfInstructions = maxSizeOfInstructionsValue;
+    }
+    /**
+     * @return Returns the maxStackElements.
+     */
+    public int getMaxStackElements()
+    {
+        return maxStackElements;
+    }
+    /**
+     * @param maxStackElementsValue The maxStackElements to set.
+     */
+    public void setMaxStackElements(int maxStackElementsValue)
+    {
+        this.maxStackElements = maxStackElementsValue;
+    }
+    /**
+     * @return Returns the maxStorage.
+     */
+    public int getMaxStorage()
+    {
+        return maxStorage;
+    }
+    /**
+     * @param maxStorageValue The maxStorage to set.
+     */
+    public void setMaxStorage(int maxStorageValue)
+    {
+        this.maxStorage = maxStorageValue;
+    }
+    /**
+     * @return Returns the maxTwilightPoints.
+     */
+    public int getMaxTwilightPoints()
+    {
+        return maxTwilightPoints;
+    }
+    /**
+     * @param maxTwilightPointsValue The maxTwilightPoints to set.
+     */
+    public void setMaxTwilightPoints(int maxTwilightPointsValue)
+    {
+        this.maxTwilightPoints = maxTwilightPointsValue;
+    }
+    /**
+     * @return Returns the maxZones.
+     */
+    public int getMaxZones()
+    {
+        return maxZones;
+    }
+    /**
+     * @param maxZonesValue The maxZones to set.
+     */
+    public void setMaxZones(int maxZonesValue)
+    {
+        this.maxZones = maxZonesValue;
+    }
+    /**
+     * @return Returns the numGlyphs.
+     */
+    public int getNumGlyphs()
+    {
+        return numGlyphs;
+    }
+    /**
+     * @param numGlyphsValue The numGlyphs to set.
+     */
+    public void setNumGlyphs(int numGlyphsValue)
+    {
+        this.numGlyphs = numGlyphsValue;
+    }
+    /**
+     * @return Returns the version.
+     */
+    public float getVersion()
+    {
+        return version;
+    }
+    /**
+     * @param versionValue The version to set.
+     */
+    public void setVersion(float versionValue)
+    {
+        this.version = versionValue;
+    }
+
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        version = data.read32Fixed();
+        numGlyphs = data.readUnsignedShort();
+        maxPoints = data.readUnsignedShort();
+        maxContours = data.readUnsignedShort();
+        maxCompositePoints = data.readUnsignedShort();
+        maxCompositeContours = data.readUnsignedShort();
+        maxZones = data.readUnsignedShort();
+        maxTwilightPoints = data.readUnsignedShort();
+        maxStorage = data.readUnsignedShort();
+        maxFunctionDefs = data.readUnsignedShort();
+        maxInstructionDefs = data.readUnsignedShort();
+        maxStackElements = data.readUnsignedShort();
+        maxSizeOfInstructions = data.readUnsignedShort();
+        maxComponentElements = data.readUnsignedShort();
+        maxComponentDepth = data.readUnsignedShort();
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,205 @@
+/*
+ * 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.ttf;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An interface into a data stream.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.2 $
+ */
+public class MemoryTTFDataStream extends TTFDataStream 
+{
+    private byte[] data = null;
+    private int currentPosition = 0;
+    
+    /**
+     * Constructor from a stream. 
+     * @param is The stream of read from.
+     * @throws IOException If an error occurs while reading from the stream.
+     */
+    public MemoryTTFDataStream( InputStream is ) throws IOException
+    {
+        try
+        {
+            ByteArrayOutputStream output = new ByteArrayOutputStream( is.available() );
+            byte[] buffer = new byte[1024];
+            int amountRead = 0;
+            while( (amountRead = is.read( buffer ) ) != -1 )
+            {
+                output.write( buffer, 0, amountRead );
+            }
+            data = output.toByteArray();
+        }
+        finally
+        {
+            if( is != null )
+            {
+                is.close();
+            }
+        }
+    }
+    
+
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public long readLong() throws IOException
+    {
+        return ((long)(readSignedInt()) << 32) + (readSignedInt() & 0xFFFFFFFFL);
+    }
+    
+    /**
+     * Read a signed integer.
+     * 
+     * @return A signed integer.
+     * @throws IOException If there is a problem reading the file.
+     */
+    public int readSignedInt() throws IOException
+    {
+        int ch1 = read();
+        int ch2 = read();
+        int ch3 = read();
+        int ch4 = read();
+        if( (ch1 | ch2 | ch3 | ch4) < 0)
+        {
+            throw new EOFException();
+        }
+        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
+    }
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int read() throws IOException
+    {
+        int retval = -1;
+        if( currentPosition < data.length )
+        {
+            retval = data[currentPosition];
+        }
+        currentPosition++;
+        return (retval+256)%256;
+    }
+    
+    /**
+     * Read an unsigned short.
+     * 
+     * @return An unsigned short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int readUnsignedShort() throws IOException
+    {
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+        {
+            throw new EOFException();
+        }
+        return (ch1 << 8) + (ch2 << 0);
+    }
+    
+    /**
+     * Read an signed short.
+     * 
+     * @return An signed short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public short readSignedShort() throws IOException
+    {
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+        {
+            throw new EOFException();
+        }
+        return (short)((ch1 << 8) + (ch2 << 0));
+    }
+    
+    /**
+     * Close the underlying resources.
+     * 
+     * @throws IOException If there is an error closing the resources.
+     */
+    public void close() throws IOException
+    {
+        data = null;
+    }
+    
+    /**
+     * Seek into the datasource.
+     * 
+     * @param pos The position to seek to.
+     * @throws IOException If there is an error seeking to that position.
+     */
+    public void seek(long pos) throws IOException
+    {
+        currentPosition = (int)pos;
+    }
+    
+    /**
+     * @see java.io.InputStream#read( byte[], int, int )
+     * 
+     * @param b The buffer to write to.
+     * @param off The offset into the buffer.
+     * @param len The length into the buffer.
+     * 
+     * @return The number of bytes read.
+     * 
+     * @throws IOException If there is an error reading from the stream.
+     */
+    public int read(byte[] b,
+            int off,
+            int len)
+     throws IOException
+     {
+        int amountRead = Math.min( len, data.length-currentPosition );
+        System.arraycopy(data,currentPosition,b, off, amountRead );
+        currentPosition+=amountRead;
+        
+        return amountRead;
+     }
+    
+    /**
+     * Get the current position in the stream.
+     * @return The current position in the stream.
+     * @throws IOException If an error occurs while reading the stream.
+     */
+    public long getCurrentPosition() throws IOException
+    {
+        return currentPosition;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public InputStream getOriginalData() throws IOException
+    {
+        return new ByteArrayInputStream( data );
+    }
+}
\ No newline at end of file

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NameRecord.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NameRecord.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NameRecord.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NameRecord.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,228 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A name record in the name table.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class NameRecord
+{
+    /**
+     * A constant for the platform.
+     */
+    public static final int PLATFORM_APPLE_UNICODE = 0;
+    /**
+     * A constant for the platform.
+     */
+    public static final int PLATFORM_MACINTOSH = 1;
+    /**
+     * A constant for the platform.
+     */
+    public static final int PLATFORM_ISO = 2;
+    /**
+     * A constant for the platform.
+     */
+    public static final int PLATFORM_WINDOWS = 3;
+    
+    /**
+     * Platform specific encoding.
+     */
+    public static final int PLATFORM_ENCODING_WINDOWS_UNDEFINED = 0;
+    /**
+     * Platform specific encoding.
+     */
+    public static final int PLATFORM_ENCODING_WINDOWS_UNICODE = 1;
+    
+    /**
+     * A name id.
+     */
+    public static final int NAME_COPYRIGHT = 0;
+    /**
+     * A name id.
+     */
+    public static final int NAME_FONT_FAMILY_NAME = 1;
+    /**
+     * A name id.
+     */
+    public static final int NAME_FONT_SUB_FAMILY_NAME = 2;
+    /**
+     * A name id.
+     */
+    public static final int NAME_UNIQUE_FONT_ID = 3;
+    /**
+     * A name id.
+     */
+    public static final int NAME_FULL_FONT_NAME = 4;
+    /**
+     * A name id.
+     */
+    public static final int NAME_VERSION = 5;
+    /**
+     * A name id.
+     */
+    public static final int NAME_POSTSCRIPT_NAME = 6;
+    /**
+     * A name id.
+     */
+    public static final int NAME_TRADEMARK = 7;
+    
+    
+    
+    private int platformId;
+    private int platformEncodingId;
+    private int languageId;
+    private int nameId;
+    private int stringLength;
+    private int stringOffset;
+    private String string;
+    
+    /**
+     * @return Returns the stringLength.
+     */
+    public int getStringLength()
+    {
+        return stringLength;
+    }
+    /**
+     * @param stringLengthValue The stringLength to set.
+     */
+    public void setStringLength(int stringLengthValue)
+    {
+        this.stringLength = stringLengthValue;
+    }
+    /**
+     * @return Returns the stringOffset.
+     */
+    public int getStringOffset()
+    {
+        return stringOffset;
+    }
+    /**
+     * @param stringOffsetValue The stringOffset to set.
+     */
+    public void setStringOffset(int stringOffsetValue)
+    {
+        this.stringOffset = stringOffsetValue;
+    }
+    
+    /**
+     * @return Returns the languageId.
+     */
+    public int getLanguageId()
+    {
+        return languageId;
+    }
+    /**
+     * @param languageIdValue The languageId to set.
+     */
+    public void setLanguageId(int languageIdValue)
+    {
+        this.languageId = languageIdValue;
+    }
+    /**
+     * @return Returns the nameId.
+     */
+    public int getNameId()
+    {
+        return nameId;
+    }
+    /**
+     * @param nameIdValue The nameId to set.
+     */
+    public void setNameId(int nameIdValue)
+    {
+        this.nameId = nameIdValue;
+    }
+    /**
+     * @return Returns the platformEncodingId.
+     */
+    public int getPlatformEncodingId()
+    {
+        return platformEncodingId;
+    }
+    /**
+     * @param platformEncodingIdValue The platformEncodingId to set.
+     */
+    public void setPlatformEncodingId(int platformEncodingIdValue)
+    {
+        this.platformEncodingId = platformEncodingIdValue;
+    }
+    /**
+     * @return Returns the platformId.
+     */
+    public int getPlatformId()
+    {
+        return platformId;
+    }
+    /**
+     * @param platformIdValue The platformId to set.
+     */
+    public void setPlatformId(int platformIdValue)
+    {
+        this.platformId = platformIdValue;
+    }
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        platformId = data.readUnsignedShort();
+        platformEncodingId = data.readUnsignedShort();
+        languageId = data.readUnsignedShort();
+        nameId = data.readUnsignedShort();
+        stringLength = data.readUnsignedShort();
+        stringOffset = data.readUnsignedShort();
+    }
+    
+    /**
+     * Return a string representation of this class.
+     * 
+     * @return A string for this class.
+     */
+    public String toString()
+    {
+        return 
+            "platform=" + platformId + 
+            " pEncoding=" + platformEncodingId + 
+            " language=" + languageId + 
+            " name=" + nameId;
+    }
+    /**
+     * @return Returns the string.
+     */
+    public String getString()
+    {
+        return string;
+    }
+    /**
+     * @param stringValue The string to set.
+     */
+    public void setString(String stringValue)
+    {
+        this.string = stringValue;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NameRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NamingTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NamingTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NamingTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NamingTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,98 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class NamingTable extends TTFTable
+{
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "name";
+    
+    private List nameRecords = new ArrayList();
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        int formatSelector = data.readUnsignedShort();
+        int numberOfNameRecords = data.readUnsignedShort();
+        int offsetToStartOfStringStorage = data.readUnsignedShort();
+        for( int i=0; i< numberOfNameRecords; i++ )
+        {
+            NameRecord nr = new NameRecord();
+            nr.initData( ttf, data );
+            nameRecords.add( nr );
+        }
+        for( int i=0; i<numberOfNameRecords; i++ )
+        {
+            NameRecord nr = (NameRecord)nameRecords.get( i );
+            data.seek( getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset() );
+            int platform = nr.getPlatformId();
+            int encoding = nr.getPlatformEncodingId();
+            String charset = "ISO-8859-1";
+            if( platform == 3 && encoding == 1 )
+            {
+                charset = "UTF-16";
+            }
+            else if( platform == 2 )
+            {
+                if( encoding == 0 )
+                {
+                    charset = "US-ASCII";
+                }
+                else if( encoding == 1 )
+                {
+                    //not sure is this is correct??
+                    charset = "ISO-10646-1";
+                }
+                else if( encoding == 2 )
+                {
+                    charset = "ISO-8859-1";
+                }
+            }
+            String string = data.readString( nr.getStringLength(), charset );
+            nr.setString( string );
+        }
+    }
+    
+    /**
+     * This will get the name records for this naming table.
+     * 
+     * @return A list of NameRecord objects.
+     */
+    public List getNameRecords()
+    {
+        return nameRecords;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/NamingTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,680 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class OS2WindowsMetricsTable extends TTFTable
+{
+    
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_THIN = 100;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_ULTRA_LIGHT = 200;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_LIGHT = 300;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_NORMAL = 400;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_MEDIUM = 500;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_SEMI_BOLD = 600;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_BOLD = 700;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_EXTRA_BOLD = 800;
+    /**
+     * Weight class constant.
+     */
+    public static final int WEIGHT_CLASS_BLACK = 900;
+    
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_ULTRA_CONDENSED = 1;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_EXTRA_CONDENSED = 2;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_CONDENSED = 3;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_SEMI_CONDENSED = 4;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_MEDIUM = 5;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_SEMI_EXPANDED = 6;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_EXPANDED = 7;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_EXTRA_EXPANDED = 8;
+    /**
+     * Width class constant.
+     */
+    public static final int WIDTH_CLASS_ULTRA_EXPANDED = 9;
+    
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_NO_CLASSIFICATION = 0;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_OLDSTYLE_SERIFS = 1;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_TRANSITIONAL_SERIFS = 2;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_MODERN_SERIFS = 3;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_CLAREDON_SERIFS = 4;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_SLAB_SERIFS = 5;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_FREEFORM_SERIFS = 7;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_SANS_SERIF = 8;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_ORNAMENTALS = 9;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_SCRIPTS = 10;
+    /**
+     * Family class constant.
+     */
+    public static final int FAMILY_CLASS_SYMBOLIC = 12;
+    
+    /**
+     * @return Returns the achVendId.
+     */
+    public String getAchVendId()
+    {
+        return achVendId;
+    }
+    /**
+     * @param achVendIdValue The achVendId to set.
+     */
+    public void setAchVendId(String achVendIdValue)
+    {
+        this.achVendId = achVendIdValue;
+    }
+    /**
+     * @return Returns the averageCharWidth.
+     */
+    public short getAverageCharWidth()
+    {
+        return averageCharWidth;
+    }
+    /**
+     * @param averageCharWidthValue The averageCharWidth to set.
+     */
+    public void setAverageCharWidth(short averageCharWidthValue)
+    {
+        this.averageCharWidth = averageCharWidthValue;
+    }
+    /**
+     * @return Returns the codePageRange1.
+     */
+    public long getCodePageRange1()
+    {
+        return codePageRange1;
+    }
+    /**
+     * @param codePageRange1Value The codePageRange1 to set.
+     */
+    public void setCodePageRange1(long codePageRange1Value)
+    {
+        this.codePageRange1 = codePageRange1Value;
+    }
+    /**
+     * @return Returns the codePageRange2.
+     */
+    public long getCodePageRange2()
+    {
+        return codePageRange2;
+    }
+    /**
+     * @param codePageRange2Value The codePageRange2 to set.
+     */
+    public void setCodePageRange2(long codePageRange2Value)
+    {
+        this.codePageRange2 = codePageRange2Value;
+    }
+    /**
+     * @return Returns the familyClass.
+     */
+    public short getFamilyClass()
+    {
+        return familyClass;
+    }
+    /**
+     * @param familyClassValue The familyClass to set.
+     */
+    public void setFamilyClass(short familyClassValue)
+    {
+        this.familyClass = familyClassValue;
+    }
+    /**
+     * @return Returns the firstCharIndex.
+     */
+    public int getFirstCharIndex()
+    {
+        return firstCharIndex;
+    }
+    /**
+     * @param firstCharIndexValue The firstCharIndex to set.
+     */
+    public void setFirstCharIndex(int firstCharIndexValue)
+    {
+        this.firstCharIndex = firstCharIndexValue;
+    }
+    /**
+     * @return Returns the fsSelection.
+     */
+    public int getFsSelection()
+    {
+        return fsSelection;
+    }
+    /**
+     * @param fsSelectionValue The fsSelection to set.
+     */
+    public void setFsSelection(int fsSelectionValue)
+    {
+        this.fsSelection = fsSelectionValue;
+    }
+    /**
+     * @return Returns the fsType.
+     */
+    public short getFsType()
+    {
+        return fsType;
+    }
+    /**
+     * @param fsTypeValue The fsType to set.
+     */
+    public void setFsType(short fsTypeValue)
+    {
+        this.fsType = fsTypeValue;
+    }
+    /**
+     * @return Returns the lastCharIndex.
+     */
+    public int getLastCharIndex()
+    {
+        return lastCharIndex;
+    }
+    /**
+     * @param lastCharIndexValue The lastCharIndex to set.
+     */
+    public void setLastCharIndex(int lastCharIndexValue)
+    {
+        this.lastCharIndex = lastCharIndexValue;
+    }
+    /**
+     * @return Returns the panose.
+     */
+    public byte[] getPanose()
+    {
+        return panose;
+    }
+    /**
+     * @param panoseValue The panose to set.
+     */
+    public void setPanose(byte[] panoseValue)
+    {
+        this.panose = panoseValue;
+    }
+    /**
+     * @return Returns the strikeoutPosition.
+     */
+    public short getStrikeoutPosition()
+    {
+        return strikeoutPosition;
+    }
+    /**
+     * @param strikeoutPositionValue The strikeoutPosition to set.
+     */
+    public void setStrikeoutPosition(short strikeoutPositionValue)
+    {
+        this.strikeoutPosition = strikeoutPositionValue;
+    }
+    /**
+     * @return Returns the strikeoutSize.
+     */
+    public short getStrikeoutSize()
+    {
+        return strikeoutSize;
+    }
+    /**
+     * @param strikeoutSizeValue The strikeoutSize to set.
+     */
+    public void setStrikeoutSize(short strikeoutSizeValue)
+    {
+        this.strikeoutSize = strikeoutSizeValue;
+    }
+    /**
+     * @return Returns the subscriptXOffset.
+     */
+    public short getSubscriptXOffset()
+    {
+        return subscriptXOffset;
+    }
+    /**
+     * @param subscriptXOffsetValue The subscriptXOffset to set.
+     */
+    public void setSubscriptXOffset(short subscriptXOffsetValue)
+    {
+        this.subscriptXOffset = subscriptXOffsetValue;
+    }
+    /**
+     * @return Returns the subscriptXSize.
+     */
+    public short getSubscriptXSize()
+    {
+        return subscriptXSize;
+    }
+    /**
+     * @param subscriptXSizeValue The subscriptXSize to set.
+     */
+    public void setSubscriptXSize(short subscriptXSizeValue)
+    {
+        this.subscriptXSize = subscriptXSizeValue;
+    }
+    /**
+     * @return Returns the subscriptYOffset.
+     */
+    public short getSubscriptYOffset()
+    {
+        return subscriptYOffset;
+    }
+    /**
+     * @param subscriptYOffsetValue The subscriptYOffset to set.
+     */
+    public void setSubscriptYOffset(short subscriptYOffsetValue)
+    {
+        this.subscriptYOffset = subscriptYOffsetValue;
+    }
+    /**
+     * @return Returns the subscriptYSize.
+     */
+    public short getSubscriptYSize()
+    {
+        return subscriptYSize;
+    }
+    /**
+     * @param subscriptYSizeValue The subscriptYSize to set.
+     */
+    public void setSubscriptYSize(short subscriptYSizeValue)
+    {
+        this.subscriptYSize = subscriptYSizeValue;
+    }
+    /**
+     * @return Returns the superscriptXOffset.
+     */
+    public short getSuperscriptXOffset()
+    {
+        return superscriptXOffset;
+    }
+    /**
+     * @param superscriptXOffsetValue The superscriptXOffset to set.
+     */
+    public void setSuperscriptXOffset(short superscriptXOffsetValue)
+    {
+        this.superscriptXOffset = superscriptXOffsetValue;
+    }
+    /**
+     * @return Returns the superscriptXSize.
+     */
+    public short getSuperscriptXSize()
+    {
+        return superscriptXSize;
+    }
+    /**
+     * @param superscriptXSizeValue The superscriptXSize to set.
+     */
+    public void setSuperscriptXSize(short superscriptXSizeValue)
+    {
+        this.superscriptXSize = superscriptXSizeValue;
+    }
+    /**
+     * @return Returns the superscriptYOffset.
+     */
+    public short getSuperscriptYOffset()
+    {
+        return superscriptYOffset;
+    }
+    /**
+     * @param superscriptYOffsetValue The superscriptYOffset to set.
+     */
+    public void setSuperscriptYOffset(short superscriptYOffsetValue)
+    {
+        this.superscriptYOffset = superscriptYOffsetValue;
+    }
+    /**
+     * @return Returns the superscriptYSize.
+     */
+    public short getSuperscriptYSize()
+    {
+        return superscriptYSize;
+    }
+    /**
+     * @param superscriptYSizeValue The superscriptYSize to set.
+     */
+    public void setSuperscriptYSize(short superscriptYSizeValue)
+    {
+        this.superscriptYSize = superscriptYSizeValue;
+    }
+    /**
+     * @return Returns the typeLineGap.
+     */
+    public int getTypeLineGap()
+    {
+        return typeLineGap;
+    }
+    /**
+     * @param typeLineGapValue The typeLineGap to set.
+     */
+    public void setTypeLineGap(int typeLineGapValue)
+    {
+        this.typeLineGap = typeLineGapValue;
+    }
+    /**
+     * @return Returns the typoAscender.
+     */
+    public int getTypoAscender()
+    {
+        return typoAscender;
+    }
+    /**
+     * @param typoAscenderValue The typoAscender to set.
+     */
+    public void setTypoAscender(int typoAscenderValue)
+    {
+        this.typoAscender = typoAscenderValue;
+    }
+    /**
+     * @return Returns the typoDescender.
+     */
+    public int getTypoDescender()
+    {
+        return typoDescender;
+    }
+    /**
+     * @param typoDescenderValue The typoDescender to set.
+     */
+    public void setTypoDescender(int typoDescenderValue)
+    {
+        this.typoDescender = typoDescenderValue;
+    }
+    /**
+     * @return Returns the unicodeRange1.
+     */
+    public long getUnicodeRange1()
+    {
+        return unicodeRange1;
+    }
+    /**
+     * @param unicodeRange1Value The unicodeRange1 to set.
+     */
+    public void setUnicodeRange1(long unicodeRange1Value)
+    {
+        this.unicodeRange1 = unicodeRange1Value;
+    }
+    /**
+     * @return Returns the unicodeRange2.
+     */
+    public long getUnicodeRange2()
+    {
+        return unicodeRange2;
+    }
+    /**
+     * @param unicodeRange2Value The unicodeRange2 to set.
+     */
+    public void setUnicodeRange2(long unicodeRange2Value)
+    {
+        this.unicodeRange2 = unicodeRange2Value;
+    }
+    /**
+     * @return Returns the unicodeRange3.
+     */
+    public long getUnicodeRange3()
+    {
+        return unicodeRange3;
+    }
+    /**
+     * @param unicodeRange3Value The unicodeRange3 to set.
+     */
+    public void setUnicodeRange3(long unicodeRange3Value)
+    {
+        this.unicodeRange3 = unicodeRange3Value;
+    }
+    /**
+     * @return Returns the unicodeRange4.
+     */
+    public long getUnicodeRange4()
+    {
+        return unicodeRange4;
+    }
+    /**
+     * @param unicodeRange4Value The unicodeRange4 to set.
+     */
+    public void setUnicodeRange4(long unicodeRange4Value)
+    {
+        this.unicodeRange4 = unicodeRange4Value;
+    }
+    /**
+     * @return Returns the version.
+     */
+    public int getVersion()
+    {
+        return version;
+    }
+    /**
+     * @param versionValue The version to set.
+     */
+    public void setVersion(int versionValue)
+    {
+        this.version = versionValue;
+    }
+    /**
+     * @return Returns the weightClass.
+     */
+    public int getWeightClass()
+    {
+        return weightClass;
+    }
+    /**
+     * @param weightClassValue The weightClass to set.
+     */
+    public void setWeightClass(int weightClassValue)
+    {
+        this.weightClass = weightClassValue;
+    }
+    /**
+     * @return Returns the widthClass.
+     */
+    public int getWidthClass()
+    {
+        return widthClass;
+    }
+    /**
+     * @param widthClassValue The widthClass to set.
+     */
+    public void setWidthClass(int widthClassValue)
+    {
+        this.widthClass = widthClassValue;
+    }
+    /**
+     * @return Returns the winAscent.
+     */
+    public int getWinAscent()
+    {
+        return winAscent;
+    }
+    /**
+     * @param winAscentValue The winAscent to set.
+     */
+    public void setWinAscent(int winAscentValue)
+    {
+        this.winAscent = winAscentValue;
+    }
+    /**
+     * @return Returns the winDescent.
+     */
+    public int getWinDescent()
+    {
+        return winDescent;
+    }
+    /**
+     * @param winDescentValue The winDescent to set.
+     */
+    public void setWinDescent(int winDescentValue)
+    {
+        this.winDescent = winDescentValue;
+    }
+    private int version;
+    private short averageCharWidth;
+    private int weightClass;
+    private int widthClass;
+    private short fsType;
+    private short subscriptXSize;
+    private short subscriptYSize;
+    private short subscriptXOffset;
+    private short subscriptYOffset;
+    private short superscriptXSize;
+    private short superscriptYSize;
+    private short superscriptXOffset;
+    private short superscriptYOffset;
+    private short strikeoutSize;
+    private short strikeoutPosition;
+    private short familyClass;
+    private byte[] panose = new byte[10];
+    private long unicodeRange1;
+    private long unicodeRange2;
+    private long unicodeRange3;
+    private long unicodeRange4;
+    private String achVendId;
+    private int fsSelection;
+    private int firstCharIndex;
+    private int lastCharIndex;
+    private int typoAscender;
+    private int typoDescender;
+    private int typeLineGap;
+    private int winAscent;
+    private int winDescent;
+    private long codePageRange1 = -1;
+    private long codePageRange2 = -1;
+    
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "OS/2";
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        version = data.readUnsignedShort();
+        averageCharWidth = data.readSignedShort();
+        weightClass = data.readUnsignedShort();
+        widthClass = data.readUnsignedShort();
+        fsType = data.readSignedShort();
+        subscriptXSize = data.readSignedShort();
+        subscriptYSize = data.readSignedShort();
+        subscriptXOffset = data.readSignedShort();
+        subscriptYOffset = data.readSignedShort();
+        superscriptXSize = data.readSignedShort();
+        superscriptYSize = data.readSignedShort();
+        superscriptXOffset = data.readSignedShort();
+        superscriptYOffset = data.readSignedShort();
+        strikeoutSize = data.readSignedShort();
+        strikeoutPosition = data.readSignedShort();
+        familyClass = data.readSignedShort();
+        panose = data.read( 10 );
+        unicodeRange1 = data.readUnsignedInt();
+        unicodeRange2 = data.readUnsignedInt();
+        unicodeRange3 = data.readUnsignedInt();
+        unicodeRange4 = data.readUnsignedInt();
+        achVendId = data.readString( 4 );
+        fsSelection = data.readUnsignedShort();
+        firstCharIndex = data.readUnsignedShort();
+        lastCharIndex = data.readUnsignedShort();
+        typoAscender = data.readSignedShort();
+        typoDescender = data.readSignedShort();
+        typeLineGap = data.readSignedShort();
+        winAscent = data.readUnsignedShort();
+        winDescent = data.readUnsignedShort();
+        if( version >= 1 )
+        {
+            codePageRange1 = data.readUnsignedInt();
+            codePageRange2 = data.readUnsignedInt();
+        }
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,288 @@
+/*
+ * 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.ttf;
+
+import java.io.IOException;
+
+import org.apache.fontbox.encoding.MacRomanEncoding;
+
+/**
+ * A table in a true type font.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public class PostScriptTable extends TTFTable
+{
+    private float formatType;
+    private float italicAngle;
+    private short underlinePosition;
+    private short underlineThickness;
+    private long isFixedPitch;
+    private long minMemType42;
+    private long maxMemType42;
+    private long mimMemType1;
+    private long maxMemType1;
+    private String[] glyphNames = null;
+    
+    /**
+     * A tag that identifies this table type.
+     */
+    public static final String TAG = "post";
+    
+    /**
+     * This will read the required data from the stream.
+     * 
+     * @param ttf The font that is being read.
+     * @param data The stream to read the data from.
+     * @throws IOException If there is an error reading the data.
+     */
+    public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+    {
+        MaximumProfileTable maxp = ttf.getMaximumProfile();
+        formatType = data.read32Fixed();
+        italicAngle = data.read32Fixed();
+        underlinePosition = data.readSignedShort();
+        underlineThickness = data.readSignedShort();
+        isFixedPitch = data.readUnsignedInt();
+        minMemType42 = data.readUnsignedInt();
+        maxMemType42 = data.readUnsignedInt();
+        mimMemType1 = data.readUnsignedInt();
+        maxMemType1 = data.readUnsignedInt();
+        MacRomanEncoding encoding = new MacRomanEncoding();
+        
+        
+        if( formatType == 1.0f )
+        {
+            /*
+             * This TrueType font file contains exactly the 258 glyphs in the standard 
+             * Macintosh TrueType.
+             */
+            glyphNames = new String[258];
+            for( int i=0; i<glyphNames.length; i++)
+            {
+                String name = encoding.getName( i );
+                if( name != null )
+                {
+                    glyphNames[i] = name;
+                }
+            }
+        }
+        else if( formatType == 2.0f )
+        {
+            int numGlyphs = data.readUnsignedShort();
+            int[] glyphNameIndex = new int[numGlyphs];
+            glyphNames = new String[ numGlyphs ];
+            int maxIndex = Integer.MIN_VALUE;
+            for( int i=0; i<numGlyphs; i++ )
+            {
+                int index = data.readUnsignedShort();
+                glyphNameIndex[i] = index;
+                maxIndex = Math.max( maxIndex, index );
+            }
+            String[] nameArray = null;
+            if( maxIndex >= 258 )
+            {
+                nameArray = new String[ maxIndex-258 +1 ];
+                for( int i=0; i<maxIndex-258+1; i++ )
+                {
+                    int numberOfChars = data.read();
+                    nameArray[i]=data.readString( numberOfChars );
+                }
+            }
+            for( int i=0; i<numGlyphs; i++ )
+            {
+                int index = glyphNameIndex[i];
+                if( index < 258 )
+                {
+                    glyphNames[i] = encoding.getName( index );
+                }
+                else if( index >= 258 && index <= 32767 )
+                {
+                    glyphNames[i] = nameArray[index-258];
+                }
+                else
+                {
+                    throw new IOException( "Unknown glyph name index:" + index );
+                }
+            }
+        }
+        else if( formatType == 2.5f )
+        {
+            int[] glyphNameIndex = new int[maxp.getNumGlyphs()];
+            for( int i=0; i<glyphNameIndex.length; i++)
+            {
+                int offset = data.readSignedByte();
+                glyphNameIndex[i] = i+1+offset;
+            }
+            glyphNames = new String[glyphNameIndex.length];
+            for( int i=0; i<glyphNames.length; i++)
+            {
+                String name = encoding.getName( glyphNameIndex[i] );
+                if( name != null )
+                {
+                    glyphNames[i] = name;
+                }
+            }
+            
+        }
+        else if( formatType == 3.0f )
+        {
+            //no postscript information is provided.
+        }
+    }
+    /**
+     * @return Returns the formatType.
+     */
+    public float getFormatType()
+    {
+        return formatType;
+    }
+    /**
+     * @param formatTypeValue The formatType to set.
+     */
+    public void setFormatType(float formatTypeValue)
+    {
+        this.formatType = formatTypeValue;
+    }
+    /**
+     * @return Returns the isFixedPitch.
+     */
+    public long getIsFixedPitch()
+    {
+        return isFixedPitch;
+    }
+    /**
+     * @param isFixedPitchValue The isFixedPitch to set.
+     */
+    public void setIsFixedPitch(long isFixedPitchValue)
+    {
+        this.isFixedPitch = isFixedPitchValue;
+    }
+    /**
+     * @return Returns the italicAngle.
+     */
+    public float getItalicAngle()
+    {
+        return italicAngle;
+    }
+    /**
+     * @param italicAngleValue The italicAngle to set.
+     */
+    public void setItalicAngle(float italicAngleValue)
+    {
+        this.italicAngle = italicAngleValue;
+    }
+    /**
+     * @return Returns the maxMemType1.
+     */
+    public long getMaxMemType1()
+    {
+        return maxMemType1;
+    }
+    /**
+     * @param maxMemType1Value The maxMemType1 to set.
+     */
+    public void setMaxMemType1(long maxMemType1Value)
+    {
+        this.maxMemType1 = maxMemType1Value;
+    }
+    /**
+     * @return Returns the maxMemType42.
+     */
+    public long getMaxMemType42()
+    {
+        return maxMemType42;
+    }
+    /**
+     * @param maxMemType42Value The maxMemType42 to set.
+     */
+    public void setMaxMemType42(long maxMemType42Value)
+    {
+        this.maxMemType42 = maxMemType42Value;
+    }
+    /**
+     * @return Returns the mimMemType1.
+     */
+    public long getMimMemType1()
+    {
+        return mimMemType1;
+    }
+    /**
+     * @param mimMemType1Value The mimMemType1 to set.
+     */
+    public void setMimMemType1(long mimMemType1Value)
+    {
+        this.mimMemType1 = mimMemType1Value;
+    }
+    /**
+     * @return Returns the minMemType42.
+     */
+    public long getMinMemType42()
+    {
+        return minMemType42;
+    }
+    /**
+     * @param minMemType42Value The minMemType42 to set.
+     */
+    public void setMinMemType42(long minMemType42Value)
+    {
+        this.minMemType42 = minMemType42Value;
+    }
+    /**
+     * @return Returns the underlinePosition.
+     */
+    public short getUnderlinePosition()
+    {
+        return underlinePosition;
+    }
+    /**
+     * @param underlinePositionValue The underlinePosition to set.
+     */
+    public void setUnderlinePosition(short underlinePositionValue)
+    {
+        this.underlinePosition = underlinePositionValue;
+    }
+    /**
+     * @return Returns the underlineThickness.
+     */
+    public short getUnderlineThickness()
+    {
+        return underlineThickness;
+    }
+    /**
+     * @param underlineThicknessValue The underlineThickness to set.
+     */
+    public void setUnderlineThickness(short underlineThicknessValue)
+    {
+        this.underlineThickness = underlineThicknessValue;
+    }
+    /**
+     * @return Returns the glyphNames.
+     */
+    public String[] getGlyphNames()
+    {
+        return glyphNames;
+    }
+    /**
+     * @param glyphNamesValue The glyphNames to set.
+     */
+    public void setGlyphNames(String[] glyphNamesValue)
+    {
+        this.glyphNames = glyphNamesValue;
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,168 @@
+/*
+ * 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.ttf;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+
+/**
+ * An implementation of the TTFDataStream that goes against a RAF.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.2 $
+ */
+public class RAFDataStream extends TTFDataStream 
+{
+    private RandomAccessFile raf = null;
+    private File ttfFile = null;
+    
+    /**
+     * Constructor.
+     * 
+     * @param name The raf file.
+     * @param mode The mode to open the RAF.
+     * 
+     * @throws FileNotFoundException If there is a problem creating the RAF.
+     * 
+     * @see RandomAccessFile#RandomAccessFile( String, String )
+     */
+    public RAFDataStream(String name, String mode) throws FileNotFoundException
+    {
+        this( new File( name ), mode );
+    }
+    
+    /**
+     * Constructor.
+     * 
+     * @param file The raf file.
+     * @param mode The mode to open the RAF.
+     * 
+     * @throws FileNotFoundException If there is a problem creating the RAF.
+     * 
+     * @see RandomAccessFile#RandomAccessFile( File, String )
+     */
+    public RAFDataStream(File file, String mode) throws FileNotFoundException
+    {
+        raf = new RandomAccessFile( file, mode );
+        ttfFile = file;
+    }
+    
+    /**
+     * Read an signed short.
+     * 
+     * @return An signed short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public short readSignedShort() throws IOException
+    {
+        return raf.readShort();
+    }
+    
+    /**
+     * Get the current position in the stream.
+     * @return The current position in the stream.
+     * @throws IOException If an error occurs while reading the stream.
+     */
+    public long getCurrentPosition() throws IOException
+    {
+        return raf.getFilePointer();
+    }
+    
+    /**
+     * Close the underlying resources.
+     * 
+     * @throws IOException If there is an error closing the resources.
+     */
+    public void close() throws IOException
+    {
+        raf.close();
+        raf = null;
+    }
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int read() throws IOException
+    {
+        return raf.read();
+    }
+    
+    /**
+     * Read an unsigned short.
+     * 
+     * @return An unsigned short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int readUnsignedShort() throws IOException
+    {
+        return raf.readUnsignedShort();
+    }
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public long readLong() throws IOException
+    {
+        return raf.readLong();
+    }
+    
+    /**
+     * Seek into the datasource.
+     * 
+     * @param pos The position to seek to.
+     * @throws IOException If there is an error seeking to that position.
+     */
+    public void seek(long pos) throws IOException
+    {
+        raf.seek( pos );
+    }
+    
+    /**
+     * @see java.io.InputStream#read( byte[], int, int )
+     * 
+     * @param b The buffer to write to.
+     * @param off The offset into the buffer.
+     * @param len The length into the buffer.
+     * 
+     * @return The number of bytes read.
+     * 
+     * @throws IOException If there is an error reading from the stream.
+     */
+    public int read(byte[] b,
+            int off,
+            int len)
+     throws IOException
+     {
+        return raf.read(b,off,len);
+     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public InputStream getOriginalData() throws IOException
+    {
+        return new FileInputStream( ttfFile );
+    }
+}

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java?rev=752669&view=auto
==============================================================================
--- incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java (added)
+++ incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java Wed Mar 11 22:40:33 2009
@@ -0,0 +1,233 @@
+/*
+ * 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.ttf;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+/**
+ * An interface into a data stream.
+ * 
+ * @author Ben Litchfield (ben@benlitchfield.com)
+ * @version $Revision: 1.1 $
+ */
+public abstract class TTFDataStream 
+{
+
+    /**
+     * Read a 16.16 fixed value, where the first 16 bits are the decimal and the last
+     * 16 bits are the fraction.
+     * @return A 32 bit value.
+     * @throws IOException If there is an error reading the data.
+     */
+    public float read32Fixed() throws IOException
+    {
+        float retval = 0;
+        retval = readSignedShort();
+        retval += (readUnsignedShort()/65536);
+        return retval;
+    }
+    
+    /**
+     * Read a fixed length ascii string.
+     * @param length The length of the string to read.
+     * @return A string of the desired length.
+     * @throws IOException If there is an error reading the data.
+     */
+    public String readString( int length ) throws IOException
+    {
+        return readString( length, "ISO-8859-1" );
+    }
+    
+    /**
+     * Read a fixed length ascii string.
+     * @param length The length of the string to read in bytes.
+     * @param charset The expected character set of the string.
+     * @return A string of the desired length.
+     * @throws IOException If there is an error reading the data.
+     */
+    public String readString( int length, String charset ) throws IOException
+    {
+        byte[] buffer = read( length );
+        return new String(buffer, charset);
+    }
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public abstract int read() throws IOException;
+    
+    /**
+     * Read an unsigned byte.
+     * @return An unsigned byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public abstract long readLong() throws IOException;
+    
+    
+    /**
+     * Read a signed byte.
+     * @return A signed byte.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int readSignedByte() throws IOException
+    {
+        int signedByte = read();
+        return signedByte < 127 ? signedByte : signedByte-256;
+    }
+    
+    /**
+     * Read an unsigned integer.
+     * @return An unsiged integer.
+     * @throws IOException If there is an error reading the data.
+     */
+    public long readUnsignedInt() throws IOException
+    {
+        long byte1 = read();
+        long byte2 = read();
+        long byte3 = read();
+        long byte4 = read();
+        if( byte4 < 0 )
+        {
+            throw new EOFException();
+        }
+        return (byte1 << 24) + (byte2 << 16) + (byte3 << 8) + (byte4 << 0);
+    }
+    
+    /**
+     * Read an unsigned short.
+     * 
+     * @return An unsigned short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public abstract int readUnsignedShort() throws IOException;
+    
+    /**
+     * Read an unsigned short array.
+     * 
+     * @param length The length of the array to read.
+     * @return An unsigned short array.
+     * @throws IOException If there is an error reading the data.
+     */
+    public int[] readUnsignedShortArray( int length ) throws IOException
+    {
+        int[] array = new int[ length ];
+        for( int i=0; i<length; i++ )
+        {
+            array[i] = readUnsignedShort();
+        }
+        return array;
+    }
+    
+    /**
+     * Read an signed short.
+     * 
+     * @return An signed short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public abstract short readSignedShort() throws IOException;
+    
+    /**
+     * Read an eight byte international date.
+     * 
+     * @return An signed short.
+     * @throws IOException If there is an error reading the data.
+     */
+    public Calendar readInternationalDate() throws IOException
+    {
+        long secondsSince1904 = readLong();
+        GregorianCalendar cal = new GregorianCalendar( 1904, 0, 1 );
+        long millisFor1904 = cal.getTimeInMillis();
+        millisFor1904 += (secondsSince1904*1000);
+        cal.setTimeInMillis( millisFor1904 );
+        return cal;
+    }
+    
+    /**
+     * Close the underlying resources.
+     * 
+     * @throws IOException If there is an error closing the resources.
+     */
+    public abstract void close() throws IOException;
+    
+    /**
+     * Seek into the datasource.
+     * 
+     * @param pos The position to seek to.
+     * @throws IOException If there is an error seeking to that position.
+     */
+    public abstract void seek(long pos) throws IOException;
+    
+    /**
+     * Read a specific number of bytes from the stream.
+     * @param numberOfBytes The number of bytes to read.
+     * @return The byte buffer.
+     * @throws IOException If there is an error while reading.
+     */
+    public byte[] read( int numberOfBytes ) throws IOException
+    {
+        byte[] data = new byte[ numberOfBytes ];
+        int amountRead = 0;
+        int totalAmountRead = 0;
+        while( (amountRead = read( data, totalAmountRead, numberOfBytes-totalAmountRead ) ) != -1 && 
+               totalAmountRead < numberOfBytes )
+        {
+            totalAmountRead += amountRead;
+            //read at most numberOfBytes bytes from the stream.
+        }
+        return data;
+    }
+    
+    /**
+     * @see java.io.InputStream#read( byte[], int, int )
+     * 
+     * @param b The buffer to write to.
+     * @param off The offset into the buffer.
+     * @param len The length into the buffer.
+     * 
+     * @return The number of bytes read.
+     * 
+     * @throws IOException If there is an error reading from the stream.
+     */
+    public abstract int read(byte[] b,
+            int off,
+            int len)
+     throws IOException;
+    
+    /**
+     * Get the current position in the stream.
+     * @return The current position in the stream.
+     * @throws IOException If an error occurs while reading the stream.
+     */
+    public abstract long getCurrentPosition() throws IOException;
+    
+    /**
+     * This will get the original data file that was used for this
+     * stream.
+     * 
+     * @return The data that was read from.
+     * @throws IOException If there is an issue reading the data.
+     */
+    public abstract InputStream getOriginalData() throws IOException;
+
+}
\ No newline at end of file

Propchange: incubator/pdfbox/fontbox/trunk/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java
------------------------------------------------------------------------------
    svn:eol-style = native