pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1779729 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Date Sat, 21 Jan 2017 14:30:44 GMT
Author: tilman
Date: Sat Jan 21 14:30:44 2017
New Revision: 1779729

URL: http://svn.apache.org/viewvc?rev=1779729&view=rev
Log:
PDFBOX-3659: don't use the generic font for the encoding of standard 14 fonts to avoid trouble
if these are not installed

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=1779729&r1=1779728&r2=1779729&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
Jan 21 14:30:44 2017
@@ -401,22 +401,41 @@ public class PDType1Font extends PDSimpl
         }
 
         String name = getGlyphList().codePointToName(unicode);
-        if (!encoding.contains(name))
+        if (isStandard14())
         {
-            throw new IllegalArgumentException(
-                    String.format("U+%04X ('%s') is not available in this font %s (generic:
%s) encoding: %s",
-                                  unicode, name, getName(), genericFont.getName(), encoding.getEncodingName()));
+            // genericFont not needed, thus simplified code
+            // this is important on systems with no installed fonts
+            if (!encoding.contains(name))
+            {
+                throw new IllegalArgumentException(
+                        String.format("U+%04X ('%s') is not available in this font %s encoding:
%s",
+                                unicode, name, getName(), encoding.getEncodingName()));
+            }
+            if (name.equals(".notdef"))
+            {
+                throw new IllegalArgumentException(
+                        String.format("No glyph for U+%04X in font %s", unicode, getName()));
+            }
         }
-        
-        String nameInFont = getNameInFont(name);
-        Map<String, Integer> inverted = encoding.getNameToCodeMap();
-
-        if (nameInFont.equals(".notdef") || !genericFont.hasGlyph(nameInFont))
+        else
         {
-            throw new IllegalArgumentException(
-                    String.format("No glyph for U+%04X in font %s (generic: %s)", unicode,
getName(), genericFont.getName()));
+            if (!encoding.contains(name))
+            {
+                throw new IllegalArgumentException(
+                        String.format("U+%04X ('%s') is not available in this font %s (generic:
%s) encoding: %s",
+                                unicode, name, getName(), genericFont.getName(), encoding.getEncodingName()));
+            }
+
+            String nameInFont = getNameInFont(name);
+
+            if (nameInFont.equals(".notdef") || !genericFont.hasGlyph(nameInFont))
+            {
+                throw new IllegalArgumentException(
+                        String.format("No glyph for U+%04X in font %s (generic: %s)", unicode,
getName(), genericFont.getName()));
+            }
         }
 
+        Map<String, Integer> inverted = encoding.getNameToCodeMap();
         int code = inverted.get(name);
         bytes = new byte[] { (byte)code };
         codeToBytesMap.put(code, bytes);



Mime
View raw message