You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/11/13 19:26:45 UTC
svn commit: r1895001 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Author: tilman
Date: Sat Nov 13 19:26:44 2021
New Revision: 1895001
URL: http://svn.apache.org/viewvc?rev=1895001&view=rev
Log:
PDFBOX-5321: avoid quiet failure when encoding is missing; fix messages
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=1895001&r1=1895000&r2=1895001&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 Nov 13 19:26:44 2021
@@ -405,13 +405,13 @@ public class PDType1Font extends PDSimpl
if (!encoding.contains(name))
{
throw new IllegalArgumentException(
- String.format("U+%04X ('%s') is not available in this font %s encoding: %s",
+ String.format("U+%04X ('%s') is not available in the font %s, encoding: %s",
unicode, name, getName(), encoding.getEncodingName()));
}
if (".notdef".equals(name))
{
throw new IllegalArgumentException(
- String.format("No glyph for U+%04X in font %s", unicode, getName()));
+ String.format("No glyph for U+%04X in the font %s", unicode, getName()));
}
}
else
@@ -419,7 +419,7 @@ public class PDType1Font extends PDSimpl
if (!encoding.contains(name))
{
throw new IllegalArgumentException(
- String.format("U+%04X ('%s') is not available in this font %s (generic: %s) encoding: %s",
+ String.format("U+%04X ('%s') is not available in the font %s (generic: %s), encoding: %s",
unicode, name, getName(), genericFont.getName(), encoding.getEncodingName()));
}
@@ -428,12 +428,18 @@ public class PDType1Font extends PDSimpl
if (".notdef".equals(nameInFont) || !genericFont.hasGlyph(nameInFont))
{
throw new IllegalArgumentException(
- String.format("No glyph for U+%04X in font %s (generic: %s)", unicode, getName(), genericFont.getName()));
+ String.format("No glyph for U+%04X in the font %s (generic: %s)", unicode, getName(), genericFont.getName()));
}
}
Map<String, Integer> inverted = encoding.getNameToCodeMap();
int code = inverted.get(name);
+ if (code < 0)
+ {
+ 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()));
+ }
bytes = new byte[] { (byte)code };
codeToBytesMap.put(unicode, bytes);
return bytes;