Index: findbugs-exclude.xml
===================================================================
--- findbugs-exclude.xml	(revision 1530933)
+++ findbugs-exclude.xml	(working copy)
@@ -5433,4 +5433,11 @@
       <Method name="hasValueOfElementName"/>
       <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
    </Match>
+   <Match>
+     <Class name="org.apache.fop.pdf.PDFCFFStream"/>
+     <Or>
+        <Bug pattern="EI_EXPOSE_REP"/>
+        <Bug pattern="EI_EXPOSE_REP2"/>
+     </Or>
+   </Match>
 </FindBugsFilter>
Index: src/java/org/apache/fop/fonts/FontType.java
===================================================================
--- src/java/org/apache/fop/fonts/FontType.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/FontType.java	(working copy)
@@ -49,6 +49,8 @@
      */
     public static final FontType TRUETYPE    = new FontType("TrueType", 5);
 
+    public static final FontType TYPE1C       = new FontType("Type1C", 6);
+
     private final String name;
     private final int value;
 
Index: src/java/org/apache/fop/fonts/MultiByteFont.java
===================================================================
--- src/java/org/apache/fop/fonts/MultiByteFont.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/MultiByteFont.java	(working copy)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+import java.io.InputStream;
 import java.nio.CharBuffer;
 import java.nio.IntBuffer;
 import java.util.BitSet;
@@ -52,7 +53,7 @@
     private int defaultWidth;
     private CIDFontType cidType = CIDFontType.CIDTYPE2;
 
-    private final CIDSet cidSet;
+    protected final CIDSet cidSet;
 
     /* advanced typographic support */
     private GlyphDefinitionTable gdef;
@@ -212,13 +213,13 @@
         if (idx < NUM_MOST_LIKELY_GLYPHS && mostLikelyGlyphs[idx] != 0) {
             return mostLikelyGlyphs[idx];
         }
-        for (int i = 0; (i < cmap.length) && retIdx == 0; i++) {
-            if (cmap[i].getUnicodeStart() <= idx
-                    && cmap[i].getUnicodeEnd() >= idx) {
-
-                retIdx = cmap[i].getGlyphStartIndex()
+        for (CMapSegment i : cmap) {
+            if (retIdx == 0
+                    && i.getUnicodeStart() <= idx
+                    && i.getUnicodeEnd() >= idx) {
+                retIdx = i.getGlyphStartIndex()
                     + idx
-                    - cmap[i].getUnicodeStart();
+                    - i.getUnicodeStart();
                 if (idx < NUM_MOST_LIKELY_GLYPHS) {
                     mostLikelyGlyphs[idx] = retIdx;
                 }
@@ -231,7 +232,7 @@
      * Add a private use mapping {PU,GI} to the existing character map.
      * N.B. Does not insert in order, merely appends to end of existing map.
      */
-    private synchronized void addPrivateUseMapping(int pu, int gi) {
+    protected synchronized void addPrivateUseMapping(int pu, int gi) {
         assert findGlyphIndex(pu) == SingleByteEncoding.NOT_FOUND_CODE_POINT;
         CMapSegment[] oldCmap = cmap;
         int cmapLength = oldCmap.length;
@@ -320,10 +321,10 @@
         bitset.set(0);
         bitset.set(1);
         bitset.set(2);
-        for (int i = 0; i < cmap.length; i++) {
-            int start = cmap[i].getUnicodeStart();
-            int end = cmap[i].getUnicodeEnd();
-            int glyphIndex = cmap[i].getGlyphStartIndex();
+        for (CMapSegment i : cmap) {
+            int start = i.getUnicodeStart();
+            int end = i.getUnicodeEnd();
+            int glyphIndex = i.getGlyphStartIndex();
             while (start++ < end + 1) {
                 bitset.set(glyphIndex++);
             }
@@ -334,10 +335,10 @@
     protected char[] getChars() {
         // the width array is set when the font is built
         char[] chars = new char[width.length];
-        for (int i = 0; i < cmap.length; i++) {
-            int start = cmap[i].getUnicodeStart();
-            int end = cmap[i].getUnicodeEnd();
-            int glyphIndex = cmap[i].getGlyphStartIndex();
+        for (CMapSegment i : cmap) {
+            int start = i.getUnicodeStart();
+            int end = i.getUnicodeEnd();
+            int glyphIndex = i.getGlyphStartIndex();
             while (start < end + 1) {
                 chars[glyphIndex++] = (char) start++;
             }
@@ -624,5 +625,12 @@
         return cb;
     }
 
+    public Map<Integer, Integer> getWidthsMap() {
+        return null;
+    }
+
+    public InputStream getCmapStream() {
+        return null;
+    }
 }
 
Index: src/java/org/apache/fop/fonts/SingleByteFont.java
===================================================================
--- src/java/org/apache/fop/fonts/SingleByteFont.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/SingleByteFont.java	(working copy)
@@ -42,10 +42,10 @@
     /** logger */
     private  static Log log = LogFactory.getLog(SingleByteFont.class);
 
-    private SingleByteEncoding mapping;
+    protected SingleByteEncoding mapping;
     private boolean useNativeEncoding = false;
 
-    private int[] width = null;
+    protected int[] width = null;
 
     private Map<Character, UnencodedCharacter> unencodedCharacters;
     private List<SimpleSingleByteEncoding> additionalEncodings;
@@ -422,6 +422,5 @@
         assert getFontType() == FontType.TRUETYPE;
         return ttPostScriptVersion;
     }
-
 }
 
Index: src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java
===================================================================
--- src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/truetype/OFMtxEntry.java	(working copy)
@@ -24,7 +24,7 @@
 /**
  * This class represents a TrueType Mtx Entry.
  */
-class OFMtxEntry {
+public class OFMtxEntry {
 
     private int wx;
     private int lsb;
@@ -55,7 +55,7 @@
      * @return int[]
      */
     public int[] getBoundingBox() {
-        return boundingBox;
+        return boundingBox.clone();
     }
 
     /**
@@ -63,7 +63,7 @@
      * @param boundingBox The boundingBox to set
      */
     public void setBoundingBox(int[] boundingBox) {
-        this.boundingBox = boundingBox;
+        this.boundingBox = boundingBox.clone();
     }
 
     /**
Index: src/java/org/apache/fop/fonts/truetype/OTFFile.java
===================================================================
--- src/java/org/apache/fop/fonts/truetype/OTFFile.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/truetype/OTFFile.java	(working copy)
@@ -20,6 +20,8 @@
 package org.apache.fop.fonts.truetype;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.fontbox.cff.CFFDataInput;
 import org.apache.fontbox.cff.CFFFont;
@@ -28,7 +30,7 @@
 
 public class OTFFile extends OpenFont {
 
-    protected CFFFont fileFont;
+    protected List<CFFFont> fileFonts = new ArrayList<CFFFont>();
 
     public OTFFile() throws IOException {
         checkForFontbox();
@@ -48,9 +50,10 @@
         UnicodeMapping[] mappings = unicodeMappings.toArray(new UnicodeMapping[0]);
         for (int i = 0; i < mappings.length; i++) {
             int glyphIdx = mappings[i].getGlyphIndex();
-            Mapping m = fileFont.getGIDMappings().get(glyphIdx);
-            int[] bbox = fileFont.getBoundingBox(m.getSID());
-            String name = fileFont.getNameOfCharFromCode(m.getSID());
+            fileFonts.get(0).constructMappings();
+            Mapping m = fileFonts.get(0).getGIDMappings().get(glyphIdx);
+            int[] bbox = fileFonts.get(0).getBoundingBox(m.getSID());
+            String name = fileFonts.get(0).getNameOfCharFromCode(m.getSID());
             mtxTab[glyphIdx].setBoundingBox(bbox);
             mtxTab[glyphIdx].setName(name);
         }
@@ -61,16 +64,16 @@
         fontFile = in;
         fontFile.seekSet(0);
         CFFParser parser = new CFFParser();
-        fileFont = parser.parse(in.getAllBytes()).get(0);
+        fileFonts = parser.parse(in.getAllBytes());
     }
 
     protected void readName() throws IOException {
-        Object familyName = fileFont.getProperty("FamilyName");
+        Object familyName = fileFonts.get(0).getProperty("FamilyName");
         if (familyName != null && !familyName.equals("")) {
             familyNames.add(familyName.toString());
             fullName = familyName.toString();
         } else {
-            fullName = fileFont.getName();
+            fullName = fileFonts.get(0).getName();
             familyNames.add(fullName);
         }
     }
@@ -81,7 +84,7 @@
      * @return The byte data found in the CFF table
      */
     public static byte[] getCFFData(FontFileReader fontFile) throws IOException {
-        byte[] cff = new byte[0];
+        byte[] cff = fontFile.getAllBytes();
         CFFDataInput input = new CFFDataInput(fontFile.getAllBytes());
         input.readBytes(4); //OTTO
         short numTables = input.readShort();
Index: src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java
===================================================================
--- src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java	(working copy)
@@ -49,23 +49,23 @@
  */
 public class OTFSubSetFile extends OTFFile {
 
-    private byte[] output;
-    private int currentPos = 0;
+    protected byte[] output;
+    protected int currentPos = 0;
     private int realSize = 0;
 
     /** A map containing each glyph to be included in the subset
       * with their existing and new GID's **/
-    private LinkedHashMap<Integer, Integer> subsetGlyphs;
+    protected LinkedHashMap<Integer, Integer> subsetGlyphs = new LinkedHashMap<Integer, Integer>();
 
     /** A map of the new GID to SID used to construct the charset table **/
-    private LinkedHashMap<Integer, Integer> gidToSID;
+    protected LinkedHashMap<Integer, Integer> gidToSID;
 
-    private CFFIndexData localIndexSubr;
-    private CFFIndexData globalIndexSubr;
+    protected CFFIndexData localIndexSubr;
+    protected CFFIndexData globalIndexSubr;
 
     /** List of subroutines to write to the local / global indexes in the subset font **/
-    private List<byte[]> subsetLocalIndexSubr;
-    private List<byte[]> subsetGlobalIndexSubr;
+    protected List<byte[]> subsetLocalIndexSubr;
+    protected List<byte[]> subsetGlobalIndexSubr;
 
     /** For fonts which have an FDSelect or ROS flag in Top Dict, this is used to store the
      * local subroutine indexes for each group as opposed to the above subsetLocalIndexSubr */
@@ -76,30 +76,30 @@
     private LinkedHashMap<Integer, FDIndexReference> subsetFDSelect;
 
     /** A list of unique subroutines from the global / local subroutine indexes */
-    private List<Integer> localUniques;
-    private List<Integer> globalUniques;
+    protected List<Integer> localUniques;
+    protected List<Integer> globalUniques;
 
     /** A store of the number of subroutines each global / local subroutine will store **/
-    private int subsetLocalSubrCount;
-    private int subsetGlobalSubrCount;
+    protected int subsetLocalSubrCount;
+    protected int subsetGlobalSubrCount;
 
     /** A list of char string data for each glyph to be stored in the subset font **/
-    private List<byte[]> subsetCharStringsIndex;
+    protected List<byte[]> subsetCharStringsIndex;
 
     /** The embedded name to change in the name table **/
-    private String embeddedName;
+    protected String embeddedName;
 
     /** An array used to hold the string index data for the subset font **/
-    private List<byte[]> stringIndexData = new ArrayList<byte[]>();
+    protected List<byte[]> stringIndexData = new ArrayList<byte[]>();
 
     /** The CFF reader object used to read data and offsets from the original font file */
-    private CFFDataReader cffReader = null;
+    protected CFFDataReader cffReader = null;
 
     /** The class used to represent this font **/
     private MultiByteFont mbFont;
 
     /** The number of standard strings in CFF **/
-    private static final int NUM_STANDARD_STRINGS = 391;
+    public static final int NUM_STANDARD_STRINGS = 391;
     /** The operator used to identify a local subroutine reference */
     private static final int LOCAL_SUBROUTINE = 10;
     /** The operator used to identify a global subroutine reference */
@@ -162,7 +162,7 @@
        return result;
     }
 
-    private void createCFF() throws IOException {
+    protected void createCFF() throws IOException {
         //Header
         writeBytes(cffReader.getHeader());
 
@@ -201,7 +201,7 @@
 
         //Encoding
         int encodingOffset = currentPos;
-        writeEncoding(fileFont.getEncoding());
+        writeEncoding(fileFonts.get(0).getEncoding());
 
         //Charset table
         int charsetOffset = currentPos;
@@ -238,7 +238,7 @@
         }
     }
 
-    private List<Integer> storeFDStrings(List<Integer> uniqueNewRefs) throws IOException {
+    protected List<Integer> storeFDStrings(List<Integer> uniqueNewRefs) throws IOException {
         ArrayList<Integer> fontNameSIDs = new ArrayList<Integer>();
         List<FontDict> fdFonts = cffReader.getFDFonts();
         for (int i = 0; i < uniqueNewRefs.size(); i++) {
@@ -252,14 +252,14 @@
         return fontNameSIDs;
     }
 
-    private void writeBytes(byte[] out) {
+    protected void writeBytes(byte[] out) {
         for (int i = 0; i < out.length; i++) {
             output[currentPos++] = out[i];
             realSize++;
         }
     }
 
-    private void writeBytes(byte[] out, int offset, int length) {
+    protected void writeBytes(byte[] out, int offset, int length) {
         for (int i = offset; i < offset + length; i++) {
             output[currentPos++] = out[i];
             realSize++;
@@ -280,7 +280,7 @@
         }
     }
 
-    private void writeTopDICT() throws IOException {
+    protected void writeTopDICT() throws IOException {
         LinkedHashMap<String, DICTEntry> topDICT = cffReader.getTopDictEntries();
         List<String> topDictStringEntries = Arrays.asList("version", "Notice", "Copyright",
                 "FullName", "FamilyName", "Weight", "PostScript");
@@ -375,7 +375,7 @@
         writeIndex(stringIndexData);
     }
 
-    private void createCharStringDataCID() throws IOException {
+    protected void createCharStringDataCID() throws IOException {
         CFFIndexData charStringsIndex = cffReader.getCharStringIndex();
 
         FDSelect fontDictionary = cffReader.getFDSelect();
@@ -458,14 +458,14 @@
         }
     }
 
-    private void writeFDSelect() {
+    protected void writeFDSelect() {
         writeByte(0); //Format
         for (Integer gid : subsetFDSelect.keySet()) {
             writeByte(subsetFDSelect.get(gid).getNewFDIndex());
         }
     }
 
-    private List<Integer> getUsedFDFonts() {
+    protected List<Integer> getUsedFDFonts() {
         List<Integer> uniqueNewRefs = new ArrayList<Integer>();
         for (int gid : subsetFDSelect.keySet()) {
             int fdIndex = subsetFDSelect.get(gid).getOldFDIndex();
@@ -476,7 +476,7 @@
         return uniqueNewRefs;
     }
 
-    private List<Integer> writeCIDDictsAndSubrs(List<Integer> uniqueNewRefs)
+    protected List<Integer> writeCIDDictsAndSubrs(List<Integer> uniqueNewRefs)
             throws IOException {
         List<Integer> privateDictOffsets = new ArrayList<Integer>();
         List<FontDict> fdFonts = cffReader.getFDFonts();
@@ -498,7 +498,7 @@
         return privateDictOffsets;
     }
 
-    private int writeFDArray(List<Integer> uniqueNewRefs, List<Integer> privateDictOffsets,
+    protected int writeFDArray(List<Integer> uniqueNewRefs, List<Integer> privateDictOffsets,
             List<Integer> fontNameSIDs)
             throws IOException {
         int offset = currentPos;
@@ -791,7 +791,7 @@
         return c;
     }
 
-    private int writeIndex(List<byte[]> dataArray) {
+    protected int writeIndex(List<byte[]> dataArray) {
         int hdrTotal = 3;
         //2 byte number of items
         this.writeCard16(dataArray.size());
@@ -915,7 +915,7 @@
         }
     }
 
-    private void writePrivateDict() throws IOException {
+    protected void writePrivateDict() throws IOException {
         Map<String, DICTEntry> topDICT = cffReader.getTopDictEntries();
 
         DICTEntry privateEntry = topDICT.get("Private");
@@ -924,7 +924,7 @@
         }
     }
 
-    private void updateOffsets(int topDictOffset, int charsetOffset, int charStringOffset,
+    protected void updateOffsets(int topDictOffset, int charsetOffset, int charStringOffset,
             int privateDictOffset, int localIndexOffset, int encodingOffset)
             throws IOException {
         Map<String, DICTEntry> topDICT = cffReader.getTopDictEntries();
@@ -949,18 +949,20 @@
 
             //Update the local subroutine index offset in the private dict
             DICTEntry subroutines = privateDICT.get("Subrs");
-            int oldLocalSubrOffset = privateDictOffset + subroutines.getOffset();
-            //Value needs to be converted to -139 etc.
-            int encodeValue = 0;
-            if (subroutines.getOperandLength() == 1) {
-                encodeValue = 139;
+            if (subroutines != null) {
+                int oldLocalSubrOffset = privateDictOffset + subroutines.getOffset();
+                //Value needs to be converted to -139 etc.
+                int encodeValue = 0;
+                if (subroutines.getOperandLength() == 1) {
+                    encodeValue = 139;
+                }
+                output = updateOffset(output, oldLocalSubrOffset, subroutines.getOperandLength(),
+                        (localIndexOffset - privateDictOffset) + encodeValue);
             }
-            output = updateOffset(output, oldLocalSubrOffset, subroutines.getOperandLength(),
-                    (localIndexOffset - privateDictOffset) + encodeValue);
         }
     }
 
-    private void updateFixedOffsets(Map<String, DICTEntry> topDICT, int dataTopDictOffset,
+    protected void updateFixedOffsets(Map<String, DICTEntry> topDICT, int dataTopDictOffset,
             int charsetOffset, int charStringOffset, int encodingOffset) {
         //Charset offset in the top dict
         DICTEntry charset = topDICT.get("charset");
@@ -980,7 +982,7 @@
         }
     }
 
-    private void updateCIDOffsets(int topDictDataOffset, int fdArrayOffset, int fdSelectOffset,
+    protected void updateCIDOffsets(int topDictDataOffset, int fdArrayOffset, int fdSelectOffset,
             int charsetOffset, int charStringOffset, int encodingOffset) {
         LinkedHashMap<String, DICTEntry> topDict = cffReader.getTopDictEntries();
 
@@ -999,7 +1001,7 @@
         updateFixedOffsets(topDict, topDictDataOffset, charsetOffset, charStringOffset, encodingOffset);
     }
 
-    private byte[] updateOffset(byte[] out, int position, int length, int replacement) {
+    protected byte[] updateOffset(byte[] out, int position, int length, int replacement) {
         switch (length) {
         case 1:
             out[position] = (byte)(replacement & 0xFF);
@@ -1037,7 +1039,7 @@
      * Appends a byte to the output array,
      * updates currentPost but not realSize
      */
-    private void writeByte(int b) {
+    protected void writeByte(int b) {
         output[currentPos++] = (byte)b;
         realSize++;
     }
@@ -1046,7 +1048,7 @@
      * Appends a USHORT to the output array,
      * updates currentPost but not realSize
      */
-    private void writeCard16(int s) {
+    protected void writeCard16(int s) {
         byte b1 = (byte)((s >> 8) & 0xff);
         byte b2 = (byte)(s & 0xff);
         writeByte(b1);
Index: src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
===================================================================
--- src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java	(revision 1530933)
+++ src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java	(working copy)
@@ -35,21 +35,21 @@
  */
 public class TTFSubSetFile extends TTFFile {
 
-    private byte[] output = null;
-    private int realSize = 0;
-    private int currentPos = 0;
+    protected byte[] output = null;
+    protected int realSize = 0;
+    protected int currentPos = 0;
 
     /*
      * Offsets in name table to be filled out by table.
      * The offsets are to the checkSum field
      */
-    private Map<OFTableName, Integer> offsets = new HashMap<OFTableName, Integer>();
+    protected Map<OFTableName, Integer> offsets = new HashMap<OFTableName, Integer>();
 
     private int checkSumAdjustmentOffset = 0;
-    private int locaOffset = 0;
+    protected int locaOffset = 0;
 
     /** Stores the glyph offsets so that we can end strings at glyph boundaries */
-    private int[] glyphOffsets;
+    protected int[] glyphOffsets;
 
     /**
      * Default Constructor
@@ -67,7 +67,7 @@
     }
 
     /** The dir tab entries in the new subset font. */
-    private Map<OFTableName, OFDirTabEntry> newDirTabs
+    protected Map<OFTableName, OFDirTabEntry> newDirTabs
                         = new HashMap<OFTableName, OFDirTabEntry>();
 
     private int determineTableCount() {
@@ -93,7 +93,7 @@
     /**
      * Create the directory table
      */
-    private void createDirectory() {
+    protected void createDirectory() {
         int numTables = determineTableCount();
         // Create the TrueType header
         writeByte((byte)0);
@@ -162,7 +162,7 @@
     /**
      * Create an empty loca table without updating checksum
      */
-    private void createLoca(int size) throws IOException {
+    protected void createLoca(int size) throws IOException {
         pad4();
         locaOffset = currentPos;
         int dirTableOffset = offsets.get(OFTableName.LOCA);
@@ -177,8 +177,7 @@
         if (entry != null) {
             pad4();
             seekTab(in, tableName, 0);
-            System.arraycopy(in.getBytes((int)entry.getOffset(), (int)entry.getLength()),
-                             0, output, currentPos, (int)entry.getLength());
+            writeBytes(in.getBytes((int) entry.getOffset(), (int) entry.getLength()));
 
             updateCheckSum(currentPos, (int) entry.getLength(), tableName);
             currentPos += (int) entry.getLength();
@@ -192,28 +191,28 @@
     /**
      * Copy the cvt table as is from original font to subset font
      */
-    private boolean createCvt(FontFileReader in) throws IOException {
+    protected boolean createCvt(FontFileReader in) throws IOException {
         return copyTable(in, OFTableName.CVT);
     }
 
     /**
      * Copy the fpgm table as is from original font to subset font
      */
-    private boolean createFpgm(FontFileReader in) throws IOException {
+    protected boolean createFpgm(FontFileReader in) throws IOException {
         return copyTable(in, OFTableName.FPGM);
     }
 
     /**
      * Copy the name table as is from the original.
      */
-    private boolean createName(FontFileReader in) throws IOException {
+    protected boolean createName(FontFileReader in) throws IOException {
         return copyTable(in, OFTableName.NAME);
     }
 
     /**
      * Copy the OS/2 table as is from the original.
      */
-    private boolean createOS2(FontFileReader in) throws IOException {
+    protected boolean createOS2(FontFileReader in) throws IOException {
         return copyTable(in, OFTableName.OS2);
     }
 
@@ -221,14 +220,13 @@
      * Copy the maxp table as is from original font to subset font
      * and set num glyphs to size
      */
-    private void createMaxp(FontFileReader in, int size) throws IOException {
+    protected void createMaxp(FontFileReader in, int size) throws IOException {
         OFTableName maxp = OFTableName.MAXP;
         OFDirTabEntry entry = dirTabs.get(maxp);
         if (entry != null) {
             pad4();
             seekTab(in, maxp, 0);
-            System.arraycopy(in.getBytes((int)entry.getOffset(), (int)entry.getLength()),
-                             0, output, currentPos, (int)entry.getLength());
+            writeBytes(in.getBytes((int) entry.getOffset(), (int) entry.getLength()));
             writeUShort(currentPos + 4, size);
 
             updateCheckSum(currentPos, (int)entry.getLength(), maxp);
@@ -239,7 +237,7 @@
         }
     }
 
-    private void createPost(FontFileReader in) throws IOException {
+    protected void createPost(FontFileReader in) throws IOException {
         OFTableName post = OFTableName.POST;
         OFDirTabEntry entry = dirTabs.get(post);
         if (entry != null) {
@@ -252,12 +250,12 @@
                     0, newPostTable, 0, newTableSize);
             // set the post table to Format 3.0
             newPostTable[1] = 0x03;
-            System.arraycopy(newPostTable, 0, output, currentPos, newTableSize);
+            writeBytes(newPostTable);
             updateCheckSum(currentPos, newTableSize, post);
             currentPos += newTableSize;
             realSize += newTableSize;
         } else {
-            throw new IOException("Can't find post table");
+//            throw new IOException("Can't find post table");
         }
     }
 
@@ -265,7 +263,7 @@
     /**
      * Copy the prep table as is from original font to subset font
      */
-    private boolean createPrep(FontFileReader in) throws IOException {
+    protected boolean createPrep(FontFileReader in) throws IOException {
         return copyTable(in, OFTableName.PREP);
     }
 
@@ -274,13 +272,12 @@
      * Copy the hhea table as is from original font to subset font
      * and fill in size of hmtx table
      */
-    private void createHhea(FontFileReader in, int size) throws IOException {
+    protected void createHhea(FontFileReader in, int size) throws IOException {
         OFDirTabEntry entry = dirTabs.get(OFTableName.HHEA);
         if (entry != null) {
             pad4();
             seekTab(in, OFTableName.HHEA, 0);
-            System.arraycopy(in.getBytes((int) entry.getOffset(), (int) entry.getLength()), 0,
-                    output, currentPos, (int) entry.getLength());
+            writeBytes(in.getBytes((int) entry.getOffset(), (int) entry.getLength()));
             writeUShort((int) entry.getLength() + currentPos - 2, size);
 
             updateCheckSum(currentPos, (int) entry.getLength(), OFTableName.HHEA);
@@ -298,14 +295,13 @@
      * checkSumAdjustment to 0, store offset to checkSumAdjustment
      * in checkSumAdjustmentOffset
      */
-    private void createHead(FontFileReader in) throws IOException {
+    protected void createHead(FontFileReader in) throws IOException {
         OFTableName head = OFTableName.HEAD;
         OFDirTabEntry entry = dirTabs.get(head);
         if (entry != null) {
             pad4();
             seekTab(in, head, 0);
-            System.arraycopy(in.getBytes((int)entry.getOffset(), (int)entry.getLength()),
-                             0, output, currentPos, (int)entry.getLength());
+            writeBytes(in.getBytes((int) entry.getOffset(), (int) entry.getLength()));
 
             checkSumAdjustmentOffset = currentPos + 8;
             output[currentPos + 8] = 0;     // Set checkSumAdjustment to 0
@@ -361,10 +357,7 @@
                         glyphLength);
                 int endOffset1 = endOffset;
                 // Copy glyph
-                System.arraycopy(
-                    glyphData, 0,
-                    output, currentPos,
-                    glyphLength);
+                writeBytes(glyphData);
 
 
                 // Update loca table
@@ -402,12 +395,14 @@
         }
     }
 
-    private int[] buildSubsetIndexToOrigIndexMap(Map<Integer, Integer> glyphs) {
+    protected int[] buildSubsetIndexToOrigIndexMap(Map<Integer, Integer> glyphs) {
         int[] origIndexes = new int[glyphs.size()];
         for (Map.Entry<Integer, Integer> glyph : glyphs.entrySet()) {
             int origIndex = glyph.getKey();
             int subsetIndex = glyph.getValue();
-            origIndexes[subsetIndex] = origIndex;
+            if (origIndexes.length > subsetIndex) {
+                origIndexes[subsetIndex] = origIndex;
+            }
         }
         return origIndexes;
     }
@@ -418,8 +413,8 @@
      * Integer key and Integer value that maps the original
      * metric (key) to the subset metric (value)
      */
-    private void createHmtx(FontFileReader in,
-                            Map<Integer, Integer> glyphs) throws IOException {
+    protected void createHmtx(FontFileReader in,
+                              Map<Integer, Integer> glyphs) throws IOException {
         OFTableName hmtx = OFTableName.HMTX;
         OFDirTabEntry entry = dirTabs.get(hmtx);
 
@@ -560,7 +555,7 @@
         ttfOut.endFontStream();
     }
 
-    private void scanGlyphs(FontFileReader in, Map<Integer, Integer> subsetGlyphs)
+    protected void scanGlyphs(FontFileReader in, Map<Integer, Integer> subsetGlyphs)
             throws IOException {
         OFDirTabEntry glyfTableInfo = dirTabs.get(OFTableName.GLYF);
         if (glyfTableInfo == null) {
@@ -580,7 +575,7 @@
         int length = 0;
         try {
             byte[] buf = str.getBytes("ISO-8859-1");
-            System.arraycopy(buf, 0, output, currentPos, buf.length);
+            writeBytes(buf);
             length = buf.length;
             currentPos += length;
         } catch (java.io.UnsupportedEncodingException e) {
@@ -598,6 +593,10 @@
         output[currentPos++] = b;
     }
 
+    protected void writeBytes(byte[] b) {
+        System.arraycopy(b, 0, output, currentPos, b.length);
+    }
+
     /**
      * Appends a USHORT to the output array,
      * updates currentPost but not realSize
@@ -625,7 +624,7 @@
      * Appends a ULONG to the output array,
      * at the given position without changing currentPos
      */
-    private void writeULong(int pos, int s) {
+    protected void writeULong(int pos, int s) {
         byte b1 = (byte)((s >> 24) & 0xff);
         byte b2 = (byte)((s >> 16) & 0xff);
         byte b3 = (byte)((s >> 8) & 0xff);
@@ -640,7 +639,7 @@
      * Create a padding in the fontfile to align
      * on a 4-byte boundary
      */
-    private void pad4() {
+    protected void pad4() {
         int padSize = getPadSize(currentPos);
         if (padSize < 4) {
             for (int i = 0; i < padSize; i++) {
@@ -663,7 +662,7 @@
     }
 
 
-    private void updateCheckSum(int tableStart, int tableSize, OFTableName tableName) {
+    protected void updateCheckSum(int tableStart, int tableSize, OFTableName tableName) {
         int checksum = getCheckSum(output, tableStart, tableSize);
         int offset = offsets.get(tableName);
         int padSize = getPadSize(tableStart +  tableSize);
@@ -673,7 +672,7 @@
         writeULong(offset + 8, tableSize);
     }
 
-    private static int getCheckSum(byte[] data, int start, int size) {
+    protected static int getCheckSum(byte[] data, int start, int size) {
         // All the tables here are aligned on four byte boundaries
         // Add remainder to size if it's not a multiple of 4
         int remainder = size % 4;
@@ -687,14 +686,16 @@
             long l = 0;
             for (int j = 0; j < 4; j++) {
                 l <<= 8;
-                l |= data[start + i + j] & 0xff;
+                if (data.length > (start + i + j)) {
+                    l |= data[start + i + j] & 0xff;
+                }
             }
             sum += l;
         }
         return (int) sum;
     }
 
-    private void createCheckSumAdjustment() {
+    protected void createCheckSumAdjustment() {
         long sum = getCheckSum(output, 0, realSize);
         int checksum = (int)(0xb1b0afba - sum);
         writeULong(checkSumAdjustmentOffset, checksum);
Index: src/java/org/apache/fop/pdf/PDFCFFStream.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFCFFStream.java	(revision 0)
+++ src/java/org/apache/fop/pdf/PDFCFFStream.java	(working copy)
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Special PDFStream for embeddable CFF fonts.
+ */
+public class PDFCFFStream extends AbstractPDFFontStream {
+    private byte[] cffData;
+    private String type;
+
+    public PDFCFFStream(String type) {
+        this.type = type;
+    }
+
+    protected int getSizeHint() throws IOException {
+        if (this.cffData != null) {
+            return cffData.length;
+        } else {
+            return 0; //no hint available
+        }
+    }
+
+    protected void outputRawStreamData(OutputStream out) throws IOException {
+        out.write(this.cffData);
+    }
+
+    protected void populateStreamDict(Object lengthEntry) {
+        put("Subtype", new PDFName(type));
+        super.populateStreamDict(lengthEntry);
+    }
+
+    public void setData(byte[] data) throws IOException {
+        cffData = data;
+    }
+}

Property changes on: src/java/org/apache/fop/pdf/PDFCFFStream.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: src/java/org/apache/fop/pdf/PDFDocument.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFDocument.java	(revision 1530933)
+++ src/java/org/apache/fop/pdf/PDFDocument.java	(working copy)
@@ -161,6 +161,8 @@
 
     private boolean accessibilityEnabled;
 
+    private boolean mergeFontsEnabled;
+
     /**
      * Creates an empty PDF document.
      *
@@ -1030,6 +1032,14 @@
         return trailerDictionary;
     }
 
+    public boolean isMergeFontsEnabled() {
+        return mergeFontsEnabled;
+    }
+
+    public void setMergeFontsEnabled(boolean mergeFontsEnabled) {
+        this.mergeFontsEnabled = mergeFontsEnabled;
+    }
+
     private interface TrailerOutputHelper {
 
         void outputStructureTreeElements(OutputStream stream) throws IOException;
Index: src/java/org/apache/fop/pdf/PDFFactory.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFFactory.java	(revision 1530933)
+++ src/java/org/apache/fop/pdf/PDFFactory.java	(working copy)
@@ -1354,9 +1354,15 @@
             PDFFont font = null;
 
             font = PDFFont.createFont(fontname, fonttype, subsetFontName, null);
-            getDocument().registerObject(font);
+            if (descriptor instanceof RefPDFFont) {
+                font.setObjectNumber(((RefPDFFont)descriptor).getRef().getObjectNumber());
+                font.setDocument(getDocument());
+                getDocument().addObject(font);
+            } else {
+                getDocument().registerObject(font);
+            }
 
-            if (fonttype == FontType.TYPE0) {
+            if ((fonttype == FontType.TYPE0) && pdfdesc instanceof PDFCIDFontDescriptor) {
                 font.setEncoding(encoding);
                 CIDFont cidMetrics;
                 if (metrics instanceof LazyFont) {
@@ -1371,8 +1377,19 @@
                         cidMetrics.getDefaultWidth(), getFontWidths(cidMetrics), sysInfo,
                         (PDFCIDFontDescriptor) pdfdesc);
                 getDocument().registerObject(cidFont);
-                PDFCMap cmap = new PDFToUnicodeCMap(cidMetrics.getCIDSet().getChars(), "fop-ucs-H",
+
+                PDFCMap cmap;
+                if (cidMetrics instanceof MultiByteFont && ((MultiByteFont) cidMetrics).getCmapStream() != null) {
+                    cmap = new PDFCMap("fop-ucs-H", null);
+                    try {
+                        cmap.setData(IOUtils.toByteArray(((MultiByteFont) cidMetrics).getCmapStream()));
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                } else {
+                    cmap = new PDFToUnicodeCMap(cidMetrics.getCIDSet().getChars(), "fop-ucs-H",
                         new PDFCIDSystemInfo("Adobe", "Identity", 0), false);
+                }
                 getDocument().registerObject(cmap);
                 ((PDFFontType0)font).setCMAP(cmap);
                 ((PDFFontType0)font).setDescendantFonts(cidFont);
@@ -1403,6 +1420,29 @@
                     font.setEncoding(mapping.getName());
                     //No ToUnicode CMap necessary if PDF 1.4, chapter 5.9 (page 368) is to be
                     //believed.
+                } else if (mapping.getName().equals("FOPPDFEncoding")) {
+                    String[] charNameMap = mapping.getCharNameMap();
+                    char[] intmap = mapping.getUnicodeCharMap();
+                    PDFArray differences = new PDFArray();
+                    int len = intmap.length;
+                    if (charNameMap.length < len) {
+                        len = charNameMap.length;
+                    }
+                    int last = 0;
+                    for (int i = 0; i < len; i++) {
+                        if (intmap[i] - 1 != last) {
+                            differences.add(intmap[i]);
+                        }
+                        last = intmap[i];
+                        differences.add(new PDFName(charNameMap[i]));
+                    }
+                    PDFEncoding pdfEncoding = new PDFEncoding(singleByteFont.getEncodingName());
+                    getDocument().registerObject(pdfEncoding);
+                    pdfEncoding.setDifferences(differences);
+                    font.setEncoding(pdfEncoding);
+                    if (mapping.getUnicodeCharMap() != null) {
+                        generateToUnicodeCmap(nonBase14, mapping);
+                    }
                 } else {
                     Object pdfEncoding = createPDFEncoding(mapping,
                     singleByteFont.getFontName());
@@ -1466,8 +1506,30 @@
     private PDFWArray getFontWidths(CIDFont cidFont) {
         // Create widths for reencoded chars
         PDFWArray warray = new PDFWArray();
-        int[] widths = cidFont.getCIDSet().getWidths();
-        warray.addEntry(0, widths);
+        if (cidFont instanceof MultiByteFont && ((MultiByteFont)cidFont).getWidthsMap() != null) {
+            Map<Integer, Integer> map = ((MultiByteFont)cidFont).getWidthsMap();
+            for (Map.Entry<Integer, Integer> cid : map.entrySet()) {
+                warray.addEntry(cid.getKey(), new int[] {cid.getValue()});
+            }
+//            List<Integer> l = new ArrayList<Integer>(map.keySet());
+//            for (int i=0; i<map.size(); i++) {
+//                int cid = l.get(i);
+//                List<Integer> cids = new ArrayList<Integer>();
+//                cids.add(map.get(cid));
+//                while (i<map.size()-1 && l.get(i) + 1 == l.get(i + 1)) {
+//                    cids.add(map.get(l.get(i + 1)));
+//                    i++;
+//                }
+//                int[] cidsints = new int[cids.size()];
+//                for (int j=0; j<cids.size(); j++) {
+//                    cidsints[j] = cids.get(j);
+//                }
+//                warray.addEntry(cid, cidsints);
+//            }
+        } else {
+            int[] widths = cidFont.getCIDSet().getWidths();
+            warray.addEntry(0, widths);
+        }
         return warray;
     }
 
@@ -1580,46 +1642,50 @@
             in = font.getInputStream();
             if (in == null) {
                 return null;
-            } else {
-                AbstractPDFStream embeddedFont = null;
-                if (desc.getFontType() == FontType.TYPE0) {
-                    MultiByteFont mbfont = (MultiByteFont) font;
-                    FontFileReader reader = new FontFileReader(in);
-                    byte[] fontBytes;
-                    String header = OFFontLoader.readHeader(reader);
-                    boolean isCFF = mbfont.isOTFFile();
-                    if (font.getEmbeddingMode() == EmbeddingMode.FULL) {
-                        fontBytes = reader.getAllBytes();
-                        if (isCFF) {
-                            //Ensure version 1.6 for full OTF CFF embedding
-                            document.setPDFVersion(Version.V1_6);
-                        }
-                    } else {
-                        fontBytes = getFontSubsetBytes(reader, mbfont, header, fontPrefix, desc,
-                                isCFF);
+            }
+            AbstractPDFStream embeddedFont = null;
+            if (desc.getFontType() == FontType.TYPE0) {
+                MultiByteFont mbfont = (MultiByteFont) font;
+                FontFileReader reader = new FontFileReader(in);
+                byte[] fontBytes;
+                String header = OFFontLoader.readHeader(reader);
+                boolean isCFF = mbfont.isOTFFile();
+                if (font.getEmbeddingMode() == EmbeddingMode.FULL) {
+                    fontBytes = reader.getAllBytes();
+                    if (isCFF) {
+                        //Ensure version 1.6 for full OTF CFF embedding
+                        document.setPDFVersion(Version.V1_6);
                     }
-                    embeddedFont = getFontStream(font, fontBytes, isCFF);
-                } else if (desc.getFontType() == FontType.TYPE1) {
-                    PFBParser parser = new PFBParser();
-                    PFBData pfb = parser.parsePFB(in);
-                    embeddedFont = new PDFT1Stream();
-                    ((PDFT1Stream) embeddedFont).setData(pfb);
                 } else {
-                    byte[] file = IOUtils.toByteArray(in);
-                    embeddedFont = new PDFTTFStream(file.length);
-                    ((PDFTTFStream) embeddedFont).setData(file, file.length);
+                    fontBytes = getFontSubsetBytes(reader, mbfont, header, fontPrefix, desc,
+                            isCFF);
                 }
+                embeddedFont = getFontStream(font, fontBytes, isCFF);
+            } else if (desc.getFontType() == FontType.TYPE1) {
+                PFBParser parser = new PFBParser();
+                PFBData pfb = parser.parsePFB(in);
+                embeddedFont = new PDFT1Stream();
+                ((PDFT1Stream) embeddedFont).setData(pfb);
+            } else if (desc.getFontType() == FontType.TYPE1C) {
+                byte[] file = IOUtils.toByteArray(in);
+                PDFCFFStream embeddedFont2 = new PDFCFFStream("Type1C");
+                embeddedFont2.setData(file);
+                return embeddedFont2;
+            } else {
+                byte[] file = IOUtils.toByteArray(in);
+                embeddedFont = new PDFTTFStream(file.length);
+                ((PDFTTFStream) embeddedFont).setData(file, file.length);
+            }
 
-                /*
-                embeddedFont.getFilterList().addFilter("flate");
-                if (getDocument().isEncryptionActive()) {
-                    getDocument().applyEncryption(embeddedFont);
-                } else {
-                    embeddedFont.getFilterList().addFilter("ascii-85");
-                }*/
+            /*
+            embeddedFont.getFilterList().addFilter("flate");
+            if (getDocument().isEncryptionActive()) {
+                getDocument().applyEncryption(embeddedFont);
+            } else {
+                embeddedFont.getFilterList().addFilter("ascii-85");
+            }*/
 
-                return embeddedFont;
-            }
+            return embeddedFont;
         } catch (IOException ioe) {
             log.error("Failed to embed font [" + desc + "] " + desc.getEmbedFontName(), ioe);
             return null;
Index: src/java/org/apache/fop/pdf/PDFFont.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFFont.java	(revision 1530933)
+++ src/java/org/apache/fop/pdf/PDFFont.java	(working copy)
@@ -109,6 +109,7 @@
             return new PDFFontType0(fontname, basefont,
                                     encoding);
         } else if ((subtype == FontType.TYPE1)
+                || (subtype == FontType.TYPE1C)
                 || (subtype == FontType.MMTYPE1)) {
             return new PDFFontType1(fontname, basefont,
                                     encoding);
Index: src/java/org/apache/fop/pdf/PDFFontDescriptor.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFFontDescriptor.java	(revision 1530933)
+++ src/java/org/apache/fop/pdf/PDFFontDescriptor.java	(working copy)
@@ -102,7 +102,7 @@
     public void setFontFile(FontType subtype, AbstractPDFStream fontfile) {
         if (subtype == FontType.TYPE1) {
             put("FontFile", fontfile);
-        } else if (fontfile instanceof PDFCFFStreamType0C) {
+        } else if (fontfile instanceof PDFCFFStreamType0C || subtype == FontType.TYPE1C) {
             put("FontFile3", fontfile);
         } else {
             put("FontFile2", fontfile);
Index: src/java/org/apache/fop/pdf/RefPDFFont.java
===================================================================
--- src/java/org/apache/fop/pdf/RefPDFFont.java	(revision 0)
+++ src/java/org/apache/fop/pdf/RefPDFFont.java	(working copy)
@@ -0,0 +1,21 @@
+/*
+ * 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.fop.pdf;
+
+public interface RefPDFFont {
+    PDFDictionary getRef();
+}

Property changes on: src/java/org/apache/fop/pdf/RefPDFFont.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java
===================================================================
--- src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java	(revision 1530933)
+++ src/java/org/apache/fop/render/intermediate/AbstractIFPainter.java	(working copy)
@@ -245,7 +245,7 @@
         if (log.isTraceEnabled()) {
             log.trace("Using ImageHandler: " + handler.getClass().getName());
         }
-
+        context.putHint("fontinfo", getFontInfo());
         handler.handleImage(context, effImage, rect);
     }
 
Index: src/java/org/apache/fop/render/pdf/PDFRendererConfig.java
===================================================================
--- src/java/org/apache/fop/render/pdf/PDFRendererConfig.java	(revision 1530933)
+++ src/java/org/apache/fop/render/pdf/PDFRendererConfig.java	(working copy)
@@ -56,6 +56,7 @@
 import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
 import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
 import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
 import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
@@ -135,6 +136,7 @@
                 configureEncryptionParams(cfg, userAgent, strict);
                 parseAndPut(OUTPUT_PROFILE, cfg);
                 parseAndPut(DISABLE_SRGB_COLORSPACE, cfg);
+                parseAndPut(MERGE_FONTS, cfg);
 
                 parseAndPut(VERSION, cfg);
             } catch (ConfigurationException e) {
Index: src/java/org/apache/fop/render/pdf/PDFRendererOption.java
===================================================================
--- src/java/org/apache/fop/render/pdf/PDFRendererOption.java	(revision 1530933)
+++ src/java/org/apache/fop/render/pdf/PDFRendererOption.java	(working copy)
@@ -66,6 +66,12 @@
             return Boolean.valueOf(value);
         }
     },
+    MERGE_FONTS("merge-fonts", false) {
+        @Override
+        Boolean deserialize(String value) {
+            return Boolean.valueOf(value);
+        }
+    },
     /** Rendering Options key for the ICC profile for the output intent. */
     OUTPUT_PROFILE("output-profile") {
         @Override
Index: src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
===================================================================
--- src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java	(revision 1530933)
+++ src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java	(working copy)
@@ -31,6 +31,7 @@
 
 import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
 import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
+import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
 import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
 import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
@@ -120,4 +121,8 @@
     public Version getPDFVersion() {
         return (Version) properties.get(VERSION);
     }
+
+    public Boolean getMergeFontsEnabled() {
+        return (Boolean)properties.get(MERGE_FONTS);
+    }
 }
Index: src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
===================================================================
--- src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java	(revision 1530933)
+++ src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java	(working copy)
@@ -338,6 +338,7 @@
         }
 
         this.pdfDoc.enableAccessibility(userAgent.isAccessibilityEnabled());
+        pdfDoc.setMergeFontsEnabled(rendererConfig.getMergeFontsEnabled());
 
         return this.pdfDoc;
     }
Index: test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java
===================================================================
--- test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java	(revision 1530933)
+++ test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java	(working copy)
@@ -95,7 +95,7 @@
     }
 
     private void validateCharStrings(CFFDataReader cffReader) throws IOException {
-        CFFFont sourceSansOriginal = sourceSansProBold.fileFont;
+        CFFFont sourceSansOriginal = sourceSansProBold.fileFonts.get(0);
         Map<String, byte[]> origCharStringData = sourceSansOriginal.getCharStringsDict();
         IndexData origGlobalIndex = sourceSansOriginal.getGlobalSubrIndex();
         IndexData origLocalIndex = sourceSansOriginal.getLocalSubrIndex();
