pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1668977 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Date Tue, 24 Mar 2015 20:07:10 GMT
Author: jahewson
Date: Tue Mar 24 20:07:10 2015
New Revision: 1668977

URL: http://svn.apache.org/r1668977
Log:
PDFBOX-2714: Map glyph names when encoding a Type 1 font backed by a TTF

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java

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=1668977&r1=1668976&r2=1668977&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 Tue
Mar 24 20:07:10 2015
@@ -296,9 +296,10 @@ public class PDType1Font extends PDSimpl
         }
 
         String name = getGlyphList().codePointToName(unicode);
+        String nameInFont = getNameInFont(name);
         Map<String, Integer> inverted = getInvertedEncoding();
 
-        if (name.equals(".notdef") || !type1Equivalent.hasGlyph(name))
+        if (nameInFont.equals(".notdef") || !type1Equivalent.hasGlyph(nameInFont))
         {
             throw new IllegalArgumentException(
                     String.format("No glyph for U+%04X in font %s", unicode, getName()));
@@ -423,6 +424,15 @@ public class PDType1Font extends PDSimpl
     public String codeToName(int code) throws IOException
     {
         String name = getEncoding().getName(code);
+        return getNameInFont(name);
+    }
+
+    /**
+     * Maps a PostScript glyph name to the name in the underlying font, for example when
+     * using a TTF font we might map "W" to "uni0057".
+     */
+    private String getNameInFont(String name) throws IOException
+    {
         if (isEmbedded() || type1Equivalent.hasGlyph(name))
         {
             return name;



Mime
View raw message