pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1621411 [1/7] - in /pdfbox/trunk: ./ examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ fontbox/src/main/java/org/apache/fontbox/afm/ fontbox/src/main/java/org/apache/fontbox/cff/ fontbox/src/main/java/org/apache/fontbox/cff/charse...
Date Sat, 30 Aug 2014 02:27:00 GMT
Author: jahewson
Date: Sat Aug 30 02:26:57 2014
New Revision: 1621411

URL: http://svn.apache.org/r1621411
Log:
PDFBOX-2262: Merge no-awt branch into trunk

Added:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFCIDFont.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFCIDFont.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFCharset.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFCharset.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFEncoding.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFEncoding.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertCharset.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertCharset.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertEncoding.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertEncoding.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertSubsetCharset.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFExpertSubsetCharset.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFISOAdobeCharset.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFISOAdobeCharset.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/FDSelect.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/FDSelect.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapTable.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/CmapTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/GlyphList.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/GlyphList.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/CMapManager.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/CMapManager.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Equivalent.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Equivalent.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1FontEmbedder.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1FontEmbedder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/CIDType0Glyph2D.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/CIDType0Glyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Vector.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/util/Vector.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontLike.java
      - copied unchanged from r1621410, pdfbox/branches/no-awt/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontLike.java
Removed:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetric.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFontROS.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedFDSelect.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharStringFormatter.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1FontFormatter.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/charset/
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/encoding/
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CMAPEncodingEntry.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CMAPTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubFont.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Mapping.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/SystemFontManager.java
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/Type1CharStringTest.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/AFMEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFBoxCharsetProvider.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/PdfDocEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/conversion/
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMatrix.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFFontManager.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java
    pdfbox/trunk/pdfbox/src/main/resources/META-INF/services/
    pdfbox/trunk/pdfbox/src/main/resources/org/apache/pdfbox/resources/FontMapping.properties
    pdfbox/trunk/pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encoding/package.html
Modified:
    pdfbox/trunk/   (props changed)
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1AfmPfb.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMap.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CodespaceRange.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/HorizontalMetricsTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/NamingTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/type1/Type1Font.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/BoundingBox.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontDirFinder.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMapParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/MacOSRomanEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/MacRomanEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFDocEncodingCharset.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/StandardEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Type1Encoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/WinAnsiEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorAFM.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptorDictionary.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDCalRGB.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Matrix.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/operator/text/ShowTextGlyph.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/ParallelParameterized.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encoding/PDFDocEncodingCharsetTest.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
    pdfbox/trunk/pdfbox/src/test/resources/input/allah2.pdf-sorted.txt
    pdfbox/trunk/pdfbox/src/test/resources/input/allah2.pdf.txt
    pdfbox/trunk/pdfbox/src/test/resources/logging.properties
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/content/PreflightContentStream.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/CIDType0FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/CIDType2FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/SimpleFontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type1FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/CIDType0Container.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/CIDType2Container.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/TrueTypeContainer.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/FontValidationProcess.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java

Propchange: pdfbox/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Aug 30 02:26:57 2014
@@ -0,0 +1,2 @@
+/pdfbox/branches/no-awt:1618517-1621410
+/pdfbox/no-awt:1618514-1618516

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java Sat Aug 30 02:26:57 2014
@@ -28,8 +28,10 @@ import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.PDStream;
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
-import org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font;
+import org.apache.pdfbox.pdmodel.font.PDCIDFont;
+import org.apache.pdfbox.pdmodel.font.PDCIDFontType2;
 import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
 import org.apache.pdfbox.pdmodel.font.PDFontDescriptorDictionary;
 import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
 import org.apache.pdfbox.pdmodel.font.PDType0Font;
@@ -177,12 +179,12 @@ public class ExtractTTFFonts
                     {
                         name = getUniqueFileName(prefix, "ttf");
                     }
-                    writeFont(font, name);
+                    writeFont(font.getFontDescriptor(), name);
                 }
                 else if (font instanceof PDType0Font)
                 {
-                    PDFont descendantFont = ((PDType0Font) font).getDescendantFont();
-                    if (descendantFont instanceof PDCIDFontType2Font)
+                    PDCIDFont descendantFont = ((PDType0Font) font).getDescendantFont();
+                    if (descendantFont instanceof PDCIDFontType2)
                     {
                         String name = null;
                         if (addKey)
@@ -193,7 +195,7 @@ public class ExtractTTFFonts
                         {
                             name = getUniqueFileName(prefix, "ttf");
                         }
-                        writeFont(descendantFont, name);
+                        writeFont(descendantFont.getFontDescriptor(), name);
                     }
                 }
             }
@@ -217,12 +219,12 @@ public class ExtractTTFFonts
 
     }
 
-    private void writeFont(PDFont font, String name) throws IOException
+    private void writeFont(PDFontDescriptor fd, String name) throws IOException
     {
-        PDFontDescriptorDictionary fd = (PDFontDescriptorDictionary) font.getFontDescriptor();
+        PDFontDescriptorDictionary fdd = (PDFontDescriptorDictionary) fd;
         if (fd != null)
         {
-            PDStream ff2Stream = fd.getFontFile2();
+            PDStream ff2Stream = fdd.getFontFile2();
             if (ff2Stream != null)
             {
                 System.out.println("Writing font:" + name);

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1AfmPfb.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1AfmPfb.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1AfmPfb.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldType1AfmPfb.java Sat Aug 30 02:26:57 2014
@@ -17,13 +17,15 @@
 
 package org.apache.pdfbox.examples.pdmodel;
 
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.font.PDType1AfmPfbFont;
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
 
 /**
  * This is an example that creates a simple document
@@ -56,7 +58,7 @@ public class HelloWorldType1AfmPfb
 
             PDPage page = new PDPage();
             doc.addPage(page);
-            PDFont font = new PDType1AfmPfbFont(doc,fontfile);
+            PDFont font = createPDType1AfmPfbFont(doc, fontfile);
 
             PDPageContentStream contentStream = new PDPageContentStream(doc,
                     page);
@@ -78,6 +80,14 @@ public class HelloWorldType1AfmPfb
         }
     }
 
+    private PDType1Font createPDType1AfmPfbFont(PDDocument doc, String afmName) throws IOException
+    {
+        return new PDType1Font(doc,
+                new BufferedInputStream(new FileInputStream(afmName)),
+                new BufferedInputStream(new FileInputStream(afmName.replaceAll(".AFM", "").
+                        replaceAll(".afm", "") + ".pfb")));
+    }
+
     /**
      * This will create a hello world PDF document
      * with a ttf-font.

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java Sat Aug 30 02:26:57 2014
@@ -334,7 +334,7 @@ public class AFMParser
      * 
      * @throws IOException If there is an IO error reading the document.
      */
-    public FontMetric parse() throws IOException
+    public FontMetrics parse() throws IOException
     {
     	return parseFontMetric();
     }
@@ -346,9 +346,9 @@ public class AFMParser
      *
      * @throws IOException If there is an error reading the AFM file.
      */
-    private FontMetric parseFontMetric() throws IOException
+    private FontMetrics parseFontMetric() throws IOException
     {
-        FontMetric fontMetrics = new FontMetric();
+        FontMetrics fontMetrics = new FontMetrics();
         String startFontMetrics = readString();
         if( !START_FONT_METRICS.equals( startFontMetrics ) )
         {
@@ -527,7 +527,7 @@ public class AFMParser
      *
      * @throws IOException If there is an error parsing the data.
      */
-    private void parseKernData( FontMetric fontMetrics ) throws IOException
+    private void parseKernData( FontMetrics fontMetrics ) throws IOException
     {
         String nextCommand;
         while( !(nextCommand = readString()).equals( END_KERN_DATA ) )

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFFont.java Sat Aug 30 02:26:57 2014
@@ -16,127 +16,45 @@
  */
 package org.apache.fontbox.cff;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
-import org.apache.fontbox.afm.FontMetric;
-import org.apache.fontbox.cff.charset.CFFCharset;
-import org.apache.fontbox.cff.encoding.CFFEncoding;
-import org.apache.fontbox.type1.Type1CharStringReader;
-import org.apache.fontbox.type1.Type1Mapping;
+import org.apache.fontbox.util.BoundingBox;
 
 /**
- * This class represents a CFF/Type2 Font.
+ * An Adobe Compact Font Format (CFF) font. Thread safe.
  * 
  * @author Villu Ruusmann
  * @author John Hewson
  */
-public class CFFFont implements Type1CharStringReader
+public abstract class CFFFont
 {
-    private String fontname = null;
-    private Map<String, Object> topDict = new LinkedHashMap<String, Object>();
-    private Map<String, Object> privateDict = new LinkedHashMap<String, Object>();
-    private CFFEncoding fontEncoding = null;
-    private CFFCharset fontCharset = null;
-    private Map<String, byte[]> charStringsDict = new LinkedHashMap<String, byte[]>();
-    private IndexData globalSubrIndex = null;
-    private Map<String, Type2CharString> charStringCache = new HashMap<String, Type2CharString>();
-    private FontMetric fontMetric = null;
-    
+    protected String fontName;
+    protected final Map<String, Object> topDict = new LinkedHashMap<String, Object>();
+    protected CFFCharset charset;
+    protected final List<byte[]> charStrings = new ArrayList<byte[]>();
+    protected IndexData globalSubrIndex;
+
     /**
      * The name of the font.
-     * 
+     *
      * @return the name of the font
      */
     public String getName()
     {
-        return fontname;
+        return fontName;
     }
 
     /**
      * Sets the name of the font.
-     * 
+     *
      * @param name the name of the font
      */
-    public void setName(String name)
-    {
-        fontname = name;
-    }
-
-    /**
-     * Returns the value for the given name from the dictionary.
-     * 
-     * @param name the name of the value
-     * @return the value of the name if available
-     */
-    public Object getProperty(String name)
-    {
-        Object topDictValue = topDict.get(name);
-        if (topDictValue != null)
-        {
-            return topDictValue;
-        }
-        Object privateDictValue = privateDict.get(name);
-        if (privateDictValue != null)
-        {
-            return privateDictValue;
-        }
-        return null;
-    }
-
-    /**
-     * Returns the string value for the given name from the dictionary.
-     * 
-     * @param name the name of the value
-     * @return the string value of the name if available
-     */
-    public String getPropertyAsString(String name)
-    {
-        Object value = getProperty(name);
-        if (value != null && value instanceof String)
-        {
-            return (String)value;
-        }
-        return null;
-    }
-
-    /**
-     * Returns the float value for the given name from the dictionary.
-     * 
-     * @param name the name of the value
-     * @return the float value of the name if available
-     */
-    public float getPropertyAsFloat(String name, float defaultValue)
-    {
-        Object value = getProperty(name);
-        if (value != null && value instanceof Float)
-        {
-            return (Float)value;
-        }
-        return defaultValue;
-    }
-
-    /**
-     * Returns the boolean value for the given name from the dictionary.
-     * 
-     * @param name the name of the value
-     * @return the boolean value of the name if available
-     */
-    public boolean getPropertyAsBoolean(String name, boolean defaultValue)
+    void setName(String name)
     {
-        Object value = getProperty(name);
-        if (value != null && value instanceof Boolean)
-        {
-            return (Boolean)value;
-        }
-        return defaultValue;
+        fontName = name;
     }
 
     /**
@@ -164,183 +82,17 @@ public class CFFFont implements Type1Cha
     }
 
     /**
-     * Adds the given key/value pair to the private dictionary.
-     * 
-     * @param name the given key
-     * @param value the given value
-     */
-    public void addValueToPrivateDict(String name, Object value)
-    {
-        if (value != null)
-        {
-            privateDict.put(name, value);
-        }
-    }
-
-    /**
-     * Returns the private dictionary.
-     * 
-     * @return the dictionary
-     */
-    public Map<String, Object> getPrivateDict()
-    {
-        return privateDict;
-    }
-
-    /**
-     * Get the mappings for the font as Type1Mapping
-     *
-     * @return the Type1Mapping
-     */
-    public Collection<? extends Type1Mapping> getType1Mappings()
-    {
-        return getMappings();
-    }
-
-    /**
-     * Get the mapping (code/SID/charname/bytes) for this font.
-     * 
-     * @return mappings for codes &lt; 256 and for codes &gt;= 256
-     */
-    public Collection<CFFFont.Mapping> getMappings()
-    {
-        List<Mapping> mappings = new ArrayList<Mapping>();
-        Set<String> mappedNames = new HashSet<String>();
-        for (CFFEncoding.Entry entry : fontEncoding.getEntries())
-        {
-            String charName = fontCharset.getName(entry.getSID());
-            // Predefined encoding
-            if (charName == null)
-            {
-                continue;
-            }
-            byte[] bytes = charStringsDict.get(charName);
-            if (bytes == null)
-            {
-                continue;
-            }
-            Mapping mapping = createMapping(entry.getCode(), entry.getSID(), charName, bytes);
-            mappings.add(mapping);
-            mappedNames.add(charName);
-        }
-        if (fontEncoding instanceof CFFParser.EmbeddedEncoding)
-        {
-            CFFParser.EmbeddedEncoding embeddedEncoding = (CFFParser.EmbeddedEncoding) fontEncoding;
-
-            for (CFFParser.EmbeddedEncoding.Supplement supplement : embeddedEncoding.getSupplements())
-            {
-                String charName = fontCharset.getName(supplement.getGlyph());
-                if (charName == null)
-                {
-                    continue;
-                }
-                byte[] bytes = charStringsDict.get(charName);
-                if (bytes == null)
-                {
-                    continue;
-                }
-                Mapping mapping = createMapping(supplement.getCode(), supplement.getGlyph(), charName, bytes);
-                mappings.add(mapping);
-                mappedNames.add(charName);
-            }
-        }
-        // XXX
-        int code = 256;
-        for (CFFCharset.Entry entry : fontCharset.getEntries())
-        {
-            String name = entry.getName();
-            if (mappedNames.contains(name))
-            {
-                continue;
-            }
-            byte[] bytes = this.charStringsDict.get(name);
-            if (bytes == null)
-            {
-                continue;
-            }
-            Mapping mapping = createMapping(code++, entry.getSID(), name, bytes);
-            mappings.add(mapping);
-            mappedNames.add(name);
-        }
-        return mappings;
-    }
-
-    /**
-     * Returns a new mapping. Overridden in subclasses.
-     *
-     * @param code chatacter code
-     * @param sid SID
-     * @param name glyph name
-     * @param bytes charstring bytes
-     * @return a new mapping object
-     */
-    protected Mapping createMapping(int code, int sid, String name, byte[] bytes)
-    {
-        Mapping mapping = new Mapping();
-        mapping.setCode(code);
-        mapping.setSID(sid);
-        mapping.setName(name);
-        mapping.setBytes(bytes);
-        return  mapping;
-    }
-
-    /**
-     * Return the Width value of the given Glyph identifier.
-     * 
-     * @param sid SID
-     * @return -1 if the SID is missing from the Font.
-     * @throws IOException if something went wrong
-     * 
-     */
-    public int getWidth(int sid) throws IOException
-    {
-        for (Mapping m : getMappings())
-        {
-            if (m.getSID() == sid)
-            {
-                Type1CharString charstring = m.getType1CharString();
-                return charstring.getWidth();
-            }
-        }
-
-        // SID not found, return the nodef width
-        int nominalWidth = getNominalWidthX(sid);
-        int defaultWidth = getDefaultWidthX(sid);
-        return getNotDefWidth(defaultWidth, nominalWidth);
-    }
-
-    /**
-     * Returns the witdth of the .notdef character.
-     * 
-     * @param defaultWidth default width
-     * @param nominalWidth nominal width
-     * @return the calculated width for the .notdef character
-     * @throws IOException if something went wrong
-     */
-    protected int getNotDefWidth(int defaultWidth, int nominalWidth) throws IOException
-    {
-        Type1CharString charstring = getType1CharString(".notdef");
-        return charstring.getWidth() != 0 ? charstring.getWidth() + nominalWidth : defaultWidth;
-    }
-
-    /**
-     * Returns the CFFEncoding of the font.
-     * 
-     * @return the encoding
+     * Returns the FontMatrix.
      */
-    public CFFEncoding getEncoding()
-    {
-        return fontEncoding;
-    }
+    public abstract List<Number> getFontMatrix();
 
     /**
-     * Sets the CFFEncoding of the font.
-     * 
-     * @param encoding the given CFFEncoding
+     * Returns the FontBBox.
      */
-    public void setEncoding(CFFEncoding encoding)
+    public BoundingBox getFontBBox()
     {
-        fontEncoding = encoding;
+        List<Number> numbers = (List<Number>)topDict.get("FontBBox");
+        return new BoundingBox(numbers);
     }
 
     /**
@@ -350,7 +102,7 @@ public class CFFFont implements Type1Cha
      */
     public CFFCharset getCharset()
     {
-        return fontCharset;
+        return charset;
     }
 
     /**
@@ -358,126 +110,27 @@ public class CFFFont implements Type1Cha
      * 
      * @param charset the given CFFCharset
      */
-    public void setCharset(CFFCharset charset)
-    {
-        fontCharset = charset;
-    }
-
-    /**
-     * Returns the FontMetric of the font.
-     * 
-     * @return the font metrics
-     */
-    public FontMetric getFontMetric()
-    {
-        return fontMetric;
-    }
-
-    /**
-     * Sets the FontMetric of the font.
-     * 
-     * @param metric the given FontMetric 
-     */
-    public void setFontMetric(FontMetric metric)
-    {
-        fontMetric = metric;
-    }
-
-    /**
-     * Returns the SID for a given glyph name.
-     * @param name glyph name
-     * @return SID
-     */
-    private int getSIDForName(String name)
+    void setCharset(CFFCharset charset)
     {
-        int sid = 0; // .notdef
-        for (Mapping m : getMappings())
-        {
-            if (m.getName().equals(name))
-            {
-                sid = m.getSID();
-                break;
-            }
-        }
-      return sid;
+        this.charset = charset;
     }
 
     /**
      * Returns the character strings dictionary.
-     * 
-     * @return the dictionary
-     */
-    public Map<String, byte[]> getCharStringsDict()
-    {
-        return charStringsDict;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Type1CharString getType1CharString(String name) throws IOException
-    {
-        return getType1CharString(name, getSIDForName(name));
-    }
-
-    /**
-     * Returns the Type 1 CharString for the character with the given name and SID.
-     *
-     * @return Type 1 CharString
-     */
-    private Type1CharString getType1CharString(String name, int sid) throws IOException
-    {
-        Type2CharString type2 = charStringCache.get(name);
-        if (type2 == null)
-        {
-            Type2CharStringParser parser = new Type2CharStringParser(fontname, name);
-            List<Object> type2seq = parser.parse(charStringsDict.get(name), globalSubrIndex, getLocalSubrIndex(sid));
-            type2 = new Type2CharString(this, fontname, name, type2seq, getDefaultWidthX(sid), getNominalWidthX(sid));
-            charStringCache.put(name, type2);
-        }
-        return type2;
-    }
-
-    /**
-     * Returns the defaultWidthX for the given SID.
      *
-     * @param sid SID
-     * @return defaultWidthX
-     */
-    protected int getDefaultWidthX(int sid)
-    {
-        Number num = (Number)getProperty("defaultWidthX");
-        if (num == null)
-        {
-            return 1000;
-        }
-        return num.intValue();
-    }
-
-    /**
-     * Returns the nominalWidthX for the given SID.
-     *
-     * @param sid SID
-     * @return defaultWidthX
+     * @return the dictionary
      */
-    protected int getNominalWidthX(int sid)
+    List<byte[]> getCharStringBytes()
     {
-        Number num = (Number)getProperty("nominalWidthX");
-        if (num == null)
-        {
-            return 0;
-        }
-        return num.intValue();
+        return charStrings;
     }
 
     /**
-     * {@inheritDoc}
+     * Returns the number of charstrings in the font.
      */
-    public String toString()
+    public int getNumCharStrings()
     {
-        return getClass().getName() + "[name=" + fontname + ", topDict=" + topDict + ", privateDict=" + privateDict
-                + ", encoding=" + fontEncoding + ", charset=" + fontCharset + ", charStringsDict=" + charStringsDict
-                + "]";
+        return charStrings.size();
     }
 
     /**
@@ -485,7 +138,7 @@ public class CFFFont implements Type1Cha
      * 
      * @param globalSubrIndexValue the IndexData object containing the global subroutines
      */
-    public void setGlobalSubrIndex(IndexData globalSubrIndexValue)
+    void setGlobalSubrIndex(IndexData globalSubrIndexValue)
     {
         globalSubrIndex = globalSubrIndexValue;
     }
@@ -500,83 +153,11 @@ public class CFFFont implements Type1Cha
         return globalSubrIndex;
     }
 
-    /**
-     * Returns the local subroutine index data.
-     * 
-     * @return the dictionary
-     */
-    protected IndexData getLocalSubrIndex(int sid)
-    {
-        return (IndexData)privateDict.get("Subrs");
-    }
-
-    public class Mapping implements Type1Mapping
+    @Override
+    public String toString()
     {
-        private int mappedCode;
-        private int mappedSID;
-        private String mappedName;
-        private byte[] mappedBytes;
-
-        /**
-         * {@inheritDoc}
-         */
-        public Type1CharString getType1CharString() throws IOException
-        {
-            return CFFFont.this.getType1CharString(mappedName, mappedSID);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public int getCode()
-        {
-            return mappedCode;
-        }
-
-        protected void setCode(int code)
-        {
-            mappedCode = code;
-        }
-
-        /**
-         * Gets the value for the SID.
-         *
-         * @return the SID
-         */
-        public int getSID()
-        {
-            return mappedSID;
-        }
-
-        protected void setSID(int sid)
-        {
-            this.mappedSID = sid;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public String getName()
-        {
-            return mappedName;
-        }
-
-        protected void setName(String name)
-        {
-            this.mappedName = name;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public byte[] getBytes()
-        {
-            return mappedBytes;
-        }
-
-        protected void setBytes(byte[] bytes)
-        {
-            this.mappedBytes = bytes;
-        }
+        return getClass().getSimpleName() + "[name=" + fontName + ", topDict=" + topDict
+                + ", charset=" + charset + ", charStrings=" + charStrings
+                + "]";
     }
 }

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Sat Aug 30 02:26:57 2014
@@ -16,29 +16,13 @@
  */
 package org.apache.fontbox.cff;
 
-import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-
-import org.apache.fontbox.afm.CharMetric;
-import org.apache.fontbox.afm.FontMetric;
-import org.apache.fontbox.cff.CFFFont.Mapping;
-import org.apache.fontbox.cff.charset.CFFCharset;
-import org.apache.fontbox.cff.charset.CFFExpertCharset;
-import org.apache.fontbox.cff.charset.CFFExpertSubsetCharset;
-import org.apache.fontbox.cff.charset.CFFISOAdobeCharset;
-import org.apache.fontbox.cff.encoding.CFFEncoding;
-import org.apache.fontbox.cff.encoding.CFFExpertEncoding;
-import org.apache.fontbox.cff.encoding.CFFStandardEncoding;
-import org.apache.fontbox.util.BoundingBox;
 
 /**
  * This class represents a parser for a CFF font. 
@@ -56,6 +40,7 @@ public class CFFParser
     private IndexData nameIndex = null;
     private IndexData topDictIndex = null;
     private IndexData stringIndex = null;
+    private String debugFontName; // for debugging only
 
     /**
      * Parsing CFF Font using a byte array as input.
@@ -123,7 +108,6 @@ public class CFFParser
         {
             CFFFont font = parseFont(i);
             font.setGlobalSubrIndex(globalSubrIndex);
-            createFontMetrics(font);
             fonts.add(font);
         }
         return fonts;
@@ -330,35 +314,42 @@ public class CFFParser
 
     private CFFFont parseFont(int index) throws IOException
     {
-        CFFFont font = null;
+        // name index
         DataInput nameInput = new DataInput(nameIndex.getBytes(index));
         String name = nameInput.getString();
 
+        // top dict
         CFFDataInput topDictInput = new CFFDataInput(topDictIndex.getBytes(index));
         DictData topDict = readDictData(topDictInput);
+
+        // we dont't support synthetic fonts
         DictData.Entry syntheticBaseEntry = topDict.getEntry("SyntheticBase");
         if (syntheticBaseEntry != null)
         {
             throw new IOException("Synthetic Fonts are not supported");
         }
 
-        DictData.Entry rosEntry = topDict.getEntry("ROS");
-        if (rosEntry != null)
-        {
-            font = new CFFFontROS();
-            ((CFFFontROS) font).setRegistry(readString(rosEntry.getNumber(0).intValue()));
-            ((CFFFontROS) font).setOrdering(readString(rosEntry.getNumber(1).intValue()));
-            ((CFFFontROS) font).setSupplement(rosEntry.getNumber(2).intValue());
+        // determine if this is a Type 1-equivalent font or a CIDFont
+        CFFFont font;
+        boolean isCIDFont = topDict.getEntry("ROS") != null;
+        if (isCIDFont)
+        {
+            font = new CFFCIDFont();
+            DictData.Entry rosEntry = topDict.getEntry("ROS");
+            ((CFFCIDFont) font).setRegistry(readString(rosEntry.getNumber(0).intValue()));
+            ((CFFCIDFont) font).setOrdering(readString(rosEntry.getNumber(1).intValue()));
+            ((CFFCIDFont) font).setSupplement(rosEntry.getNumber(2).intValue());
         }
-
-        if (font == null)
+        else
         {
-            // -- No specific behavior for this font
-            font = new CFFFont();
+            font = new CFFType1Font();
         }
 
+        // name
+        debugFontName = name;
         font.setName(name);
 
+        // top dict
         font.addValueToTopDict("version", getString(topDict, "version"));
         font.addValueToTopDict("Notice", getString(topDict, "Notice"));
         font.addValueToTopDict("Copyright", getString(topDict, "Copyright"));
@@ -371,26 +362,22 @@ public class CFFParser
         font.addValueToTopDict("UnderlineThickness", getNumber(topDict, "UnderlineThickness", 50));
         font.addValueToTopDict("PaintType", getNumber(topDict, "PaintType", 0));
         font.addValueToTopDict("CharstringType", getNumber(topDict, "CharstringType", 2));
-        font.addValueToTopDict(
-                "FontMatrix",
-                getArray(
-                        topDict,
-                        "FontMatrix",
-                        Arrays.<Number> asList(0.001, (double) 0, (double) 0, 0.001, (double) 0, (double) 0)));
+        font.addValueToTopDict("FontMatrix", getArray(topDict, "FontMatrix", Arrays.<Number>asList(
+                                                      0.001, (double) 0, (double) 0, 0.001,
+                                                      (double) 0, (double) 0)));
         font.addValueToTopDict("UniqueID", getNumber(topDict, "UniqueID", null));
-        font.addValueToTopDict(
-                "FontBBox",
-                getArray(
-                        topDict,
-                        "FontBBox",
-                        Arrays.<Number> asList(0, 0, 0, 0)));
+        font.addValueToTopDict("FontBBox", getArray(topDict, "FontBBox",
+                                                    Arrays.<Number> asList(0, 0, 0, 0)));
         font.addValueToTopDict("StrokeWidth", getNumber(topDict, "StrokeWidth", 0));
         font.addValueToTopDict("XUID", getArray(topDict, "XUID", null));
 
+        // charstrings index
         DictData.Entry charStringsEntry = topDict.getEntry("CharStrings");
         int charStringsOffset = charStringsEntry.getNumber(0).intValue();
         input.setPosition(charStringsOffset);
         IndexData charStringsIndex = readIndexData(input);
+
+        // charset
         DictData.Entry charsetEntry = topDict.getEntry("charset");
         CFFCharset charset;
         int charsetId = charsetEntry != null ? charsetEntry.getNumber(0).intValue() : 0;
@@ -409,171 +396,193 @@ public class CFFParser
         else
         {
             input.setPosition(charsetId);
-            charset = readCharset(input, charStringsIndex.getCount());
+            charset = readCharset(input, charStringsIndex.getCount(), isCIDFont);
         }
         font.setCharset(charset);
-        font.getCharStringsDict().put(".notdef", charStringsIndex.getBytes(0));
-        int[] gids = new int[charStringsIndex.getCount()];
-        List<CFFCharset.Entry> glyphEntries = charset.getEntries();
+
+        // charstrings dict
+        font.getCharStringBytes().add(charStringsIndex.getBytes(0)); // .notdef
         for (int i = 1; i < charStringsIndex.getCount(); i++)
         {
-            CFFCharset.Entry glyphEntry = glyphEntries.get(i - 1);
-            gids[i - 1] = glyphEntry.getSID();
-            font.getCharStringsDict().put(glyphEntry.getName(), charStringsIndex.getBytes(i));
+            byte[] bytes = charStringsIndex.getBytes(i);
+            font.getCharStringBytes().add(bytes);
         }
-        DictData.Entry encodingEntry = topDict.getEntry("Encoding");
-        CFFEncoding encoding;
-        int encodingId = encodingEntry != null ? encodingEntry.getNumber(0).intValue() : 0;
-        if (encodingId == 0 || rosEntry != null) // --- ROS uses StandardEncoding
-        {
-            encoding = CFFStandardEncoding.getInstance();
-        }
-        else if (encodingId == 1)
+
+        // format-specific dictionaries
+        if (isCIDFont)
         {
-            encoding = CFFExpertEncoding.getInstance();
+            parseCIDFontDicts(topDict, (CFFCIDFont) font, charStringsIndex);
         }
         else
         {
-            input.setPosition(encodingId);
-            encoding = readEncoding(input, gids);
+            parseType1Dicts(topDict, (CFFType1Font) font, charset);
         }
-        font.setEncoding(encoding);
-
-        if (rosEntry != null)
-        {
-            // ---- It is a CIDKeyed Font, The Private Dictionary isn't in the Top Dict But in the Font Dict
-            // ---- Font Dict can be accessed by the FDArray and FDSelect
-            DictData.Entry fdArrayEntry = topDict.getEntry("FDArray");
-            if (fdArrayEntry == null)
-            {
-                throw new IOException("FDArray is missing for a CIDKeyed Font.");
-            }
-
-            int fontDictOffset = fdArrayEntry.getNumber(0).intValue();
-            input.setPosition(fontDictOffset);
-            IndexData fdIndex = readIndexData(input);
 
-            List<Map<String, Object>> privateDictionaries = new LinkedList<Map<String, Object>>();
-            List<Map<String, Object>> fontDictionaries = new LinkedList<Map<String, Object>>();
-            CFFFontROS fontRos = (CFFFontROS) font;
+        return font;
+    }
 
-            for (int i = 0; i < fdIndex.getCount(); ++i)
+    /**
+     * Parse dictionaries specific to a CIDFont.
+     */
+    private void parseCIDFontDicts(DictData topDict, CFFCIDFont font, IndexData charStringsIndex)
+            throws IOException
+    {
+        // In a CIDKeyed Font, the Private dictionary isn't in the Top Dict but in the Font dict
+        // which can be accessed by a lookup using FDArray and FDSelect
+        DictData.Entry fdArrayEntry = topDict.getEntry("FDArray");
+        if (fdArrayEntry == null)
+        {
+            throw new IOException("FDArray is missing for a CIDKeyed Font.");
+        }
+
+        // font dict index
+        int fontDictOffset = fdArrayEntry.getNumber(0).intValue();
+        input.setPosition(fontDictOffset);
+        IndexData fdIndex = readIndexData(input);
+
+        List<Map<String, Object>> privateDictionaries = new LinkedList<Map<String, Object>>();
+        List<Map<String, Object>> fontDictionaries = new LinkedList<Map<String, Object>>();
+
+        for (int i = 0; i < fdIndex.getCount(); ++i)
+        {
+            byte[] bytes = fdIndex.getBytes(i);
+            CFFDataInput fontDictInput = new CFFDataInput(bytes);
+            DictData fontDict = readDictData(fontDictInput);
+
+            // font dict
+            Map<String, Object> fontDictMap = new LinkedHashMap<String, Object>();
+            fontDictMap.put("FontName", getString(fontDict, "FontName"));
+            fontDictMap.put("FontType", getNumber(fontDict, "FontType", 0));
+            fontDictMap.put("FontBBox", getDelta(fontDict, "FontBBox", null));
+            fontDictMap.put("FontMatrix", getDelta(fontDict, "FontMatrix", null));
+            // TODO OD-4 : Add here other keys
+            fontDictionaries.add(fontDictMap);
+
+            // read private dict
+            DictData.Entry privateEntry = fontDict.getEntry("Private");
+            if (privateEntry == null)
             {
-                byte[] b = fdIndex.getBytes(i);
-                CFFDataInput fontDictInput = new CFFDataInput(b);
-                DictData fontDictData = readDictData(fontDictInput);
-
-                Map<String, Object> fontDictMap = new LinkedHashMap<String, Object>();
-                fontDictMap.put("FontName", getString(fontDictData, "FontName"));
-                fontDictMap.put("FontType", getNumber(fontDictData, "FontType", 0));
-                fontDictMap.put("FontBBox", getDelta(fontDictData, "FontBBox", null));
-                fontDictMap.put("FontMatrix", getDelta(fontDictData, "FontMatrix", null));
-                // TODO OD-4 : Add here other keys
-                fontDictionaries.add(fontDictMap);
-
-                DictData.Entry privateEntry = fontDictData.getEntry("Private");
-                // --- Font DICT is invalid without "Private" entry
-                if (privateEntry == null)
-                {
-                    throw new IOException("Missing Private Dictionary");
-                }
-
-                int privateOffset = privateEntry.getNumber(1).intValue();
-                input.setPosition(privateOffset);
-                int privateSize = privateEntry.getNumber(0).intValue();
-                CFFDataInput privateDictData = new CFFDataInput(input.readBytes(privateSize));
-                DictData privateDict = readDictData(privateDictData);
-
-                Map<String, Object> privDict = new LinkedHashMap<String, Object>();
-                privDict.put("BlueValues", getDelta(privateDict, "BlueValues", null));
-                privDict.put("OtherBlues", getDelta(privateDict, "OtherBlues", null));
-                privDict.put("FamilyBlues", getDelta(privateDict, "FamilyBlues", null));
-                privDict.put("FamilyOtherBlues", getDelta(privateDict, "FamilyOtherBlues", null));
-                privDict.put("BlueScale", getNumber(privateDict, "BlueScale", 0.039625));
-                privDict.put("BlueShift", getNumber(privateDict, "BlueShift", 7));
-                privDict.put("BlueFuzz", getNumber(privateDict, "BlueFuzz", 1));
-                privDict.put("StdHW", getNumber(privateDict, "StdHW", null));
-                privDict.put("StdVW", getNumber(privateDict, "StdVW", null));
-                privDict.put("StemSnapH", getDelta(privateDict, "StemSnapH", null));
-                privDict.put("StemSnapV", getDelta(privateDict, "StemSnapV", null));
-                privDict.put("ForceBold", getBoolean(privateDict, "ForceBold", false));
-                privDict.put("LanguageGroup", getNumber(privateDict, "LanguageGroup", 0));
-                privDict.put("ExpansionFactor", getNumber(privateDict, "ExpansionFactor", 0.06));
-                privDict.put("initialRandomSeed", getNumber(privateDict, "initialRandomSeed", 0));
-                privDict.put("defaultWidthX", getNumber(privateDict, "defaultWidthX", 0));
-                privDict.put("nominalWidthX", getNumber(privateDict, "nominalWidthX", 0));
-
-                int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
-                if (localSubrOffset == 0)
-                {
-                    privDict.put("Subrs", new IndexData(0));
-                }
-                else
-                {
-                    input.setPosition(privateOffset + localSubrOffset);
-                    IndexData idx = readIndexData(input);
-                    privDict.put("Subrs", idx);
-                }
-
-                privateDictionaries.add(privDict);
+                throw new IOException("Font DICT invalid without \"Private\" entry");
             }
-
-            fontRos.setFontDict(fontDictionaries);
-            fontRos.setPrivDict(privateDictionaries);
-
-            DictData.Entry fdSelectEntry = topDict.getEntry("FDSelect");
-            int fdSelectPos = fdSelectEntry.getNumber(0).intValue();
-            input.setPosition(fdSelectPos);
-            CIDKeyedFDSelect fdSelect = readFDSelect(input, charStringsIndex.getCount(), fontRos);
-
-            font.addValueToPrivateDict("defaultWidthX", 1000);
-            font.addValueToPrivateDict("nominalWidthX", 0);
-
-            fontRos.setFdSelect(fdSelect);
-
-        }
-        else
-        {
-            DictData.Entry privateEntry = topDict.getEntry("Private");
             int privateOffset = privateEntry.getNumber(1).intValue();
             input.setPosition(privateOffset);
             int privateSize = privateEntry.getNumber(0).intValue();
             CFFDataInput privateDictData = new CFFDataInput(input.readBytes(privateSize));
             DictData privateDict = readDictData(privateDictData);
-            font.addValueToPrivateDict("BlueValues", getDelta(privateDict, "BlueValues", null));
-            font.addValueToPrivateDict("OtherBlues", getDelta(privateDict, "OtherBlues", null));
-            font.addValueToPrivateDict("FamilyBlues", getDelta(privateDict, "FamilyBlues", null));
-            font.addValueToPrivateDict("FamilyOtherBlues", getDelta(privateDict, "FamilyOtherBlues", null));
-            font.addValueToPrivateDict("BlueScale", getNumber(privateDict, "BlueScale", 0.039625));
-            font.addValueToPrivateDict("BlueShift", getNumber(privateDict, "BlueShift", 7));
-            font.addValueToPrivateDict("BlueFuzz", getNumber(privateDict, "BlueFuzz", 1));
-            font.addValueToPrivateDict("StdHW", getNumber(privateDict, "StdHW", null));
-            font.addValueToPrivateDict("StdVW", getNumber(privateDict, "StdVW", null));
-            font.addValueToPrivateDict("StemSnapH", getDelta(privateDict, "StemSnapH", null));
-            font.addValueToPrivateDict("StemSnapV", getDelta(privateDict, "StemSnapV", null));
-            font.addValueToPrivateDict("ForceBold", getBoolean(privateDict, "ForceBold", false));
-            font.addValueToPrivateDict("LanguageGroup", getNumber(privateDict, "LanguageGroup", 0));
-            font.addValueToPrivateDict("ExpansionFactor",
-                    getNumber(privateDict, "ExpansionFactor", 0.06));
-            font.addValueToPrivateDict("initialRandomSeed",
-                    getNumber(privateDict, "initialRandomSeed", 0));
-            font.addValueToPrivateDict("defaultWidthX", getNumber(privateDict, "defaultWidthX", 0));
-            font.addValueToPrivateDict("nominalWidthX", getNumber(privateDict, "nominalWidthX", 0));
 
-            int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
+            // populate private dict
+            Map<String, Object> privDict = new LinkedHashMap<String, Object>();
+            privDict.put("BlueValues", getDelta(privateDict, "BlueValues", null));
+            privDict.put("OtherBlues", getDelta(privateDict, "OtherBlues", null));
+            privDict.put("FamilyBlues", getDelta(privateDict, "FamilyBlues", null));
+            privDict.put("FamilyOtherBlues", getDelta(privateDict, "FamilyOtherBlues", null));
+            privDict.put("BlueScale", getNumber(privateDict, "BlueScale", 0.039625));
+            privDict.put("BlueShift", getNumber(privateDict, "BlueShift", 7));
+            privDict.put("BlueFuzz", getNumber(privateDict, "BlueFuzz", 1));
+            privDict.put("StdHW", getNumber(privateDict, "StdHW", null));
+            privDict.put("StdVW", getNumber(privateDict, "StdVW", null));
+            privDict.put("StemSnapH", getDelta(privateDict, "StemSnapH", null));
+            privDict.put("StemSnapV", getDelta(privateDict, "StemSnapV", null));
+            privDict.put("ForceBold", getBoolean(privateDict, "ForceBold", false));
+            privDict.put("LanguageGroup", getNumber(privateDict, "LanguageGroup", 0));
+            privDict.put("ExpansionFactor", getNumber(privateDict, "ExpansionFactor", 0.06));
+            privDict.put("initialRandomSeed", getNumber(privateDict, "initialRandomSeed", 0));
+            privDict.put("defaultWidthX", getNumber(privateDict, "defaultWidthX", 0));
+            privDict.put("nominalWidthX", getNumber(privateDict, "nominalWidthX", 0));
+            privateDictionaries.add(privDict);
+
+            // local subrs
+            int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", 0);
             if (localSubrOffset == 0)
             {
-                //font.setLocalSubrIndex(new IndexData(0));
-                font.addValueToPrivateDict("Subrs", new IndexData(0));
+                privDict.put("Subrs", new IndexData(0));
             }
             else
             {
                 input.setPosition(privateOffset + localSubrOffset);
-                //font.setLocalSubrIndex(readIndexData(input));
-                font.addValueToPrivateDict("Subrs", readIndexData(input));
+                IndexData idx = readIndexData(input);
+                privDict.put("Subrs", idx);
             }
         }
-        return font;
+
+        // font-dict (FD) select
+        DictData.Entry fdSelectEntry = topDict.getEntry("FDSelect");
+        int fdSelectPos = fdSelectEntry.getNumber(0).intValue();
+        input.setPosition(fdSelectPos);
+        FDSelect fdSelect = readFDSelect(input, charStringsIndex.getCount(), font);
+
+        // todo: almost certainly erroneous - CIDFonts do not have a top-level private dict
+        //font.addValueToPrivateDict("defaultWidthX", 1000);
+        //font.addValueToPrivateDict("nominalWidthX", 0);
+
+        font.setFontDict(fontDictionaries);
+        font.setPrivDict(privateDictionaries);
+        font.setFdSelect(fdSelect);
+    }
+
+    /**
+     * Parse dictionaries specific to a Type 1-equivalent font.
+     */
+    private void parseType1Dicts(DictData topDict, CFFType1Font font, CFFCharset charset)
+            throws IOException
+    {
+        // encoding
+        DictData.Entry encodingEntry = topDict.getEntry("Encoding");
+        CFFEncoding encoding;
+        int encodingId = encodingEntry != null ? encodingEntry.getNumber(0).intValue() : 0;
+        if (encodingId == 0)
+        {
+            encoding = CFFStandardEncoding.getInstance();
+        }
+        else if (encodingId == 1)
+        {
+            encoding = CFFExpertEncoding.getInstance();
+        }
+        else
+        {
+            input.setPosition(encodingId);
+            encoding = readEncoding(input, charset);
+        }
+        font.setEncoding(encoding);
+
+        // read private dict
+        DictData.Entry privateEntry = topDict.getEntry("Private");
+        int privateOffset = privateEntry.getNumber(1).intValue();
+        input.setPosition(privateOffset);
+        int privateSize = privateEntry.getNumber(0).intValue();
+        CFFDataInput privateDictData = new CFFDataInput(input.readBytes(privateSize));
+        DictData privateDict = readDictData(privateDictData);
+
+        // populate private dict
+        font.addToPrivateDict("BlueValues", getDelta(privateDict, "BlueValues", null));
+        font.addToPrivateDict("OtherBlues", getDelta(privateDict, "OtherBlues", null));
+        font.addToPrivateDict("FamilyBlues", getDelta(privateDict, "FamilyBlues", null));
+        font.addToPrivateDict("FamilyOtherBlues", getDelta(privateDict, "FamilyOtherBlues", null));
+        font.addToPrivateDict("BlueScale", getNumber(privateDict, "BlueScale", 0.039625));
+        font.addToPrivateDict("BlueShift", getNumber(privateDict, "BlueShift", 7));
+        font.addToPrivateDict("BlueFuzz", getNumber(privateDict, "BlueFuzz", 1));
+        font.addToPrivateDict("StdHW", getNumber(privateDict, "StdHW", null));
+        font.addToPrivateDict("StdVW", getNumber(privateDict, "StdVW", null));
+        font.addToPrivateDict("StemSnapH", getDelta(privateDict, "StemSnapH", null));
+        font.addToPrivateDict("StemSnapV", getDelta(privateDict, "StemSnapV", null));
+        font.addToPrivateDict("ForceBold", getBoolean(privateDict, "ForceBold", false));
+        font.addToPrivateDict("LanguageGroup", getNumber(privateDict, "LanguageGroup", 0));
+        font.addToPrivateDict("ExpansionFactor", getNumber(privateDict, "ExpansionFactor", 0.06));
+        font.addToPrivateDict("initialRandomSeed", getNumber(privateDict, "initialRandomSeed", 0));
+        font.addToPrivateDict("defaultWidthX", getNumber(privateDict, "defaultWidthX", 0));
+        font.addToPrivateDict("nominalWidthX", getNumber(privateDict, "nominalWidthX", 0));
+
+        // local subrs
+        int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", 0);
+        if (localSubrOffset == 0)
+        {
+            font.addToPrivateDict("Subrs", new IndexData(0));
+        }
+        else
+        {
+            input.setPosition(privateOffset + localSubrOffset);
+            font.addToPrivateDict("Subrs", readIndexData(input));
+        }
     }
 
     private String readString(int index) throws IOException
@@ -589,7 +598,7 @@ public class CFFParser
         }
         else
         {
-        	// technically this maps to .notdef, but we need a unique glyph name
+        	// technically this maps to .notdef, but we need a unique sid name
         	return "SID" + index;
         }
     }
@@ -597,7 +606,7 @@ public class CFFParser
     private String getString(DictData dict, String name) throws IOException
     {
         DictData.Entry entry = dict.getEntry(name);
-        return (entry != null ? readString(entry.getNumber(0).intValue()) : null);
+        return entry != null ? readString(entry.getNumber(0).intValue()) : null;
     }
 
     private Boolean getBoolean(DictData dict, String name, boolean defaultValue) throws IOException
@@ -626,18 +635,18 @@ public class CFFParser
         return entry != null ? entry.getArray() : defaultValue;
     }
 
-    private CFFEncoding readEncoding(CFFDataInput dataInput, int[] gids) throws IOException
+    private CFFEncoding readEncoding(CFFDataInput dataInput, CFFCharset charset) throws IOException
     {
         int format = dataInput.readCard8();
         int baseFormat = format & 0x7f;
 
         if (baseFormat == 0)
         {
-            return readFormat0Encoding(dataInput, format, gids);
+            return readFormat0Encoding(dataInput, charset, format);
         }
         else if (baseFormat == 1)
         {
-            return readFormat1Encoding(dataInput, format, gids);
+            return readFormat1Encoding(dataInput, charset, format);
         }
         else
         {
@@ -645,16 +654,20 @@ public class CFFParser
         }
     }
 
-    private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, int format, int[] gids) throws IOException
+    private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, CFFCharset charset,
+                                                int format) throws IOException
     {
         Format0Encoding encoding = new Format0Encoding();
         encoding.format = format;
         encoding.nCodes = dataInput.readCard8();
         encoding.code = new int[encoding.nCodes];
-        for (int i = 0; i < encoding.code.length; i++)
+        encoding.add(0, 0, ".notdef");
+        for (int gid = 1; gid <= encoding.nCodes; gid++)
         {
-            encoding.code[i] = dataInput.readCard8();
-            encoding.register(encoding.code[i], gids[i]);
+            int code = dataInput.readCard8();
+            encoding.code[gid - 1] = code;
+            int sid = charset.getSIDForGID(gid);
+            encoding.add(code, sid, readString(sid));
         }
         if ((format & 0x80) != 0)
         {
@@ -663,13 +676,15 @@ public class CFFParser
         return encoding;
     }
 
-    private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, int format, int[] gids) throws IOException
+    private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, CFFCharset charset,
+                                                int format) throws IOException
     {
         Format1Encoding encoding = new Format1Encoding();
         encoding.format = format;
         encoding.nRanges = dataInput.readCard8();
-        int count = 0;
         encoding.range = new Format1Encoding.Range1[encoding.nRanges];
+        encoding.add(0, 0, ".notdef");
+        int gid = 1;
         for (int i = 0; i < encoding.range.length; i++)
         {
             Format1Encoding.Range1 range = new Format1Encoding.Range1();
@@ -678,9 +693,11 @@ public class CFFParser
             encoding.range[i] = range;
             for (int j = 0; j < 1 + range.nLeft; j++)
             {
-                encoding.register(range.first + j, gids[count + j]);
+                int sid = charset.getSIDForGID(gid);
+                int code = range.first + j;
+                encoding.add(code, sid, readString(sid));
+                gid++;
             }
-            count += 1 + range.nLeft;
         }
         if ((format & 0x80) != 0)
         {
@@ -697,7 +714,8 @@ public class CFFParser
         {
             EmbeddedEncoding.Supplement supplement = new EmbeddedEncoding.Supplement();
             supplement.code = dataInput.readCard8();
-            supplement.glyph = dataInput.readSID();
+            supplement.sid = dataInput.readSID();
+            supplement.name = readString(supplement.sid);
             encoding.supplement[i] = supplement;
         }
     }
@@ -710,7 +728,7 @@ public class CFFParser
      * @return the FDSelect data
      * @throws IOException
      */
-    private CIDKeyedFDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFFontROS ros) throws IOException
+    private FDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFCIDFont ros) throws IOException
     {
         int format = dataInput.readCard8();
         if (format == 0)
@@ -736,7 +754,7 @@ public class CFFParser
      * @return the Format 0 of the FDSelect data
      * @throws IOException
      */
-    private Format0FDSelect readFormat0FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFFontROS ros)
+    private Format0FDSelect readFormat0FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros)
             throws IOException
     {
         Format0FDSelect fdselect = new Format0FDSelect(ros);
@@ -760,7 +778,7 @@ public class CFFParser
      * @return the Format 3 of the FDSelect data
      * @throws IOException
      */
-    private Format3FDSelect readFormat3FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFFontROS ros)
+    private Format3FDSelect readFormat3FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros)
             throws IOException
     {
         Format3FDSelect fdselect = new Format3FDSelect(ros);
@@ -782,35 +800,30 @@ public class CFFParser
     }
 
     /**
-     *  Container of a Format 3 FDSelect data (see "The Compact Font Format Specification" chapter "FDSelect" ).
+     *  Format 3 FDSelect data.
      */
-    private static class Format3FDSelect extends CIDKeyedFDSelect
+    private static class Format3FDSelect extends FDSelect
     {
         private int format;
         private int nbRanges;
         private Range3[] range3;
         private int sentinel;
 
-        private Format3FDSelect(CFFFontROS owner)
+        private Format3FDSelect(CFFCIDFont owner)
         {
             super(owner);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.apache.fontbox.cff.CIDKeyedFDSelect#getFd(int)
-         */
         @Override
-        public int getFd(int glyph)
+        public int getFDIndex(int gid)
         {
             for (int i = 0; i < nbRanges; ++i)
             {
-                if (range3[i].first >= glyph)
+                if (range3[i].first >= gid)
                 {
                     if (i + 1 < nbRanges)
                     {
-                        if (range3[i + 1].first > glyph)
+                        if (range3[i + 1].first > gid)
                         {
                             return range3[i].fd;
                         }
@@ -821,8 +834,8 @@ public class CFFParser
                     }
                     else
                     {
-                        // last range reach, the sentinel must be greater than glyph
-                        if (sentinel > glyph)
+                        // last range reach, the sentinel must be greater than gid
+                        if (sentinel > gid)
                         {
                             return range3[i].fd;
                         }
@@ -860,68 +873,53 @@ public class CFFParser
     }
 
     /**
-     *  Container of a Format 0 FDSelect data (see "The Compact Font Format Specification" chapter "FDSelect" ).
+     *  Format 0 FDSelect.
      */
-    private static class Format0FDSelect extends CIDKeyedFDSelect
+    private static class Format0FDSelect extends FDSelect
     {
         private int format;
         private int[] fds;
 
-        private Format0FDSelect(CFFFontROS owner)
+        private Format0FDSelect(CFFCIDFont owner)
         {
             super(owner);
         }
 
-        /*
-         * (non-Javadoc)
-         * 
-         * @see org.apache.fontbox.cff.CIDKeyedFDSelect#getFd(int)
-         */
         @Override
-        public int getFd(int glyph)
+        public int getFDIndex(int gid)
         {
-            Map<String, byte[]> charString = owner.getCharStringsDict();
-            Set<String> keys = charString.keySet();
-            // ---- search the position of the given glyph
-            for (Mapping mapping : owner.getMappings())
+            if (gid < fds.length)
             {
-                if (mapping.getSID() == glyph && charString.containsKey(mapping.getName()))
-                {
-                    int index = 0;
-                    for (String str : keys)
-                    {
-                        if (mapping.getName().equals(str))
-                        {
-                            return fds[index];
-                        }
-                        ++index;
-                    }
-                }
+                return fds[gid];
+            }
+            else
+            {
+                return 0;
             }
-            return -1;
         }
 
         @Override
         public String toString()
         {
-            return getClass().getName() + "[format=" + format + ", fds=" + Arrays.toString(fds) + "]";
+            return getClass().getName() + "[fds=" + Arrays.toString(fds) + "]";
         }
     }
 
-    private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs) throws IOException
+    private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs, boolean isCIDFont)
+            throws IOException
     {
         int format = dataInput.readCard8();
         if (format == 0)
         {
-            return readFormat0Charset(dataInput, format, nGlyphs);
+            return readFormat0Charset(dataInput, format, nGlyphs, isCIDFont);
         }
         else if (format == 1)
         {
-            return readFormat1Charset(dataInput, format, nGlyphs);
+            return readFormat1Charset(dataInput, format, nGlyphs, isCIDFont);
         }
         else if (format == 2)
         {
-            return readFormat2Charset(dataInput, format, nGlyphs);
+            return readFormat2Charset(dataInput, format, nGlyphs, isCIDFont);
         }
         else
         {
@@ -929,25 +927,54 @@ public class CFFParser
         }
     }
 
-    private Format0Charset readFormat0Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
+    private Format0Charset readFormat0Charset(CFFDataInput dataInput, int format, int nGlyphs,
+                                              boolean isCIDFont) throws IOException
     {
-        Format0Charset charset = new Format0Charset();
+        Format0Charset charset = new Format0Charset(isCIDFont);
         charset.format = format;
-        charset.glyph = new int[nGlyphs - 1];
-        for (int i = 0; i < charset.glyph.length; i++)
+        charset.glyph = new int[nGlyphs];
+        charset.glyph[0] = 0;
+        if (isCIDFont)
         {
-            charset.glyph[i] = dataInput.readSID();
-            charset.register(charset.glyph[i], readString(charset.glyph[i]));
+            charset.addCID(0, 0);
+        }
+        else
+        {
+            charset.addSID(0, 0, ".notdef");
+        }
+
+        for (int gid = 1; gid < charset.glyph.length; gid++)
+        {
+            int sid = dataInput.readSID();
+            charset.glyph[gid] = sid;
+            if (isCIDFont)
+            {
+                charset.addCID(gid, sid);
+            }
+            else
+            {
+                charset.addSID(gid, sid, readString(sid));
+            }
         }
         return charset;
     }
 
-    private Format1Charset readFormat1Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
+    private Format1Charset readFormat1Charset(CFFDataInput dataInput, int format, int nGlyphs,
+                                              boolean isCIDFont) throws IOException
     {
-        Format1Charset charset = new Format1Charset();
+        Format1Charset charset = new Format1Charset(isCIDFont);
         charset.format = format;
         List<Format1Charset.Range1> ranges = new ArrayList<Format1Charset.Range1>();
-        for (int i = 0; i < nGlyphs - 1;)
+        if (isCIDFont)
+        {
+            charset.addCID(0, 0);
+        }
+        else
+        {
+            charset.addSID(0, 0, ".notdef");
+        }
+
+        for (int gid = 1; gid < nGlyphs; gid++)
         {
             Format1Charset.Range1 range = new Format1Charset.Range1();
             range.first = dataInput.readSID();
@@ -955,20 +982,38 @@ public class CFFParser
             ranges.add(range);
             for (int j = 0; j < 1 + range.nLeft; j++)
             {
-                charset.register(range.first + j, readString(range.first + j));
+                int sid = range.first + j;
+                if (isCIDFont)
+                {
+                    charset.addCID(gid + j, sid);
+                }
+                else
+                {
+                    charset.addSID(gid + j, sid, readString(sid));
+                }
             }
-            i += 1 + range.nLeft;
+            gid += range.nLeft;
         }
         charset.range = ranges.toArray(new Format1Charset.Range1[0]);
         return charset;
     }
 
-    private Format2Charset readFormat2Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
+    private Format2Charset readFormat2Charset(CFFDataInput dataInput, int format, int nGlyphs,
+                                              boolean isCIDFont) throws IOException
     {
-        Format2Charset charset = new Format2Charset();
+        Format2Charset charset = new Format2Charset(isCIDFont);
         charset.format = format;
         charset.range = new Format2Charset.Range2[0];
-        for (int i = 0; i < nGlyphs - 1;)
+        if (isCIDFont)
+        {
+            charset.addCID(0, 0);
+        }
+        else
+        {
+            charset.addSID(0, 0, ".notdef");
+        }
+
+        for (int gid = 1; gid < nGlyphs; gid++)
         {
             Format2Charset.Range2[] newRange = new Format2Charset.Range2[charset.range.length + 1];
             System.arraycopy(charset.range, 0, newRange, 0, charset.range.length);
@@ -979,9 +1024,17 @@ public class CFFParser
             charset.range[charset.range.length - 1] = range;
             for (int j = 0; j < 1 + range.nLeft; j++)
             {
-                charset.register(range.first + j, readString(range.first + j));
+                int sid = range.first + j;
+                if (isCIDFont)
+                {
+                    charset.addCID(gid + j, sid);
+                }
+                else
+                {
+                    charset.addSID(gid + j, sid, readString(sid));
+                }
             }
-            i += 1 + range.nLeft;
+            gid += range.nLeft;
         }
         return charset;
     }
@@ -1110,24 +1163,17 @@ public class CFFParser
      */
     abstract static class EmbeddedEncoding extends CFFEncoding
     {
-
         private int nSups;
         private Supplement[] supplement;
 
-        @Override
-        public boolean isFontSpecific()
-        {
-            return true;
-        }
-
-        List<Supplement> getSupplements()
+        /*List<Supplement> getSupplements()
         {
             if (supplement == null)
             {
-                return Collections.<Supplement> emptyList();
+                return Collections.emptyList();
             }
             return Arrays.asList(supplement);
-        }
+        }*/
 
         /**
          * Inner class representing a supplement for an encoding. 
@@ -1135,22 +1181,28 @@ public class CFFParser
         static class Supplement
         {
             private int code;
-            private int glyph;
+            private int sid;
+            private String name;
 
-            int getCode()
+            public int getCode()
             {
                 return code;
             }
 
-            int getGlyph()
+            public int getSID()
             {
-                return glyph;
+                return sid;
+            }
+
+            public String getName()
+            {
+                return name;
             }
 
             @Override
             public String toString()
             {
-                return getClass().getName() + "[code=" + code + ", glyph=" + glyph + "]";
+                return getClass().getName() + "[code=" + code + ", sid=" + sid + "]";
             }
         }
     }
@@ -1205,14 +1257,13 @@ public class CFFParser
     }
 
     /**
-     * Inner class representing an embedded CFF charset. 
+     * Inner class representing an embedded CFF charset.
      */
     abstract static class EmbeddedCharset extends CFFCharset
     {
-        @Override
-        public boolean isFontSpecific()
+        protected EmbeddedCharset(boolean isCIDFont)
         {
-            return true;
+            super(isCIDFont);
         }
     }
 
@@ -1224,6 +1275,11 @@ public class CFFParser
         private int format;
         private int[] glyph;
 
+        protected Format0Charset(boolean isCIDFont)
+        {
+            super(isCIDFont);
+        }
+
         @Override
         public String toString()
         {
@@ -1239,6 +1295,11 @@ public class CFFParser
         private int format;
         private Range1[] range;
 
+        protected Format1Charset(boolean isCIDFont)
+        {
+            super(isCIDFont);
+        }
+
         @Override
         public String toString()
         {
@@ -1269,6 +1330,11 @@ public class CFFParser
         private int format;
         private Range2[] range;
 
+        protected Format2Charset(boolean isCIDFont)
+        {
+            super(isCIDFont);
+        }
+
         @Override
         public String toString()
         {
@@ -1291,74 +1357,9 @@ public class CFFParser
         }
     }
 
-    private void createFontMetrics(CFFFont font) throws IOException
+    @Override
+    public String toString()
     {
-        FontMetric fontMetrics = new FontMetric();
-        fontMetrics.setAFMVersion(2.0f);
-        fontMetrics.setFontName( font.getName() );
-        fontMetrics.setFullName( font.getPropertyAsString("FullName") );
-        fontMetrics.setFamilyName( font.getPropertyAsString("FamilyName") );
-        fontMetrics.setWeight( font.getPropertyAsString("Weight") );
-        CFFEncoding encoding = font.getEncoding();
-        if (encoding.isFontSpecific())
-        {
-            fontMetrics.setEncodingScheme("FontSpecific");
-        }
-        fontMetrics.setUnderlinePosition(font.getPropertyAsFloat("UnderlinePosition", -100));
-        fontMetrics.setUnderlineThickness(font.getPropertyAsFloat("UnderlineThickness", 50));
-        fontMetrics.setItalicAngle(font.getPropertyAsFloat("ItalicAngle", 0));
-        fontMetrics.setFixedPitch(font.getPropertyAsBoolean("isFixedPitch",false) );
-        
-        List<CharMetricSortable> metrics = createCharMetrics(font);
-        Collections.sort(metrics);
-        BoundingBox bounds = null;
-        for (CharMetric metric : metrics)
-        {
-            fontMetrics.addCharMetric(metric);
-            if(bounds == null)
-            {
-                bounds = metric.getBoundingBox();
-            }
-            else
-            {
-                BoundingBox.union(bounds, metric.getBoundingBox(), bounds);
-            }
-        }
-        fontMetrics.setFontBBox(bounds);
-        font.setFontMetric(fontMetrics);
-    }
-
-    private List<CharMetricSortable> createCharMetrics(CFFFont font) throws IOException
-    {
-        List<CharMetricSortable> metrics = new ArrayList<CharMetricSortable>();
-        Collection<CFFFont.Mapping> mappings = font.getMappings();
-        for (CFFFont.Mapping mapping : mappings)
-        {
-            CharMetricSortable metric = new CharMetricSortable();
-            metric.setCharacterCode(mapping.getCode());
-            metric.setName(mapping.getName());
-            metric.setWx(mapping.getType1CharString().getWidth());
-            metric.setBBox(mapping.getType1CharString().getBounds());
-            metrics.add(metric);
-        }
-        return metrics;
+        return getClass().getSimpleName() + "[" + debugFontName + "]";
     }
-
-    /**
-     * This class represents the metric of one single character. 
-     */
-    private static class CharMetricSortable extends CharMetric implements Comparable<CharMetric>
-    {
-        public int compareTo(CharMetric that)
-        {
-            return getCharacterCode() - that.getCharacterCode();
-        }
-        
-        public void setBBox(Rectangle2D rect)
-        {
-            BoundingBox bBox = new BoundingBox((float)rect.getMinX(), (float)rect.getMinY(), (float)rect.getMaxX(), (float)rect.getMaxY());
-            setBoundingBox(bBox);
-        }
-    }
-
 }

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java?rev=1621411&r1=1621410&r2=1621411&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java Sat Aug 30 02:26:57 2014
@@ -40,7 +40,7 @@ public class Type1CharString
 {
     private static final Log LOG = LogFactory.getLog(Type1CharString.class);
 
-    private Type1CharStringReader reader;
+    private Type1CharStringReader font;
     private String fontName, glyphName;
     private GeneralPath path = null;
     private int width = 0;
@@ -53,28 +53,34 @@ public class Type1CharString
 
     /**
      * Constructs a new Type1CharString object.
-     * @param reader Parent Type 1 CharString reader
+     * @param font Parent Type 1 CharString font
      * @param sequence Type 1 char string sequence
      */
-    public Type1CharString(Type1CharStringReader reader, String fontName, String glyphName,
+    public Type1CharString(Type1CharStringReader font, String fontName, String glyphName,
                            List<Object> sequence)
     {
-        this(reader, fontName, glyphName);
+        this(font, fontName, glyphName);
         type1Sequence = sequence;
     }
 
     /**
      * Constructor for use in subclasses.
-     * @param reader Parent Type 1 CharString reader
+     * @param font Parent Type 1 CharString font
      */
-    protected Type1CharString(Type1CharStringReader reader, String fontName, String glyphName)
+    protected Type1CharString(Type1CharStringReader font, String fontName, String glyphName)
     {
-        this.reader = reader;
+        this.font = font;
         this.fontName = fontName;
         this.glyphName = glyphName;
         this.current = new Point2D.Float(0, 0);
     }
 
+    // todo: NEW name (or CID as hex)
+    public String getName()
+    {
+        return glyphName;
+    }
+
     /**
      * Returns the bounds of the renderer path.
      * @return the bounds as Rectangle2D
@@ -243,8 +249,8 @@ public class Type1CharString
             int result = a / b; // TODO loss of precision, should be float
 
             List<Integer> list = new ArrayList<Integer>(numbers);
-            numbers.remove(numbers.size() - 1);
-            numbers.remove(numbers.size() - 1);
+            list.remove(list.size() - 1);
+            list.remove(list.size() - 1);
             list.add(result);
             return list;
         }
@@ -414,7 +420,7 @@ public class Type1CharString
         {
             try
             {
-                Type1CharString base = reader.getType1CharString(baseName);
+                Type1CharString base = font.getType1CharString(baseName);
                 path.append(base.getPath().getPathIterator(null), false);
             }
             catch (IOException e)
@@ -428,7 +434,7 @@ public class Type1CharString
         {
             try
             {
-                Type1CharString accent = reader.getType1CharString(accentName);
+                Type1CharString accent = font.getType1CharString(accentName);
                 AffineTransform at = AffineTransform.getTranslateInstance(
                     leftSideBearing.getX() + adx.floatValue(),
                     leftSideBearing.getY() + ady.floatValue());



Mime
View raw message