pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1620184 - in /pdfbox/branches/no-awt: fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Date Sun, 24 Aug 2014 20:11:06 GMT
Author: jahewson
Date: Sun Aug 24 20:11:05 2014
New Revision: 1620184

URL: http://svn.apache.org/r1620184
Log:
PDFBOX-2262: Fix widths for TrueType instances of Type1Equivalent fonts

Modified:
    pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java

Modified: pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1620184&r1=1620183&r2=1620184&view=diff
==============================================================================
--- pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
(original)
+++ pdfbox/branches/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
Sun Aug 24 20:11:05 2014
@@ -27,7 +27,6 @@ import java.io.InputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fontbox.encoding.Encoding;
-import org.apache.fontbox.encoding.StandardEncoding;
 
 /**
  * A TrueType font file.
@@ -449,7 +448,13 @@ public class TrueTypeFont implements Typ
         readPostScriptNames();
 
         Integer gid = postScriptNames.get(name);
-        return getAdvanceWidth(gid);
+        int width = getAdvanceWidth(gid);
+        int unitsPerEM = getUnitsPerEm();
+        if (unitsPerEM != 1000)
+        {
+            width *= 1000f / unitsPerEM;
+        }
+        return width;
     }
 
     @Override
@@ -465,9 +470,7 @@ public class TrueTypeFont implements Typ
     @Override
     public Encoding getEncoding()
     {
-        // todo: what to use? There isn't a built-in encoding really, could use the MacRoman
cmap?
-        log.warn("Using StandardEncoding for Type 1-equivalent TTF");
-        return new StandardEncoding();
+        return null;
     }
 
     @Override

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1620184&r1=1620183&r2=1620184&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
(original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Sun Aug 24 20:11:05 2014
@@ -33,6 +33,7 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.encoding.Encoding;
+import org.apache.pdfbox.encoding.StandardEncoding;
 import org.apache.pdfbox.encoding.Type1Encoding;
 import org.apache.pdfbox.encoding.WinAnsiEncoding;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -327,7 +328,15 @@ public class PDType1Font extends PDSimpl
         else
         {
             // extract from Type1 font/substitute
-            return Type1Encoding.fromFontBox(type1Equivalent.getEncoding());
+            if (type1Equivalent.getEncoding() != null)
+            {
+                return Type1Encoding.fromFontBox(type1Equivalent.getEncoding());
+            }
+            else
+            {
+                // default (only happens with TTFs)
+                return StandardEncoding.INSTANCE;
+            }
         }
     }
 



Mime
View raw message