pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1687878 [2/2] - in /pdfbox/trunk: fontbox/src/main/java/org/apache/fontbox/ fontbox/src/main/java/org/apache/fontbox/cff/ fontbox/src/main/java/org/apache/fontbox/ttf/ fontbox/src/main/java/org/apache/fontbox/type1/ pdfbox/ pdfbox/src/main...
Date Sat, 27 Jun 2015 00:18:22 GMT
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java Sat Jun 27 00:18:21 2015
@@ -16,14 +16,17 @@
  */
 package org.apache.pdfbox.pdmodel.font;
 
+import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.cff.Type2CharString;
 import org.apache.fontbox.cmap.CMap;
 import org.apache.fontbox.ttf.CmapSubtable;
+import org.apache.fontbox.ttf.GlyphData;
 import org.apache.fontbox.ttf.OTFParser;
 import org.apache.fontbox.ttf.OpenTypeFont;
 import org.apache.fontbox.ttf.TTFParser;
@@ -133,17 +136,21 @@ public class PDCIDFontType2 extends PDCI
 
         if (ttfFont == null)
         {
-            // substitute
-            TrueTypeFont ttfSubstitute = ExternalFonts.getTrueTypeFont(getBaseFont());
-            if (ttfSubstitute != null)
+            // find font or substitute
+            CIDFontMapping mapping = FontMapper.getCIDFont(getFontDescriptor(), getCIDSystemInfo());
+
+            if (mapping.isCIDFont())
             {
-                ttfFont = ttfSubstitute;
+                ttfFont = mapping.getFont();
             }
             else
             {
-                // fallback
-                ttfFont = ExternalFonts.getTrueTypeFallbackFont(getFontDescriptor());
-                LOG.warn("Using fallback font '" + ttfFont + "' for '" + getBaseFont() + "'");
+                ttfFont = (TrueTypeFont)mapping.getTrueTypeFont();
+            }
+
+            if (mapping.isFallback())
+            {
+                LOG.warn("Using fallback for CID-keyed TrueType font " + getBaseFont());
             }
         }
         ttf = ttfFont;
@@ -387,10 +394,38 @@ public class PDCIDFontType2 extends PDCI
     }
 
     /**
-     * Returns the embedded or substituted TrueType font.
+     * Returns the embedded or substituted TrueType font. May be an OpenType font if the font is
+     * not embedded.
      */
     public TrueTypeFont getTrueTypeFont()
     {
         return ttf;
     }
+
+    @Override
+    public GeneralPath getPath(int code) throws IOException
+    {
+        if (ttf instanceof OpenTypeFont)
+        {
+            int cid = codeToCID(code);
+            Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid);
+            return charstring.getPath();
+        }
+        else
+        {
+            int gid = codeToGID(code);
+            GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+            if (glyph != null)
+            {
+                return glyph.getPath();
+            }
+            return new GeneralPath();
+        }
+    }
+
+    @Override
+    public boolean hasGlyph(int code) throws IOException
+    {
+        return codeToGID(code) != 0;
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDSystemInfo.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDSystemInfo.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDSystemInfo.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDSystemInfo.java Sat Jun 27 00:18:21 2015
@@ -30,6 +30,14 @@ import org.apache.pdfbox.pdmodel.common.
 public final class PDCIDSystemInfo implements COSObjectable
 {
     private final COSDictionary dictionary;
+
+    PDCIDSystemInfo(String registry, String ordering, int supplement)
+    {
+        dictionary = new COSDictionary();
+        dictionary.setString(COSName.REGISTRY, registry);
+        dictionary.setString(COSName.ORDERING, ordering);
+        dictionary.setInt(COSName.SUPPLEMENT, supplement);
+    }
     
     PDCIDSystemInfo(COSDictionary dictionary)
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java Sat Jun 27 00:18:21 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.pdmodel.font;
 
+import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -23,9 +24,11 @@ import java.util.Map;
 import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.FontBoxFont;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.font.encoding.BuiltInEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.DictionaryEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
 import org.apache.pdfbox.pdmodel.font.encoding.GlyphList;
@@ -122,16 +125,7 @@ public abstract class PDSimpleFont exten
                 {
                     symbolic = false;
                 }
-
-                if (builtIn == null && !encodingDict.containsKey(COSName.BASE_ENCODING) && symbolic)
-                {
-                    // TTF built-in encoding is handled by PDTrueTypeFont#codeToGID
-                    this.encoding = null;
-                }
-                else
-                {
-                    this.encoding = new DictionaryEncoding(encodingDict, !symbolic, builtIn);
-                }
+                this.encoding = new DictionaryEncoding(encodingDict, !symbolic, builtIn);
             }
         }
         else
@@ -139,8 +133,10 @@ public abstract class PDSimpleFont exten
             this.encoding = readEncodingFromFont();
         }
 
-        // TTFs may have null encoding, but if it's non-symbolic then we have Standard Encoding
-        if (this.encoding == null && getSymbolicFlag() != null && !getSymbolicFlag())
+        // TTFs have a built-in encoding, but if the font is non-symbolic then we instead
+        // have Standard Encoding
+        if (this.encoding instanceof BuiltInEncoding &&
+            getSymbolicFlag() != null &&!getSymbolicFlag())
         {
             this.encoding = StandardEncoding.INSTANCE;
         }
@@ -148,8 +144,9 @@ public abstract class PDSimpleFont exten
         // normalise the standard 14 name, e.g "Symbol,Italic" -> "Symbol"
         String standard14Name = Standard14Fonts.getMappedFontName(getName());
         
-        // TTFs may have null encoding, but if it's standard 14 then we know it's Standard Encoding
-        if (this.encoding == null && isStandard14() &&
+        // TTFs may have a built-in encoding, but if the font is standard 14 then we know
+        // it's Standard Encoding
+        if (this.encoding instanceof BuiltInEncoding && isStandard14() &&
                 !standard14Name.equals("Symbol") &&
                 !standard14Name.equals("ZapfDingbats"))
         {
@@ -425,6 +422,20 @@ public abstract class PDSimpleFont exten
         return super.isStandard14();
     }
 
+    /**
+     * Returns the path for the character with the given name. For some fonts, GIDs may be used
+     * instead of names when calling this method.
+     *
+     * @return glyph path
+     * @throws IOException if the path could not be read
+     */
+    public abstract GeneralPath getPath(String name) throws IOException;
+
+    /**
+     * Returns the embedded or system font used for rendering. This is never null.
+     */
+    public abstract FontBoxFont getFontBoxFont();
+
     @Override
     public void addToSubset(int codePoint)
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java Sat Jun 27 00:18:21 2015
@@ -16,28 +16,31 @@
  */
 package org.apache.pdfbox.pdmodel.font;
 
+import java.awt.geom.GeneralPath;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.FontBoxFont;
 import org.apache.fontbox.ttf.CmapSubtable;
 import org.apache.fontbox.ttf.CmapTable;
 import org.apache.fontbox.ttf.GlyphData;
+import org.apache.fontbox.ttf.PostScriptTable;
 import org.apache.fontbox.ttf.TTFParser;
 import org.apache.fontbox.ttf.TrueTypeFont;
 import org.apache.fontbox.util.BoundingBox;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.common.PDStream;
+import org.apache.pdfbox.pdmodel.font.encoding.BuiltInEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
 import org.apache.pdfbox.pdmodel.font.encoding.GlyphList;
 import org.apache.pdfbox.pdmodel.font.encoding.MacOSRomanEncoding;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.common.PDStream;
 import org.apache.pdfbox.pdmodel.font.encoding.Type1Encoding;
 
 /**
@@ -45,7 +48,7 @@ import org.apache.pdfbox.pdmodel.font.en
  * 
  * @author Ben Litchfield
  */
-public class PDTrueTypeFont extends PDSimpleFont
+public class PDTrueTypeFont extends PDSimpleFont implements PDVectorFont
 {
     private static final Log LOG = LogFactory.getLog(PDTrueTypeFont.class);
 
@@ -149,12 +152,11 @@ public class PDTrueTypeFont extends PDSi
         // substitute
         if (ttfFont == null)
         {
-            ttfFont = ExternalFonts.getTrueTypeFont(getBaseFont());
+            FontMapping<TrueTypeFont> mapping = FontMapper.getTrueTypeFont(getFontDescriptor());
+            ttfFont = mapping.getFont();
 
-            // fallback
-            if (ttfFont == null)
+            if (mapping.isFallback())
             {
-                ttfFont = ExternalFonts.getTrueTypeFallbackFont(getFontDescriptor());
                 LOG.warn("Using fallback font '" + ttfFont + "' for '" + getBaseFont() + "'");
             }
         }
@@ -180,9 +182,28 @@ public class PDTrueTypeFont extends PDSi
         }
         else
         {
-            // for symbolic fonts the (3, 0) (Windows, Symbol) cmap is the font's built-in encoding
-            // but this is handled by codeToGID
-            return null;
+            // synthesize an encoding, so that getEncoding() is always usable
+            PostScriptTable post = ttf.getPostScript();
+            Map<Integer, String> codeToName = new HashMap<Integer, String>();
+            for (int code = 0; code <= 256; code++)
+            {
+                int gid = codeToGID(code);
+                if (gid > 0)
+                {
+                    String name = null;
+                    if (post != null)
+                    {
+                        name = post.getName(gid);
+                    }
+                    if (name == null)
+                    {
+                        // GID pseudo-name
+                        name = Integer.toString(gid);
+                    }
+                    codeToName.put(code, name);
+                }
+            }
+            return new BuiltInEncoding(codeToName);
         }
     }
 
@@ -331,6 +352,73 @@ public class PDTrueTypeFont extends PDSi
         return isEmbedded;
     }
 
+    @Override
+    public GeneralPath getPath(int code) throws IOException
+    {
+        int gid = codeToGID(code);
+        GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+        
+        // some glyphs have no outlines (e.g. space, table, newline)
+        if (glyph == null)
+        {
+            return new GeneralPath();
+        }
+        else
+        {
+            return glyph.getPath();
+        }
+    }
+    
+    @Override
+    public GeneralPath getPath(String name) throws IOException
+    {
+        // handle glyph names and uniXXXX names
+        int gid = ttf.nameToGID(name);
+        if (gid == 0)
+        {
+            try
+            {
+                // handle GID pseudo-names
+                gid = Integer.parseInt(name);
+                if (gid > ttf.getNumberOfGlyphs())
+                {
+                    gid = 0;
+                }
+            }
+            catch (NumberFormatException e)
+            {
+                gid = 0;
+            }
+        }
+        // I'm assuming .notdef paths are not drawn, as it PDFBOX-2421
+        if (gid == 0)
+        {
+            return new GeneralPath();
+        }
+        
+        GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+        if (glyph != null)
+        {
+            return glyph.getPath();
+        }
+        else
+        {
+            return new GeneralPath();
+        }
+    }
+
+    @Override
+    public FontBoxFont getFontBoxFont()
+    {
+        return ttf;
+    }
+
+    @Override
+    public boolean hasGlyph(int code) throws IOException
+    {
+        return codeToGID(code) != 0;
+    }
+
     /**
      * Returns the GID for the given character code.
      *

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java Sat Jun 27 00:18:21 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.pdmodel.font;
 
+import java.awt.geom.GeneralPath;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -37,7 +38,7 @@ import org.apache.pdfbox.util.Vector;
  *
  * @author Ben Litchfield
  */
-public class PDType0Font extends PDFont
+public class PDType0Font extends PDFont implements PDVectorFont
 {
     private static final Log LOG = LogFactory.getLog(PDType0Font.class);
 
@@ -478,4 +479,16 @@ public class PDType0Font extends PDFont
         }
         return getClass().getSimpleName() + "/" + descendant + " " + getBaseFont();
     }
+
+    @Override
+    public GeneralPath getPath(int code) throws IOException
+    {
+        return descendantFont.getPath(code);
+    }
+
+    @Override
+    public boolean hasGlyph(int code) throws IOException
+    {
+        return descendantFont.hasGlyph(code);
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java Sat Jun 27 00:18:21 2015
@@ -28,13 +28,15 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.FontBoxFont;
+import org.apache.fontbox.EncodedFont;
 import org.apache.fontbox.cff.CFFParser;
 import org.apache.fontbox.cff.CFFType1Font;
-import org.apache.fontbox.ttf.Type1Equivalent;
 import org.apache.fontbox.util.BoundingBox;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
+import org.apache.pdfbox.pdmodel.font.encoding.StandardEncoding;
 import org.apache.pdfbox.pdmodel.font.encoding.Type1Encoding;
 import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.pdmodel.common.PDStream;
@@ -46,7 +48,7 @@ import org.apache.pdfbox.util.Matrix;
  * @author Villu Ruusmann
  * @author John Hewson
  */
-public class PDType1CFont extends PDSimpleFont implements PDType1Equivalent
+public class PDType1CFont extends PDSimpleFont
 {
     private static final Log LOG = LogFactory.getLog(PDType1CFont.class);
 
@@ -56,7 +58,7 @@ public class PDType1CFont extends PDSimp
     private final AffineTransform fontMatrixTransform;
 
     private final CFFType1Font cffFont; // embedded font
-    private final Type1Equivalent type1Equivalent; // embedded or system font for rendering
+    private final FontBoxFont genericFont; // embedded or system font for rendering
     private final boolean isEmbedded;
     private final boolean isDamaged;
 
@@ -107,20 +109,17 @@ public class PDType1CFont extends PDSimp
 
         if (cffFont != null)
         {
-            type1Equivalent = cffFont;
+            genericFont = cffFont;
             isEmbedded = true;
         }
         else
         {
-            Type1Equivalent t1Equiv = ExternalFonts.getType1EquivalentFont(getBaseFont());
-            if (t1Equiv != null)
+            FontMapping<FontBoxFont> mapping = FontMapper.getFontBoxFont(fd);
+            genericFont = mapping.getFont();
+            
+            if (mapping.isFallback())
             {
-                type1Equivalent = t1Equiv;
-            }
-            else
-            {
-                type1Equivalent = ExternalFonts.getType1FallbackFont(getFontDescriptor());
-                LOG.warn("Using fallback font " + type1Equivalent.getName() + " for " + getBaseFont());
+                LOG.warn("Using fallback font " + genericFont.getName() + " for " + getBaseFont());
             }
             isEmbedded = false;
         }
@@ -130,9 +129,9 @@ public class PDType1CFont extends PDSimp
     }
 
     @Override
-    public Type1Equivalent getType1Equivalent()
+    public FontBoxFont getFontBoxFont()
     {
-        return type1Equivalent;
+        return genericFont;
     }
 
     /**
@@ -153,7 +152,7 @@ public class PDType1CFont extends PDSimp
         }
         else
         {
-            return type1Equivalent.getPath(name);
+            return genericFont.getPath(name);
         }
     }
 
@@ -166,15 +165,15 @@ public class PDType1CFont extends PDSimp
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
-        return type1Equivalent.getFontBBox();
+        return genericFont.getFontBBox();
     }
 
-    @Override
+    //@Override
     public String codeToName(int code)
     {
         return getEncoding().getName(code);
     }
-
+    
     @Override
     protected Encoding readEncodingFromFont() throws IOException
     {
@@ -185,7 +184,16 @@ public class PDType1CFont extends PDSimp
         }
         else
         {
-            return Type1Encoding.fromFontBox(type1Equivalent.getEncoding());
+            // extract from Type1 font/substitute
+            if (genericFont instanceof EncodedFont)
+            {
+                return Type1Encoding.fromFontBox(((EncodedFont) genericFont).getEncoding());
+            }
+            else
+            {
+                // default (only happens with TTFs)
+                return StandardEncoding.INSTANCE;
+            }
         }
     }
 
@@ -226,7 +234,7 @@ public class PDType1CFont extends PDSimp
     public float getWidthFromFont(int code) throws IOException
     {
         String name = codeToName(code);
-        float width = type1Equivalent.getWidth(name);
+        float width = genericFont.getWidth(name);
 
         Point2D p = new Point2D.Float(width, 0);
         fontMatrixTransform.transform(p, p);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java Sat Jun 27 00:18:21 2015
@@ -25,7 +25,8 @@ import java.util.List;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fontbox.ttf.Type1Equivalent;
+import org.apache.fontbox.FontBoxFont;
+import org.apache.fontbox.EncodedFont;
 import org.apache.fontbox.type1.DamagedFontException;
 import org.apache.fontbox.type1.Type1Font;
 import org.apache.fontbox.util.BoundingBox;
@@ -45,7 +46,7 @@ import org.apache.pdfbox.util.Matrix;
  *
  * @author Ben Litchfield
  */
-public class PDType1Font extends PDSimpleFont implements PDType1Equivalent
+public class PDType1Font extends PDSimpleFont
 {
     private static final Log LOG = LogFactory.getLog(PDType1Font.class);
 
@@ -82,7 +83,7 @@ public class PDType1Font extends PDSimpl
     public static final PDType1Font ZAPF_DINGBATS = new PDType1Font("ZapfDingbats");
 
     private final Type1Font type1font; // embedded font
-    private final Type1Equivalent type1Equivalent; // embedded or system font for rendering
+    private final FontBoxFont genericFont; // embedded or system font for rendering
     private final boolean isEmbedded;
     private final boolean isDamaged;
     private Matrix fontMatrix;
@@ -103,18 +104,15 @@ public class PDType1Font extends PDSimpl
 
         // todo: could load the PFB font here if we wanted to support Standard 14 embedding
         type1font = null;
-        Type1Equivalent t1Equiv = ExternalFonts.getType1EquivalentFont(getBaseFont());
-        if (t1Equiv != null)
-        {
-            type1Equivalent = t1Equiv;
-        }
-        else
+        FontMapping<FontBoxFont> mapping = FontMapper.getFontBoxFont(getFontDescriptor());
+        genericFont = mapping.getFont();
+        
+        if (mapping.isFallback())
         {
-            type1Equivalent = ExternalFonts.getType1FallbackFont(getFontDescriptor());
             String fontName;
             try
             {
-                fontName = type1Equivalent.getName();
+                fontName = genericFont.getName();
             }
             catch (IOException e)
             {
@@ -139,7 +137,7 @@ public class PDType1Font extends PDSimpl
         PDType1FontEmbedder embedder = new PDType1FontEmbedder(doc, dict, afmIn, pfbIn);
         encoding = embedder.getFontEncoding();
         type1font = embedder.getType1Font();
-        type1Equivalent = embedder.getType1Font();
+        genericFont = embedder.getType1Font();
         isEmbedded = true;
         isDamaged = false;
     }
@@ -211,31 +209,21 @@ public class PDType1Font extends PDSimpl
         }
         isEmbedded = t1 != null;
         isDamaged = fontIsDamaged;
-
-        // try to find a suitable .pfb font to substitute
-        if (t1 == null)
-        {
-            t1 = ExternalFonts.getType1Font(getBaseFont());
-        }
-
         type1font = t1;
 
-        // find a type 1-equivalent font to use for rendering, could even be a .ttf
+        // find a generic font to use for rendering, could be a .pfb, but might be a .ttf
         if (type1font != null)
         {
-            type1Equivalent = type1font;
+            genericFont = type1font;
         }
         else
         {
-            Type1Equivalent t1Equiv = ExternalFonts.getType1EquivalentFont(getBaseFont());
-            if (t1Equiv != null)
-            {
-                type1Equivalent = t1Equiv;
-            }
-            else
+            FontMapping<FontBoxFont> mapping = FontMapper.getFontBoxFont(fd);
+            genericFont = mapping.getFont();
+            
+            if (mapping.isFallback())
             {
-                type1Equivalent = ExternalFonts.getType1FallbackFont(getFontDescriptor());
-                LOG.warn("Using fallback font " + type1Equivalent.getName() + " for " + getBaseFont());
+                LOG.warn("Using fallback font " + genericFont.getName() + " for " + getBaseFont());
             }
         }
         readEncoding();
@@ -299,7 +287,7 @@ public class PDType1Font extends PDSimpl
         }
         else
         {
-            return (float)type1Equivalent.getPath(name).getBounds().getHeight();
+            return (float) genericFont.getPath(name).getBounds().getHeight();
         }
     }
 
@@ -315,7 +303,7 @@ public class PDType1Font extends PDSimpl
         String nameInFont = getNameInFont(name);
         Map<String, Integer> inverted = getInvertedEncoding();
 
-        if (nameInFont.equals(".notdef") || !type1Equivalent.hasGlyph(nameInFont))
+        if (nameInFont.equals(".notdef") || !genericFont.hasGlyph(nameInFont))
         {
             throw new IllegalArgumentException(
                     String.format("No glyph for U+%04X in font %s", unicode, getName()));
@@ -336,7 +324,7 @@ public class PDType1Font extends PDSimpl
             return 250;
         }
 
-        return type1Equivalent.getWidth(name);
+        return genericFont.getWidth(name);
     }
 
     @Override
@@ -375,9 +363,9 @@ public class PDType1Font extends PDSimpl
         else
         {
             // extract from Type1 font/substitute
-            if (type1Equivalent.getEncoding() != null)
+            if (genericFont instanceof EncodedFont)
             {
-                return Type1Encoding.fromFontBox(type1Equivalent.getEncoding());
+                return Type1Encoding.fromFontBox(((EncodedFont) genericFont).getEncoding());
             }
             else
             {
@@ -396,9 +384,9 @@ public class PDType1Font extends PDSimpl
     }
 
     @Override
-    public Type1Equivalent getType1Equivalent()
+    public FontBoxFont getFontBoxFont()
     {
-        return type1Equivalent;
+        return genericFont;
     }
 
     @Override
@@ -410,10 +398,10 @@ public class PDType1Font extends PDSimpl
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
-        return type1Equivalent.getFontBBox();
+        return genericFont.getFontBBox();
     }
 
-    @Override
+    //@Override
     public String codeToName(int code) throws IOException
     {
         String name = getEncoding().getName(code);
@@ -426,7 +414,7 @@ public class PDType1Font extends PDSimpl
      */
     private String getNameInFont(String name) throws IOException
     {
-        if (isEmbedded() || type1Equivalent.hasGlyph(name))
+        if (isEmbedded() || genericFont.hasGlyph(name))
         {
             return name;
         }
@@ -434,7 +422,7 @@ public class PDType1Font extends PDSimpl
         {
             // try alternative name
             String altName = ALT_NAMES.get(name);
-            if (altName != null && !name.equals(".notdef") && type1Equivalent.hasGlyph(altName))
+            if (altName != null && !name.equals(".notdef") && genericFont.hasGlyph(altName))
             {
                 return altName;
             }
@@ -445,7 +433,7 @@ public class PDType1Font extends PDSimpl
                 if (unicodes != null && unicodes.length() == 1)
                 {
                     String uniName = String.format("uni%04X", unicodes.codePointAt(0));
-                    if (type1Equivalent.hasGlyph(uniName))
+                    if (genericFont.hasGlyph(uniName))
                     {
                         return uniName;
                     }
@@ -466,7 +454,7 @@ public class PDType1Font extends PDSimpl
         }
         else
         {
-            return type1Equivalent.getPath(name);
+            return genericFont.getPath(name);
         }
     }
 
@@ -477,25 +465,27 @@ public class PDType1Font extends PDSimpl
         {
             // PDF specified that Type 1 fonts use a 1000upem matrix, but some fonts specify
             // their own custom matrix anyway, for example PDFBOX-2298
-            if (type1font != null)
+            List<Number> numbers = null;
+            try
             {
-                List<Number> numbers = type1font.getFontMatrix();
-                if (numbers != null && numbers.size() == 6)
-                {
-                    fontMatrix = new Matrix(
-                            numbers.get(0).floatValue(), numbers.get(1).floatValue(),
-                            numbers.get(2).floatValue(), numbers.get(3).floatValue(),
-                            numbers.get(4).floatValue(), numbers.get(5).floatValue());
-                }
-                else
-                {
-                    return super.getFontMatrix();
-                }
+                numbers = genericFont.getFontMatrix();
             }
-            else
+            catch (IOException e)
             {
                 fontMatrix = DEFAULT_FONT_MATRIX;
             }
+            
+            if (numbers != null && numbers.size() == 6)
+            {
+                fontMatrix = new Matrix(
+                        numbers.get(0).floatValue(), numbers.get(1).floatValue(),
+                        numbers.get(2).floatValue(), numbers.get(3).floatValue(),
+                        numbers.get(4).floatValue(), numbers.get(5).floatValue());
+            }
+            else
+            {
+                return super.getFontMatrix();
+            }
         }
         return fontMatrix;
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java Sat Jun 27 00:18:21 2015
@@ -16,10 +16,12 @@
  */
 package org.apache.pdfbox.pdmodel.font;
 
+import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.io.InputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.FontBoxFont;
 import org.apache.fontbox.util.BoundingBox;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
@@ -85,6 +87,20 @@ public class PDType3Font extends PDSimpl
     }
 
     @Override
+    public GeneralPath getPath(String name) throws IOException
+    {
+        // Type 3 fonts do not use vector paths
+        throw new UnsupportedOperationException("not supported for Type 3 fonts");
+    }
+
+    @Override
+    public FontBoxFont getFontBoxFont()
+    {
+        // Type 3 fonts do not use FontBox fonts
+        throw new UnsupportedOperationException("not supported for Type 3 fonts");
+    }
+
+    @Override
     public Vector getDisplacement(int code) throws IOException
     {
         return getFontMatrix().transform(new Vector(getWidth(code), 0));

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDVectorFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDVectorFont.java?rev=1687878&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDVectorFont.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDVectorFont.java Sat Jun 27 00:18:21 2015
@@ -0,0 +1,44 @@
+/*
+ * 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.pdfbox.pdmodel.font;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+
+/**
+ * A vector outline font, e.g. not Type 3.
+ *
+ * @author John Hewson
+ */
+public interface PDVectorFont
+{
+    /**
+     * Returns the glyph path for the given character code.
+     *
+     * @param code character code
+     * @throws java.io.IOException if the font could not be read
+     */
+    GeneralPath getPath(int code) throws IOException;
+    
+    /**
+     * Returns true if this font contains a glyph for the given character code.
+     *
+     * @param code character code
+     */
+    boolean hasGlyph(int code) throws IOException;
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDVectorFont.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/BuiltInEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/BuiltInEncoding.java?rev=1687878&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/BuiltInEncoding.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/BuiltInEncoding.java Sat Jun 27 00:18:21 2015
@@ -0,0 +1,48 @@
+/*
+ * 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.pdfbox.pdmodel.font.encoding;
+
+import java.util.Map;
+import org.apache.pdfbox.cos.COSBase;
+
+/**
+ * A font's built-in encoding.
+ *
+ * @author John Hewson
+ */
+public class BuiltInEncoding extends Encoding
+{
+    /**
+     * Constructor.
+     *
+     * @param codeToName the given code to name mapping
+     */
+    public BuiltInEncoding(Map<Integer, String> codeToName)
+    {
+        for (Map.Entry<Integer, String> entry : codeToName.entrySet())
+        {
+            add(entry.getKey(), entry.getValue());
+        }
+    }
+    
+    @Override
+    public COSBase getCOSObject()
+    {
+        throw new UnsupportedOperationException("Built-in encodings cannot be serialized");
+    }
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/BuiltInEncoding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/CIDType0Glyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/CIDType0Glyph2D.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/CIDType0Glyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/CIDType0Glyph2D.java Sat Jun 27 00:18:21 2015
@@ -20,10 +20,8 @@ import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fontbox.cff.Type2CharString;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType0;
 
 /**
@@ -53,7 +51,6 @@ final class CIDType0Glyph2D implements G
     @Override
     public GeneralPath getPathForCharacterCode(int code)
     {
-        int cid = font.getParent().codeToCID(code);
         if (cache.containsKey(code))
         {
             return cache.get(code);
@@ -61,15 +58,14 @@ final class CIDType0Glyph2D implements G
 
         try
         {
-            Type2CharString charString = font.getType2CharString(cid);
-
-            if (charString.getGID() == 0)
+            if (!font.hasGlyph(code))
             {
+                int cid = font.getParent().codeToCID(code);
                 String cidHex = String.format("%04x", cid);
                 LOG.warn("No glyph for " + code + " (CID " + cidHex + ") in font " + fontName);
             }
 
-            GeneralPath path = charString.getPath();
+            GeneralPath path = font.getPath(code);
             cache.put(code, path);
             return path;
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/TTFGlyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/TTFGlyph2D.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/TTFGlyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/TTFGlyph2D.java Sat Jun 27 00:18:21 2015
@@ -23,19 +23,18 @@ import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fontbox.ttf.GlyphData;
 import org.apache.fontbox.ttf.HeaderTable;
 import org.apache.fontbox.ttf.TrueTypeFont;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType2;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
 import org.apache.pdfbox.pdmodel.font.PDType0Font;
+import org.apache.pdfbox.pdmodel.font.PDVectorFont;
 
 /**
- * This class provides a glyph to GeneralPath conversion for TrueType fonts.
+ * This class provides a glyph to GeneralPath conversion for TrueType and OpenType fonts.
  */
 final class TTFGlyph2D implements Glyph2D
 {
@@ -43,6 +42,7 @@ final class TTFGlyph2D implements Glyph2
 
     private final PDFont font;
     private final TrueTypeFont ttf;
+    private PDVectorFont vectorFont;
     private float scale = 1.0f;
     private boolean hasScaling;
     private final Map<Integer, GeneralPath> glyphs = new HashMap<Integer, GeneralPath>();
@@ -56,6 +56,7 @@ final class TTFGlyph2D implements Glyph2
     public TTFGlyph2D(PDTrueTypeFont ttfFont) throws IOException
     {
         this(ttfFont.getTrueTypeFont(), ttfFont, false);
+        vectorFont = ttfFont;
     }
 
     /**
@@ -66,10 +67,10 @@ final class TTFGlyph2D implements Glyph2
     public TTFGlyph2D(PDType0Font type0Font) throws IOException
     {
         this(((PDCIDFontType2)type0Font.getDescendantFont()).getTrueTypeFont(), type0Font, true);
+        vectorFont = type0Font;
     }
 
-    public TTFGlyph2D(TrueTypeFont ttf, PDFont font, boolean isCIDFont)
-            throws IOException
+    private TTFGlyph2D(TrueTypeFont ttf, PDFont font, boolean isCIDFont) throws IOException
     {
         this.font = font;
         this.ttf = ttf;
@@ -136,8 +137,8 @@ final class TTFGlyph2D implements Glyph2
                     LOG.warn("No glyph for " + code + " in font " + font.getName());
                 }
             }
-
-            GlyphData glyph = ttf.getGlyph().getGlyph(gid);
+            
+            GeneralPath glyph = vectorFont.getPath(code);
 
             // Acrobat only draws GID 0 for embedded or "Standard 14" fonts, see PDFBOX-2372
             if (gid == 0 && !font.isEmbedded() && !font.isStandard14())
@@ -153,7 +154,7 @@ final class TTFGlyph2D implements Glyph2
             }
             else
             {
-                glyphPath = glyph.getPath();
+                glyphPath = glyph;
                 if (hasScaling)
                 {
                     AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java Sat Jun 27 00:18:21 2015
@@ -20,10 +20,9 @@ import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.pdmodel.font.PDType1Equivalent;
+import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
 
 /**
  * Glyph to GeneralPath conversion for Type 1 PFB and CFF, and TrueType fonts with a 'post' table.
@@ -33,14 +32,14 @@ final class Type1Glyph2D implements Glyp
     private static final Log LOG = LogFactory.getLog(Type1Glyph2D.class);
 
     private final Map<Integer, GeneralPath> cache = new HashMap<Integer, GeneralPath>();
-    private final PDType1Equivalent font;
+    private final PDSimpleFont font;
 
     /**
      * Constructor.
      *
      * @param font PDF Type1 font.
      */
-    Type1Glyph2D(PDType1Equivalent font)
+    Type1Glyph2D(PDSimpleFont font)
     {
         this.font = font;
     }
@@ -57,7 +56,7 @@ final class Type1Glyph2D implements Glyp
         // fetch
         try
         {
-            String name = font.codeToName(code);
+            String name = font.getEncoding().getName(code);
             if (name.equals(".notdef"))
             {
                 LOG.warn("No glyph for " + code + " (" + name + ") in font " + font.getName());

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type1FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type1FontValidator.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type1FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type1FontValidator.java Sat Jun 27 00:18:21 2015
@@ -21,35 +21,35 @@
 
 package org.apache.pdfbox.preflight.font;
 
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_ENCODING;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_MAC;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_MAC_EXP;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_PDFDOC;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_STD;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_WIN;
-
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
-import org.apache.pdfbox.pdmodel.font.PDType1Equivalent;
 import org.apache.pdfbox.preflight.PreflightContext;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.font.container.Type1Container;
 import org.apache.pdfbox.preflight.font.descriptor.Type1DescriptorHelper;
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
+
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_ENCODING;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_MAC;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_MAC_EXP;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_PDFDOC;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_STD;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_ENCODING_WIN;
+
 public class Type1FontValidator extends SimpleFontValidator<Type1Container>
 {
     public Type1FontValidator(PreflightContext context, PDSimpleFont font)
     {
-        super(context, font, font.getCOSObject(), new Type1Container((PDType1Equivalent)font));
+        super(context, font, font.getCOSObject(), new Type1Container((PDSimpleFont)font));
     }
 
     @Override
     protected void createFontDescriptorHelper()
     {
-        this.descriptorHelper = new Type1DescriptorHelper(context, (PDType1Equivalent)font, fontContainer);
+        this.descriptorHelper = new Type1DescriptorHelper(context, (PDSimpleFont)font, fontContainer);
     }
 
     @Override

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java Sat Jun 27 00:18:21 2015
@@ -22,11 +22,11 @@
 package org.apache.pdfbox.preflight.font.container;
 
 import java.io.IOException;
-import org.apache.pdfbox.pdmodel.font.PDType1Equivalent;
+import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
 
-public class Type1Container extends FontContainer<PDType1Equivalent>
+public class Type1Container extends FontContainer<PDSimpleFont>
 {
-    public Type1Container(PDType1Equivalent font)
+    public Type1Container(PDSimpleFont font)
     {
         super(font);
     }
@@ -36,8 +36,8 @@ public class Type1Container extends Font
     {
         if (font.isEmbedded())
         {
-            String name = font.codeToName(code);
-            return font.getType1Equivalent().hasGlyph(name);
+            String name = font.getEncoding().getName(code);
+            return font.getFontBoxFont().hasGlyph(name);
         }
         return false;
     }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java?rev=1687878&r1=1687877&r2=1687878&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java Sat Jun 27 00:18:21 2015
@@ -21,25 +21,26 @@
 
 package org.apache.pdfbox.preflight.font.descriptor;
 
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_CHARSET_MISSING_FOR_SUBSET;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_FONT_FILEX_INVALID;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_KEY_LENGTH2;
-import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_KEY_LENGTH3;
-
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdmodel.common.PDStream;
 import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
-import org.apache.pdfbox.pdmodel.font.PDType1Equivalent;
+import org.apache.pdfbox.pdmodel.font.PDSimpleFont;
 import org.apache.pdfbox.preflight.PreflightContext;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.font.container.Type1Container;
 
+
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_CHARSET_MISSING_FOR_SUBSET;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_FONT_FILEX_INVALID;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_KEY_LENGTH2;
+import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_KEY_LENGTH3;
+
 public class Type1DescriptorHelper extends FontDescriptorHelper<Type1Container>
 {
-    public Type1DescriptorHelper(PreflightContext context, PDType1Equivalent font, Type1Container fontContainer)
+    public Type1DescriptorHelper(PreflightContext context, PDSimpleFont font, Type1Container fontContainer)
     {
         super(context, font, fontContainer);
     }



Mime
View raw message