You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2013/06/02 23:35:03 UTC
svn commit: r1488796 - in
/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container:
FontContainer.java Type0Container.java Type1Container.java
Author: leleueri
Date: Sun Jun 2 21:35:03 2013
New Revision: 1488796
URL: http://svn.apache.org/r1488796
Log:
reverting rev. 1488722
Modified:
pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java
pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java
pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java
Modified: pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java?rev=1488796&r1=1488795&r2=1488796&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java (original)
+++ pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/FontContainer.java Sun Jun 2 21:35:03 2013
@@ -142,9 +142,8 @@ public abstract class FontContainer
*
* @param cid
* @return The Glyph width in 'em' unit.
- * @throws GlyphException
*/
- protected abstract float getFontProgramWidth(int cid) throws GlyphException;
+ protected abstract float getFontProgramWidth(int cid);
/**
* Test if both width are consistent. At the end of this method, the CID is marked as valid or invalid.
Modified: pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java?rev=1488796&r1=1488795&r2=1488796&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java (original)
+++ pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java Sun Jun 2 21:35:03 2013
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
-import org.apache.pdfbox.preflight.font.util.GlyphException;
public class Type0Container extends FontContainer
{
@@ -38,7 +37,7 @@ public class Type0Container extends Font
}
@Override
- protected float getFontProgramWidth(int cid) throws GlyphException
+ protected float getFontProgramWidth(int cid)
{
float width = 0;
if (this.delegateFontContainer != null)
Modified: pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java?rev=1488796&r1=1488795&r2=1488796&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java (original)
+++ pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type1Container.java Sun Jun 2 21:35:03 2013
@@ -27,7 +27,6 @@ import java.util.List;
import org.apache.fontbox.cff.CFFFont;
import org.apache.fontbox.cff.CFFFont.Mapping;
import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.preflight.PreflightConstants;
import org.apache.pdfbox.preflight.font.util.GlyphException;
import org.apache.pdfbox.preflight.font.util.Type1;
@@ -53,7 +52,7 @@ public class Type1Container extends Font
}
@Override
- protected float getFontProgramWidth(int cid) throws GlyphException
+ protected float getFontProgramWidth(int cid)
{
float widthResult = -1;
try
@@ -68,72 +67,41 @@ public class Type1Container extends Font
else
{
/*
- * Retrieves the SID with the Character Name in the encoding map Need
- * more PDF with a Type1C subfont to valid this implementation
- */
- String name = null;
- if (this.font.getFontEncoding() != null) {
- name = this.font.getFontEncoding().getName(cid);
- }
-
- int SID = -1;
-
- /* For each CFF, try to found the SID that correspond to the CID.
- * Look up by name if the encoding entry is present in the PDFont object
- * otherwise use the internal encoding map of the font.
+ * Retrieves the SID with the Character Name in the encoding map Need more PDF with a Type1C subfont to
+ * valid this implementation
*/
+ String name = this.font.getFontEncoding().getName(cid);
for (CFFFont cff : lCFonts)
{
- if (name == null) {
- SID = cff.getEncoding().getSID(cid);
- } else {
- SID = getSIDByCharacterName(name, cff);
- }
-
- if (SID > 0) {
- widthResult = cff.getWidth(SID);
- if (widthResult != defaultGlyphWidth)
+ int SID = cff.getEncoding().getSID(cid);
+ for (Mapping m : cff.getMappings())
+ {
+ if (m.getName().equals(name))
{
+ SID = m.getSID();
break;
}
}
- }
-
- if (SID < 0)
- {
- throw new GlyphException(PreflightConstants.ERROR_FONTS_GLYPH_MISSING, cid, "Unknown character CID(" + cid+")");
+ widthResult = cff.getWidth(SID);
+ if (widthResult != defaultGlyphWidth)
+ {
+ break;
+ }
}
}
}
+ catch (GlyphException e)
+ {
+ widthResult = -1;
+ }
catch (IOException e)
{
- throw new GlyphException(PreflightConstants.ERROR_FONTS_GLYPH, cid, "Unexpected error during the width validtion for the character CID(" + cid+") : " + e.getMessage());
+ widthResult = -1; // TODO validation exception
}
return widthResult;
}
- /**
- * Return the SID of the given character name.
- *
- * @param name the character name looked up
- * @param cff Compact Font Format that represents a sub set of the Type1C Font.
- * @return -1 if the name is missing from the Font encoding map, the SID of the character if it is present in the CFF.
- */
- private int getSIDByCharacterName(String name, CFFFont cff)
- {
- int SID = -1;
- for (Mapping m : cff.getMappings())
- {
- if (m.getName().equals(name))
- {
- SID = m.getSID();
- break;
- }
- }
- return SID;
- }
-
public void setType1Font(Type1 type1Font)
{
this.type1Font = type1Font;