pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leleu...@apache.org
Subject svn commit: r1370007 - in /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font: descriptor/Type1DescriptorHelper.java util/FontMetaDataValidation.java util/GlyphDescription.java util/Type1.java util/Type1Parser.java
Date Mon, 06 Aug 2012 20:50:35 GMT
Author: leleueri
Date: Mon Aug  6 20:50:34 2012
New Revision: 1370007

URL: http://svn.apache.org/viewvc?rev=1370007&view=rev
Log:
[https://issues.apache.org/jira/browse/PDFBOX-1371] Fix for Type1 validation

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/GlyphDescription.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java

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=1370007&r1=1370006&r2=1370007&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
Mon Aug  6 20:50:34 2012
@@ -89,7 +89,7 @@ public class Type1DescriptorHelper exten
 
 			boolean hasLength1 = stream.getInt(COSName.LENGTH1) > 0;
 			boolean hasLength2 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH2)) >
0;
-			boolean hasLength3 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH3)) >
0;
+			boolean hasLength3 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH3)) >=
0;
 			if (!(hasLength1 && hasLength2 && hasLength3)) {
 				this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile
is invalid"));
 				return null;
@@ -126,10 +126,10 @@ public class Type1DescriptorHelper exten
 			IOUtils.closeQuietly(bis);
 
 			// Parse the Type1 Font program in order to extract Glyph Width
-			bis = new ByteArrayInputStream(fontFile.getByteArray());
 			COSStream streamObj = fontFile.getStream();
 			int length1 = streamObj.getInt(COSName.LENGTH1);
 			int length2 = streamObj.getInt(COSName.LENGTH2);
+			bis = new ByteArrayInputStream(fontFile.getByteArray());
 			Type1Parser parserForMetrics = Type1Parser.createParserWithEncodingObject(bis, length1,
length2, font.getFontEncoding());
 			Type1 parsedData = parserForMetrics.parse();
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java?rev=1370007&r1=1370006&r2=1370007&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/FontMetaDataValidation.java
Mon Aug  6 20:50:34 2012
@@ -25,7 +25,6 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
 import org.apache.padaf.xmpbox.schema.XMPRightsManagementSchema;

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/GlyphDescription.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/GlyphDescription.java?rev=1370007&r1=1370006&r2=1370007&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/GlyphDescription.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/GlyphDescription.java
Mon Aug  6 20:50:34 2012
@@ -49,7 +49,16 @@ public class GlyphDescription {
 			if (obj instanceof CharStringCommand) {
 				CharStringCommand csCmd = (CharStringCommand) obj;
 				if ("hsbw".equals(CharStringCommand.TYPE1_VOCABULARY.get(csCmd.getKey()))) {
-					return (Integer) operations.get(i - 1);
+					// Numbers with absolute values greater than 32,000 must be followed
+					// by a div operator such that the result of the div is less than 32,000.
+					if (operations.get(i - 1) instanceof CharStringCommand) {
+						CharStringCommand div = (CharStringCommand) operations.get(i - 1);
+						if ("div".equals(CharStringCommand.TYPE1_VOCABULARY.get(div.getKey()))) {
+							return ((Integer)operations.get(i - 3) / (Integer)operations.get(i - 2));
+						}
+					} else {
+						return (Integer) operations.get(i - 1);
+					}
 				}
 			}
 		}

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java?rev=1370007&r1=1370006&r2=1370007&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1.java
Mon Aug  6 20:50:34 2012
@@ -26,7 +26,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
-
 import org.apache.pdfbox.encoding.Encoding;
 import org.apache.pdfbox.preflight.PreflightConstants;
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java?rev=1370007&r1=1370006&r2=1370007&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/util/Type1Parser.java
Mon Aug  6 20:50:34 2012
@@ -565,7 +565,7 @@ public final class Type1Parser {
 
 	private boolean isDupKeyWord(byte[] token) throws IOException {
 		String word = new String(token, TOKEN_ENCODING);
-		return "/Encoding".equals(word);
+		return "dup".equals(word);
 	}
 
 	private boolean isStartOfEExecReached() {



Mime
View raw message