Author: ssteiner
Date: Tue May 17 13:32:40 2016
New Revision: 1744262

URL: http://svn.apache.org/viewvc?rev=1744262&view=rev
Log:
FOP-2608: Convert OTF to Type 1 in postscript

Added:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java
   (with props)
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java
   (with props)
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java
   (with props)
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java
   (with props)
Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfig.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/EmbedFontInfo.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/FontLoader.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1SubsetFile.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSFontUtils.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSPainter.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
    xmlgraphics/fop/trunk/fop/src/foschema/fop-configuration.xsd

Added: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java?rev=1744262&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java
 Tue May 17 13:32:40 2016
@@ -0,0 +1,66 @@
+/*
+ * 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.fonts;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.fontbox.cff.CFFFont;
+import org.apache.fontbox.cff.CFFParser;
+import org.apache.fontbox.cff.CFFType1Font;
+
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.fonts.type1.PFBData;
+import org.apache.fop.fonts.type1.PFBParser;
+import org.apache.fop.fonts.type1.Type1SubsetFile;
+import org.apache.fop.render.ps.Type1FontFormatter;
+
+public class CFFToType1Font extends MultiByteFont {
+
+    public CFFToType1Font(InternalResourceResolver resourceResolver, 
EmbeddingMode embeddingMode) {
+        super(resourceResolver, embeddingMode);
+        setEmbeddingMode(EmbeddingMode.FULL);
+        setFontType(FontType.TYPE1);
+    }
+
+    public InputStream getInputStream() throws IOException {
+        InputStream cff = super.getInputStream();
+        return convertOTFToType1(cff);
+    }
+
+    private InputStream convertOTFToType1(InputStream in) throws IOException {
+        CFFFont f = new CFFParser().parse(IOUtils.toByteArray(in)).get(0);
+        if (!(f instanceof  CFFType1Font)) {
+            throw new IOException(getEmbedFileURI() + ": only OTF CFF Type1 
font can be converted to Type1");
+        }
+        byte[] t1 = new 
Type1FontFormatter(cidSet.getGlyphs()).format((CFFType1Font) f);
+        PFBData pfb = new PFBParser().parsePFB(new ByteArrayInputStream(t1));
+        ByteArrayOutputStream s1 = new ByteArrayOutputStream();
+        s1.write(pfb.getHeaderSegment());
+        ByteArrayOutputStream s2 = new ByteArrayOutputStream();
+        s2.write(pfb.getEncryptedSegment());
+        ByteArrayOutputStream s3 = new ByteArrayOutputStream();
+        s3.write(pfb.getTrailerSegment());
+        byte[] out = new Type1SubsetFile().stitchFont(s1, s2, s3);
+        return new ByteArrayInputStream(out);
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/CFFToType1Font.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfig.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfig.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfig.java
 Tue May 17 13:32:40 2016
@@ -79,6 +79,7 @@ public final class DefaultFontConfig imp
 
         private  boolean strict;
 
+        private Configuration config;
         private  Configuration fontInfoCfg;
 
         private  DefaultFontConfig instance;
@@ -88,6 +89,7 @@ public final class DefaultFontConfig imp
                 instance = null;
             } else {
                 this.strict = strict;
+                this.config = cfg;
                 this.fontInfoCfg = cfg.getChild("fonts", false);
                 instance = new 
DefaultFontConfig(fontInfoCfg.getChild("auto-detect", false) != null);
                 parse();
@@ -108,13 +110,15 @@ public final class DefaultFontConfig imp
                             strict);
                     continue;
                 }
-                Font font = new Font(fontCfg.getAttribute("metrics-url", 
null), embed, fontCfg.getAttribute(
-                        "embed-url-afm", null), 
fontCfg.getAttribute("embed-url-pfm", null),
+                Font font = new Font(fontCfg.getAttribute("metrics-url", 
null), embed,
+                        fontCfg.getAttribute("embed-url-afm", null),
+                        fontCfg.getAttribute("embed-url-pfm", null),
                         fontCfg.getAttribute("sub-font", null),
-                        fontCfg.getAttributeAsBoolean("kerning", true), 
fontCfg.getAttributeAsBoolean(
-                                "advanced", true), 
fontCfg.getAttribute("encoding-mode",
-                                EncodingMode.AUTO.getName()), 
fontCfg.getAttribute("embedding-mode",
-                                EncodingMode.AUTO.getName()));
+                        fontCfg.getAttributeAsBoolean("kerning", true),
+                        fontCfg.getAttributeAsBoolean("advanced", true),
+                        fontCfg.getAttribute("encoding-mode", 
EncodingMode.AUTO.getName()),
+                        fontCfg.getAttribute("embedding-mode", 
EncodingMode.AUTO.getName()),
+                        fontCfg.getAttributeAsBoolean("embed-as-type1", 
false));
                 instance.fonts.add(font);
                 boolean hasTriplets = false;
                 for (Configuration tripletCfg : 
fontCfg.getChildren("font-triplet")) {
@@ -126,6 +130,13 @@ public final class DefaultFontConfig imp
                 if (!hasTriplets) {
                     LogUtil.handleError(log, "font without font-triplet", 
strict);
                 }
+                try {
+                    if (font.getEmbedAsType1() && 
!config.getAttribute("mime").equals("application/postscript")) {
+                        throw new FOPException("The embed-as-type1 attribute 
is only supported in postscript");
+                    }
+                } catch (ConfigurationException ex) {
+                    LogUtil.handleException(log, ex, true);
+                }
             }
         }
 
@@ -289,6 +300,8 @@ public final class DefaultFontConfig imp
             return encodingMode;
         }
 
+        private final boolean embedAsType1;
+
         private final List<FontTriplet> tripletList = new 
ArrayList<FontTriplet>();
 
         public List<FontTriplet> getTripletList() {
@@ -296,7 +309,7 @@ public final class DefaultFontConfig imp
         }
 
         private Font(String metrics, String embed, String afm, String pfm, 
String subFont, boolean kerning,
-                boolean advanced, String encodingMode, String embeddingMode) {
+                boolean advanced, String encodingMode, String embeddingMode, 
boolean embedAsType1) {
             this.metrics = metrics;
             this.embedUri = embed;
             this.afm = afm;
@@ -306,6 +319,7 @@ public final class DefaultFontConfig imp
             this.advanced = advanced;
             this.encodingMode = encodingMode;
             this.embeddingMode = embeddingMode;
+            this.embedAsType1 = embedAsType1;
         }
 
         /**
@@ -355,5 +369,9 @@ public final class DefaultFontConfig imp
         public String getPfm() {
             return pfm;
         }
+
+        public boolean getEmbedAsType1() {
+            return embedAsType1;
+        }
     }
 }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/DefaultFontConfigurator.java
 Tue May 17 13:32:40 2016
@@ -167,7 +167,7 @@ public class DefaultFontConfigurator imp
         EncodingMode encodingMode = 
EncodingMode.getValue(font.getEncodingMode());
         EmbeddingMode embeddingMode = 
EmbeddingMode.getValue(font.getEmbeddingMode());
         EmbedFontInfo embedFontInfo = new EmbedFontInfo(fontUris, 
font.isKerning(), font.isAdvanced(),
-                tripletList, subFont, encodingMode, embeddingMode);
+                tripletList, subFont, encodingMode, embeddingMode, 
font.getEmbedAsType1());
         if (fontCache != null) {
             if (!fontCache.containsFont(embedFontInfo)) {
                 fontCache.addFont(embedFontInfo, resourceResolver);

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/EmbedFontInfo.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/EmbedFontInfo.java
 Tue May 17 13:32:40 2016
@@ -47,6 +47,7 @@ public class EmbedFontInfo implements Se
     protected String postScriptName;
     /** the sub-fontname of the font (used for TrueType Collections, null 
otherwise) */
     protected String subFontName;
+    private boolean embedAsType1;
 
     /** the list of associated font triplets */
     private List<FontTriplet> fontTriplets;
@@ -67,7 +68,7 @@ public class EmbedFontInfo implements Se
      */
     public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean advanced,
             List<FontTriplet> fontTriplets, String subFontName,
-            EncodingMode encodingMode, EmbeddingMode embeddingMode) {
+            EncodingMode encodingMode, EmbeddingMode embeddingMode, boolean 
embedAsType1) {
         this.kerning = kerning;
         this.advanced = advanced;
         this.fontTriplets = fontTriplets;
@@ -75,6 +76,7 @@ public class EmbedFontInfo implements Se
         this.encodingMode = encodingMode;
         this.embeddingMode = embeddingMode;
         this.fontUris = fontUris;
+        this.embedAsType1 = embedAsType1;
     }
 
     /**
@@ -88,7 +90,7 @@ public class EmbedFontInfo implements Se
     public EmbedFontInfo(FontUris fontUris, boolean kerning, boolean advanced,
             List<FontTriplet> fontTriplets, String subFontName) {
         this(fontUris, kerning, advanced, fontTriplets, subFontName, 
EncodingMode.AUTO,
-                EmbeddingMode.AUTO);
+                EmbeddingMode.AUTO, false);
     }
 
     /**
@@ -194,6 +196,10 @@ public class EmbedFontInfo implements Se
         return this.encodingMode;
     }
 
+    public boolean getEmbedAsType1() {
+        return embedAsType1;
+    }
+
     private void readObject(java.io.ObjectInputStream in)
                 throws IOException, ClassNotFoundException {
         in.defaultReadObject();

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/FontLoader.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/FontLoader.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/FontLoader.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/FontLoader.java
 Tue May 17 13:32:40 2016
@@ -91,7 +91,8 @@ public abstract class FontLoader {
      */
     public static CustomFont loadFont(FontUris fontUris, String subFontName,
             boolean embedded, EmbeddingMode embeddingMode, EncodingMode 
encodingMode,
-            boolean useKerning, boolean useAdvanced, InternalResourceResolver 
resourceResolver) throws IOException {
+            boolean useKerning, boolean useAdvanced, InternalResourceResolver 
resourceResolver,
+                                      boolean embedAsType1) throws IOException 
{
         boolean type1 = isType1(fontUris.getEmbed());
         FontLoader loader;
         if (type1) {
@@ -103,7 +104,7 @@ public abstract class FontLoader {
                     resourceResolver);
         } else {
             loader = new OFFontLoader(fontUris.getEmbed(), subFontName, 
embedded, embeddingMode,
-                    encodingMode, useKerning, useAdvanced, resourceResolver);
+                    encodingMode, useKerning, useAdvanced, resourceResolver, 
embedAsType1);
         }
         return loader.getFont();
     }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java 
(original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java 
Tue May 17 13:32:40 2016
@@ -47,6 +47,7 @@ public class LazyFont extends Typeface i
 
     private final boolean useKerning;
     private final boolean useAdvanced;
+    private boolean embedAsType1;
     private final EncodingMode encodingMode;
     private final EmbeddingMode embeddingMode;
     private final String subFontName;
@@ -72,6 +73,7 @@ public class LazyFont extends Typeface i
         } else {
             this.useAdvanced = fontInfo.getAdvanced();
         }
+        this.embedAsType1 = fontInfo.getEmbedAsType1();
         this.encodingMode = fontInfo.getEncodingMode() != null ? 
fontInfo.getEncodingMode()
                 : EncodingMode.AUTO;
         this.embeddingMode = fontInfo.getEmbeddingMode() != null ? 
fontInfo.getEmbeddingMode()
@@ -114,7 +116,7 @@ public class LazyFont extends Typeface i
                         throw new RuntimeException("Cannot load font. No font 
URIs available.");
                     }
                     realFont = FontLoader.loadFont(fontUris, subFontName, 
embedded,
-                            embeddingMode, encodingMode, useKerning, 
useAdvanced, resourceResolver);
+                            embeddingMode, encodingMode, useKerning, 
useAdvanced, resourceResolver, embedAsType1);
                 }
                 if (realFont instanceof FontDescriptor) {
                     realFontDescriptor = (FontDescriptor) realFont;

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
 Tue May 17 13:32:40 2016
@@ -150,8 +150,7 @@ public class FontInfoFinder {
             subFontName = ((MultiByteFont) customFont).getTTCName();
         }
         EmbedFontInfo fontInfo = new EmbedFontInfo(fontUris, 
customFont.isKerningEnabled(),
-                customFont.isAdvancedEnabled(), fontTripletList, subFontName,
-                EncodingMode.AUTO, EmbeddingMode.AUTO);
+                customFont.isAdvancedEnabled(), fontTripletList, subFontName);
         fontInfo.setPostScriptName(customFont.getFontName());
         if (fontCache != null) {
             fontCache.addFont(fontInfo, resourceResolver);
@@ -224,7 +223,7 @@ public class FontInfoFinder {
                 try {
                     OFFontLoader ttfLoader = new OFFontLoader(fontURI, 
fontName, true,
                             EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, 
useAdvanced,
-                            resourceResolver);
+                            resourceResolver, false);
                     customFont = ttfLoader.getFont();
                     if (this.eventListener != null) {
                         customFont.setEventListener(this.eventListener);
@@ -252,7 +251,7 @@ public class FontInfoFinder {
             try {
                 FontUris fontUris = new FontUris(fontURI, null);
                 customFont = FontLoader.loadFont(fontUris, null, true, 
EmbeddingMode.AUTO, EncodingMode.AUTO,
-                        useKerning, useAdvanced, resourceResolver);
+                        useKerning, useAdvanced, resourceResolver, false);
                 if (this.eventListener != null) {
                     customFont.setEventListener(this.eventListener);
                 }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java
 Tue May 17 13:32:40 2016
@@ -29,6 +29,7 @@ import java.util.Set;
 import org.apache.commons.io.IOUtils;
 
 import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.fonts.CFFToType1Font;
 import org.apache.fop.fonts.CIDFontType;
 import org.apache.fop.fonts.CMapSegment;
 import org.apache.fop.fonts.EmbeddingMode;
@@ -51,6 +52,7 @@ public class OFFontLoader extends FontLo
     private final String subFontName;
     private EncodingMode encodingMode;
     private EmbeddingMode embeddingMode;
+    private boolean embedAsType1;
 
     /**
      * Default constructor
@@ -58,7 +60,7 @@ public class OFFontLoader extends FontLo
      * @param resourceResolver the resource resolver for font URI resolution
      */
     public OFFontLoader(URI fontFileURI, InternalResourceResolver 
resourceResolver) {
-        this(fontFileURI, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, 
true, true, resourceResolver);
+        this(fontFileURI, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, 
true, true, resourceResolver, false);
     }
 
     /**
@@ -75,11 +77,12 @@ public class OFFontLoader extends FontLo
      */
     public OFFontLoader(URI fontFileURI, String subFontName, boolean embedded,
             EmbeddingMode embeddingMode, EncodingMode encodingMode, boolean 
useKerning,
-            boolean useAdvanced, InternalResourceResolver resolver) {
+            boolean useAdvanced, InternalResourceResolver resolver, boolean 
embedAsType1) {
         super(fontFileURI, embedded, useKerning, useAdvanced, resolver);
         this.subFontName = subFontName;
         this.encodingMode = encodingMode;
         this.embeddingMode = embeddingMode;
+        this.embedAsType1 = embedAsType1;
         if (this.encodingMode == EncodingMode.AUTO) {
             this.encodingMode = EncodingMode.CID; //Default to CID mode for 
TrueType
         }
@@ -110,7 +113,7 @@ public class OFFontLoader extends FontLo
             if (!supported) {
                 throw new IOException("The font does not have a Unicode cmap 
table: " + fontFileURI);
             }
-            buildFont(otf, ttcFontName);
+            buildFont(otf, ttcFontName, embedAsType1);
             loaded = true;
         } finally {
             IOUtils.closeQuietly(in);
@@ -125,15 +128,19 @@ public class OFFontLoader extends FontLo
         return null;
     }
 
-    private void buildFont(OpenFont otf, String ttcFontName) {
+    private void buildFont(OpenFont otf, String ttcFontName, boolean 
embedAsType1) {
         boolean isCid = this.embedded;
         if (this.encodingMode == EncodingMode.SINGLE_BYTE) {
             isCid = false;
         }
 
         if (isCid) {
-            multiFont = new MultiByteFont(resourceResolver, embeddingMode);
-            multiFont.setIsOTFFile(otf instanceof OTFFile);
+            if (otf instanceof OTFFile && embedAsType1) {
+                multiFont = new CFFToType1Font(resourceResolver, 
embeddingMode);
+            } else {
+                multiFont = new MultiByteFont(resourceResolver, embeddingMode);
+                multiFont.setIsOTFFile(otf instanceof OTFFile);
+            }
             returnFont = multiFont;
             multiFont.setTTCName(ttcFontName);
         } else {
@@ -142,7 +149,11 @@ public class OFFontLoader extends FontLo
         }
 
         returnFont.setFontURI(fontFileURI);
-        returnFont.setFontName(otf.getPostScriptName());
+        if (!otf.getEmbedFontName().equals("")) {
+            returnFont.setFontName(otf.getEmbedFontName());
+        } else {
+            returnFont.setFontName(otf.getPostScriptName());
+        }
         returnFont.setFullName(otf.getFullName());
         returnFont.setFamilyNames(otf.getFamilyNames());
         returnFont.setFontSubFamilyName(otf.getSubFamilyName());
@@ -160,7 +171,6 @@ public class OFFontLoader extends FontLo
         returnFont.setItalicAngle(Integer.parseInt(otf.getItalicAngle()));
         returnFont.setMissingWidth(0);
         returnFont.setWeight(otf.getWeightClass());
-        returnFont.setEmbeddingMode(this.embeddingMode);
         if (isCid) {
             if (otf instanceof OTFFile) {
                 multiFont.setCIDType(CIDFontType.CIDTYPE0);

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
 Tue May 17 13:32:40 2016
@@ -88,6 +88,7 @@ public class OTFFile extends OpenFont {
         fontFile.seekSet(0);
         CFFParser parser = new CFFParser();
         fileFont = parser.parse(in.getAllBytes()).get(0);
+        embedFontName = fileFont.getName();
     }
 
     protected void readName() throws IOException {

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
 Tue May 17 13:32:40 2016
@@ -184,6 +184,7 @@ public abstract class OpenFont {
 
     protected String postScriptName = "";
     protected String fullName = "";
+    protected String embedFontName = "";
     protected String notice = "";
     protected final Set<String> familyNames = new HashSet<String>();
     protected String subFamilyName = "";
@@ -2000,6 +2001,10 @@ public abstract class OpenFont {
         }
     }
 
+    public String getEmbedFontName() {
+        return embedFontName;
+    }
+
     public String getCopyrightNotice() {
         return notice;
     }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1SubsetFile.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1SubsetFile.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1SubsetFile.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1SubsetFile.java
 Tue May 17 13:32:40 2016
@@ -156,8 +156,8 @@ public class Type1SubsetFile {
         return stitchFont(boasHeader, boasMain, baosTrailer);
     }
 
-    protected byte[] stitchFont(ByteArrayOutputStream boasHeader, 
ByteArrayOutputStream boasMain,
-                                ByteArrayOutputStream boasTrailer) throws 
IOException {
+    public byte[] stitchFont(ByteArrayOutputStream boasHeader, 
ByteArrayOutputStream boasMain,
+                             ByteArrayOutputStream boasTrailer) throws 
IOException {
         int headerLength = boasHeader.size();
         int mainLength = boasMain.size();
 

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
 Tue May 17 13:32:40 2016
@@ -86,7 +86,8 @@ public class ConfiguredFontCollection im
                     CustomFont fontMetrics = FontLoader.loadFont(fontUris,
                             configFontInfo.getSubFontName(), true,
                             configFontInfo.getEmbeddingMode(), 
configFontInfo.getEncodingMode(),
-                            configFontInfo.getKerning(), 
configFontInfo.getAdvanced(), resourceResolver);
+                            configFontInfo.getKerning(), 
configFontInfo.getAdvanced(), resourceResolver,
+                            configFontInfo.getEmbedAsType1());
                     font = new CustomFontMetricsMapper(fontMetrics);
                 }
 

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSFontUtils.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSFontUtils.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSFontUtils.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSFontUtils.java
 Tue May 17 13:32:40 2016
@@ -277,7 +277,7 @@ public class PSFontUtils extends org.apa
                 }
                 gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, fontRes);
                 if (fontType == FontType.TYPE1) {
-                    embedType1Font(gen, (SingleByteFont) tf, in);
+                    embedType1Font(gen, (CustomFont) tf, in);
                     fontResource = PSFontResource.createFontResource(fontRes);
                 } else if (fontType == FontType.TRUETYPE) {
                     embedTrueTypeFont(gen, (SingleByteFont) tf, in);
@@ -316,7 +316,7 @@ public class PSFontUtils extends org.apa
         }
     }
 
-    private static void embedType1Font(PSGenerator gen, SingleByteFont font,
+    private static void embedType1Font(PSGenerator gen, CustomFont font,
             InputStream fontStream) throws IOException {
         if (font.getEmbeddingMode() == EmbeddingMode.AUTO) {
             font.setEmbeddingMode(EmbeddingMode.FULL);
@@ -326,12 +326,12 @@ public class PSFontUtils extends org.apa
         boolean embed = true;
         if (font.getEmbeddingMode() == EmbeddingMode.SUBSET) {
             Type1SubsetFile subset = new Type1SubsetFile();
-            byte[] byteSubset = subset.createSubset(fontStream, font);
+            byte[] byteSubset = subset.createSubset(fontStream, 
(SingleByteFont) font);
             fontStream = new ByteArrayInputStream(byteSubset);
         }
         embedType1Font(gen, fontStream);
         if (font.getEmbeddingMode() == EmbeddingMode.SUBSET) {
-            writeEncoding(gen, font);
+            writeEncoding(gen, (SingleByteFont) font);
         }
     }
 

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSPainter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSPainter.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSPainter.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/PSPainter.java
 Tue May 17 13:32:40 2016
@@ -40,6 +40,7 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.ps.PSGenerator;
 import org.apache.xmlgraphics.ps.PSResource;
 
+import org.apache.fop.fonts.CFFToType1Font;
 import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontTriplet;
@@ -458,7 +459,7 @@ public class PSPainter extends AbstractI
         int lineStart = 0;
         StringBuffer accText = new StringBuffer(initialSize);
         StringBuffer sb = new StringBuffer(initialSize);
-        boolean isOTF = multiByte && ((MultiByteFont)tf).isOTFFile();
+        boolean isOTF = multiByte && ((MultiByteFont)tf).isOTFFile() || tf 
instanceof CFFToType1Font;
         for (int i = start; i < end; i++) {
             char orgChar = text.charAt(i);
             char ch;

Added: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java?rev=1744262&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java
 Tue May 17 13:32:40 2016
@@ -0,0 +1,86 @@
+/*
+ * 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.render.ps;
+
+import java.io.ByteArrayOutputStream;
+import java.util.List;
+
+import org.apache.fontbox.cff.CharStringCommand;
+
+/**
+ * This class represents a formatter for CharString commands of a Type1 font.
+ * author Villu Ruusmann
+ * @version $Revision: 1.0 $
+ */
+public class Type1CharStringFormatter {
+
+    private ByteArrayOutputStream output;
+
+    /**
+     * Formats the given command sequence to a byte array.
+     * @param sequence the given command sequence
+     * @return the formatted seuqence as byte array
+     */
+    public byte[] format(List<Object> sequence) {
+        output = new ByteArrayOutputStream();
+
+        for (Object object : sequence) {
+            if (object instanceof CharStringCommand) {
+                writeCommand((CharStringCommand) object);
+            } else if (object instanceof Integer) {
+                writeNumber((Integer) object);
+            } else {
+                throw new IllegalArgumentException();
+            }
+        }
+        return output.toByteArray();
+    }
+
+    private void writeCommand(CharStringCommand command) {
+        int[] value = command.getKey().getValue();
+        for (int aValue : value) {
+            output.write(aValue);
+        }
+    }
+
+    private void writeNumber(Integer number) {
+        int value = number;
+        if (value >= -107 && value <= 107) {
+            output.write(value + 139);
+        } else if (value >= 108 && value <= 1131) {
+            int b1 = (value - 108) % 256;
+            int b0 = (value - 108 - b1) / 256 + 247;
+            output.write(b0);
+            output.write(b1);
+        } else if (value >= -1131 && value <= -108) {
+            int b1 = -((value + 108) % 256);
+            int b0 = -((value + 108 + b1) / 256 - 251);
+            output.write(b0);
+            output.write(b1);
+        } else {
+            int b1 = value >>> 24 & 0xff;
+            int b2 = value >>> 16 & 0xff;
+            int b3 = value >>> 8 & 0xff;
+            int b4 = value >>> 0 & 0xff;
+            output.write(255);
+            output.write(b1);
+            output.write(b2);
+            output.write(b3);
+            output.write(b4);
+        }
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1CharStringFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java?rev=1744262&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java
 Tue May 17 13:32:40 2016
@@ -0,0 +1,213 @@
+/*
+ * 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.render.ps;
+
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.fontbox.cff.CFFType1Font;
+import org.apache.fontbox.cff.DataOutput;
+import org.apache.fontbox.cff.Type1FontUtil;
+
+/**
+ * This class represents a formatter for a given Type1 font.
+ * author Villu Ruusmann
+ * @version $Revision: 1.0 $
+ */
+public final class Type1FontFormatter {
+    private Map<Integer, Integer> gids;
+
+    public Type1FontFormatter(Map<Integer, Integer> gids) {
+        this.gids = gids;
+    }
+
+    /**
+     * Read and convert a given CFFFont.
+     * @param font the given CFFFont
+     * @return the Type1 font
+     * @throws IOException if an error occurs during reading the given font
+     */
+    public byte[] format(CFFType1Font font) throws IOException {
+        DataOutput output = new DataOutput();
+        printFont(font, output);
+        return output.getBytes();
+    }
+
+    private void printFont(CFFType1Font font, DataOutput output)
+            throws IOException {
+        output.println("%!FontType1-1.0 " + font.getName() + " "
+                + font.getTopDict().get("version"));
+
+        printFontDictionary(font, output);
+
+        for (int i = 0; i < 8; i++) {
+            StringBuilder sb = new StringBuilder();
+
+            for (int j = 0; j < 64; j++) {
+                sb.append("0");
+            }
+
+            output.println(sb.toString());
+        }
+
+        output.println("cleartomark");
+    }
+
+    private void printFontDictionary(CFFType1Font font, DataOutput output)
+            throws IOException {
+        output.println("10 dict begin");
+        output.println("/FontInfo 10 dict dup begin");
+        output.println("/version (" + font.getTopDict().get("version")
+                + ") readonly def");
+        output.println("/Notice (" + font.getTopDict().get("Notice")
+                + ") readonly def");
+        output.println("/FullName (" + font.getTopDict().get("FullName")
+                + ") readonly def");
+        output.println("/FamilyName (" + font.getTopDict().get("FamilyName")
+                + ") readonly def");
+        output.println("/Weight (" + font.getTopDict().get("Weight")
+                + ") readonly def");
+        output.println("/ItalicAngle " + font.getTopDict().get("ItalicAngle")
+                + " def");
+        output.println("/isFixedPitch " + font.getTopDict().get("isFixedPitch")
+                + " def");
+        output.println("/UnderlinePosition "
+                + font.getTopDict().get("UnderlinePosition") + " def");
+        output.println("/UnderlineThickness "
+                + font.getTopDict().get("UnderlineThickness") + " def");
+        output.println("end readonly def");
+        output.println("/FontName /" + font.getName() + " def");
+        output.println("/PaintType " + font.getTopDict().get("PaintType") + " 
def");
+        output.println("/FontType 1 def");
+        NumberFormat matrixFormat = new DecimalFormat("0.########", new 
DecimalFormatSymbols(Locale.US));
+        output.println("/FontMatrix "
+                + formatArray(font.getTopDict().get("FontMatrix"), 
matrixFormat, false)
+                + " readonly def");
+        output.println("/FontBBox "
+                + formatArray(font.getTopDict().get("FontBBox"), false)
+                + " readonly def");
+        output.println("/StrokeWidth " + font.getTopDict().get("StrokeWidth")
+                + " def");
+
+        output.println("/Encoding " + gids.size() + " array");
+        output.println("0 1 " + (gids.size() - 1) + " {1 index exch /.notdef 
put} for");
+
+        for (Map.Entry<Integer, Integer> gid : gids.entrySet()) {
+            String name = font.getCharset().getNameForGID(gid.getKey());
+            output.println("dup " + gid.getValue() + " /" + name + " put");
+        }
+        output.println("readonly def");
+
+        output.println("currentdict end");
+
+        DataOutput eexecOutput = new DataOutput();
+
+        printEexecFontDictionary(font, eexecOutput);
+
+        output.println("currentfile eexec");
+
+        byte[] eexecBytes = Type1FontUtil.eexecEncrypt(eexecOutput.getBytes());
+        output.write(eexecBytes);
+    }
+
+    private void printEexecFontDictionary(CFFType1Font font, DataOutput output)
+            throws IOException {
+        output.println("dup /Private 15 dict dup begin");
+        output.println("/RD {string currentfile exch readstring pop} 
executeonly def");
+        output.println("/ND {noaccess def} executeonly def");
+        output.println("/NP {noaccess put} executeonly def");
+        output.println("/BlueValues "
+                + formatArray(font.getPrivateDict().get("BlueValues"), true) + 
" ND");
+        output.println("/OtherBlues "
+                + formatArray(font.getPrivateDict().get("OtherBlues"), true) + 
" ND");
+        output.println("/BlueScale " + font.getPrivateDict().get("BlueScale") 
+ " def");
+        output.println("/BlueShift " + font.getPrivateDict().get("BlueShift") 
+ " def");
+        output.println("/BlueFuzz " + font.getPrivateDict().get("BlueFuzz") + 
" def");
+        output.println("/StdHW " + 
formatArray(font.getPrivateDict().get("StdHW"), true)
+                + " ND");
+        output.println("/StdVW " + 
formatArray(font.getPrivateDict().get("StdVW"), true)
+                + " ND");
+        output.println("/ForceBold " + font.getPrivateDict().get("ForceBold") 
+ " def");
+        output.println("/MinFeature {16 16} def");
+        output.println("/password 5839 def");
+
+        output.println("2 index /CharStrings " + gids.size() + " dict dup 
begin");
+        Type1CharStringFormatter formatter = new Type1CharStringFormatter();
+        for (int gid : gids.keySet()) {
+            String mapping = font.getCharset().getNameForGID(gid);
+            byte[] type1Bytes = 
formatter.format(font.getType1CharString(mapping).getType1Sequence());
+            byte[] charstringBytes = 
Type1FontUtil.charstringEncrypt(type1Bytes, 4);
+            output.print("/" + mapping + " " + charstringBytes.length + " RD 
");
+            output.write(charstringBytes);
+            output.print(" ND");
+            output.println();
+        }
+
+        output.println("end");
+        output.println("end");
+
+        output.println("readonly put");
+        output.println("noaccess put");
+        output.println("dup /FontName get exch definefont pop");
+        output.println("mark currentfile closefile");
+    }
+
+    private static String formatArray(Object object, boolean executable) {
+        return formatArray(object, null, executable);
+    }
+
+    private static String formatArray(Object object, NumberFormat format, 
boolean executable) {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append(executable ? "{" : "[");
+
+        if (object instanceof Collection) {
+            String sep = "";
+
+            Collection<?> elements = (Collection<?>) object;
+            for (Object element : elements) {
+                sb.append(sep).append(formatElement(element, format));
+
+                sep = " ";
+            }
+        } else if (object instanceof Number) {
+            sb.append(formatElement(object, format));
+        }
+
+        sb.append(executable ? "}" : "]");
+
+        return sb.toString();
+    }
+
+    private static String formatElement(Object object, NumberFormat format) {
+        if (format != null) {
+            if (object instanceof Double || object instanceof Float) {
+                Number number = (Number)object;
+                return format.format(number.doubleValue());
+            } else if (object instanceof Long || object instanceof Integer) {
+                Number number = (Number)object;
+                return format.format(number.longValue());
+            }
+        }
+        return String.valueOf(object);
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/ps/Type1FontFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
 Tue May 17 13:32:40 2016
@@ -49,7 +49,7 @@ public class DejaVuLGCSerifTestCase {
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
         FontUris fontUris = new FontUris(file.toURI(), null);
         font = FontLoader.loadFont(fontUris, "", true, EmbeddingMode.AUTO, 
EncodingMode.AUTO,
-                false, false, resolver);
+                false, false, resolver, false);
     }
 
     /**

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/EmbedFontInfoTestCase.java
 Tue May 17 13:32:40 2016
@@ -53,7 +53,7 @@ public class EmbedFontInfoTestCase {
         List<FontTriplet> triplets = new ArrayList<FontTriplet>();
         triplets.add(triplet);
         FontUris fontUris = new FontUris(embedURI, metricsURI);
-        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, triplets, 
subFontName, encMode, embedMode);
+        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, triplets, 
subFontName, encMode, embedMode, false);
     }
 
     @Test
@@ -83,8 +83,7 @@ public class EmbedFontInfoTestCase {
     @Test
     public void testQuirkyBoundaryCasesIsEmbedded() {
         FontUris fontUris = new FontUris(null, metricsURI);
-        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, 
sut.getFontTriplets(), subFontName, encMode,
-                embedMode);
+        sut = new EmbedFontInfo(fontUris, kerning, useAdvanced, 
sut.getFontTriplets(), subFontName);
         sut.setEmbedded(true);
         assertFalse(sut.isEmbedded());
 

Added: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java?rev=1744262&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java
 Tue May 17 13:32:40 2016
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.fonts.truetype;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.fontbox.type1.Type1Font;
+
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
+import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbeddingMode;
+import org.apache.fop.fonts.EncodingMode;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontUris;
+
+public class OTFToType1TestCase {
+
+    @Test
+    public void testFont() throws IOException {
+        Type1Font t1 = 
getFont("test/resources/fonts/otf/SourceSansProBold.otf");
+        Assert.assertEquals(t1.getFontName(), "SourceSansPro-Bold");
+        Assert.assertEquals(t1.getCharStringsDict().keySet().toString(), 
"[.notdef, d]");
+        t1 = getFont("test/resources/fonts/otf/AlexBrushRegular.otf");
+        Assert.assertEquals(t1.getFontName(), "AlexBrush-Regular");
+    }
+
+    private Type1Font getFont(String s) throws IOException {
+        InternalResourceResolver rr = 
ResourceResolverFactory.createDefaultInternalResourceResolver(
+                new File(".").toURI());
+        CustomFont realFont = FontLoader.loadFont(new FontUris(new 
File(s).toURI(), null), null, true,
+                EmbeddingMode.SUBSET, EncodingMode.AUTO, true, true, rr, true);
+        realFont.mapChar('d');
+        InputStream is = realFont.getInputStream();
+        return Type1Font.createWithPFB(is);
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java
 Tue May 17 13:32:40 2016
@@ -50,12 +50,12 @@ public class TTFFontLoaderTestCase {
         boolean useKerning = true;
 
         OFFontLoader fontLoader = new OFFontLoader(absoluteFilePath, fontName, 
embedded,
-                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, 
useComplexScriptFeatures, resourceResolver);
+                EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, 
useComplexScriptFeatures, resourceResolver, false);
         assertTrue(fontLoader.getFont().hasKerningInfo());
         useKerning = false;
 
         fontLoader = new OFFontLoader(absoluteFilePath, fontName, embedded, 
EmbeddingMode.AUTO,
-                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, 
resourceResolver);
+                EncodingMode.AUTO, useKerning, useComplexScriptFeatures, 
resourceResolver, false);
         assertFalse(fontLoader.getFont().hasKerningInfo());
     }
 }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/svg/font/FontInfoBuilder.java?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
 Tue May 17 13:32:40 2016
@@ -83,7 +83,7 @@ class FontInfoBuilder {
         URI baseURI = new File("test/resources/fonts/ttf").toURI();
         InternalResourceResolver resolver = 
ResourceResolverFactory.createDefaultInternalResourceResolver(baseURI);
         OFFontLoader fontLoader = new OFFontLoader(new URI(filename), null, 
true,
-                EmbeddingMode.AUTO, EncodingMode.AUTO, true, useAdvanced, 
resolver);
+                EmbeddingMode.AUTO, EncodingMode.AUTO, true, useAdvanced, 
resolver, false);
         FontMetrics font = fontLoader.getFont();
         registerFont(font, "F" + fontKey++, fontName);
         return this;

Modified: xmlgraphics/fop/trunk/fop/src/foschema/fop-configuration.xsd
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/src/foschema/fop-configuration.xsd?rev=1744262&r1=1744261&r2=1744262&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop/src/foschema/fop-configuration.xsd (original)
+++ xmlgraphics/fop/trunk/fop/src/foschema/fop-configuration.xsd Tue May 17 
13:32:40 2016
@@ -291,6 +291,7 @@
     <xsd:attribute name="embed-url-pfm" type="xsd:anyURI" use="optional"/>
     <xsd:attribute name="sub-font" type="xsd:string" use="optional"/>
     <xsd:attribute name="name" type="xsd:string" use="optional"/>
+    <xsd:attribute name="embed-as-type1" type="xsd:boolean" use="optional"/>
     <xsd:attribute name="embedding-mode" use="optional">
       <xsd:simpleType>
         <xsd:restriction base="xsd:string">



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to