Class FontContainer<T extends PDFontLike>
- java.lang.Object
-
- org.apache.pdfbox.preflight.font.container.FontContainer<T>
-
- Direct Known Subclasses:
CIDType0Container
,CIDType2Container
,TrueTypeContainer
,Type0Container
,Type1Container
,Type3Container
public abstract class FontContainer<T extends PDFontLike> extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,GlyphDetail>
codeToDetail
protected boolean
embeddedFont
Boolean used to known if the font is embedded.protected java.util.List<ValidationResult.ValidationError>
errorBuffer
List of validation errors that occur during the font validation.private boolean
errorsAlreadyMerged
protected T
font
Font-like object.
-
Constructor Summary
Constructors Constructor Description FontContainer(T font)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
checkGlyphWidth(int code)
Check that the Width or W entry in the PDF matches the widths in the embedded font program.private void
checkWidthsConsistency(int code, float expectedWidth, float foundWidth)
Test if both widths are consistent.boolean
errorsAleadyMerged()
java.util.List<ValidationResult.ValidationError>
getAllErrors()
protected abstract boolean
hasGlyph(int code)
Checks if the embedded font contains a glyph for the given character code.private boolean
isAlreadyProcessed(int code)
Check if the given character code has already been processed.boolean
isEmbeddedFont()
boolean
isValid()
void
markAsInvalid(int code, GlyphException e)
void
markAsValid(int code)
void
notEmbedded()
void
push(java.util.List<ValidationResult.ValidationError> errors)
void
push(ValidationResult.ValidationError error)
void
setErrorsAlreadyMerged(boolean errorsAlreadyMerged)
-
-
-
Field Detail
-
errorBuffer
protected java.util.List<ValidationResult.ValidationError> errorBuffer
List of validation errors that occur during the font validation. If the font is used by an object in the PDF, all these errors will be appended to the Error list of the PreflightContext.
-
embeddedFont
protected boolean embeddedFont
Boolean used to known if the font is embedded.
-
codeToDetail
private final java.util.Map<java.lang.Integer,GlyphDetail> codeToDetail
-
errorsAlreadyMerged
private boolean errorsAlreadyMerged
-
font
protected final T extends PDFontLike font
Font-like object.
-
-
Constructor Detail
-
FontContainer
public FontContainer(T font)
-
-
Method Detail
-
push
public void push(ValidationResult.ValidationError error)
-
push
public void push(java.util.List<ValidationResult.ValidationError> errors)
-
getAllErrors
public java.util.List<ValidationResult.ValidationError> getAllErrors()
-
isValid
public boolean isValid()
-
errorsAleadyMerged
public boolean errorsAleadyMerged()
-
setErrorsAlreadyMerged
public void setErrorsAlreadyMerged(boolean errorsAlreadyMerged)
-
isEmbeddedFont
public boolean isEmbeddedFont()
-
notEmbedded
public void notEmbedded()
-
checkGlyphWidth
public void checkGlyphWidth(int code) throws GlyphException
Check that the Width or W entry in the PDF matches the widths in the embedded font program.- Parameters:
code
- character code- Throws:
GlyphException
-
hasGlyph
protected abstract boolean hasGlyph(int code) throws java.io.IOException
Checks if the embedded font contains a glyph for the given character code.- Parameters:
code
- character code- Throws:
java.io.IOException
-
isAlreadyProcessed
private boolean isAlreadyProcessed(int code) throws GlyphException
Check if the given character code has already been processed.- Parameters:
code
- character code- Returns:
- true if the CID has previously been marked as valid, false otherwise
- Throws:
GlyphException
- if the code has previously been marked as invalid // TODO useful ??
-
checkWidthsConsistency
private void checkWidthsConsistency(int code, float expectedWidth, float foundWidth) throws GlyphException
Test if both widths are consistent. At the end of this method, the CID is marked as valid or invalid.- Parameters:
code
- character codeexpectedWidth
- expected with given in the PDF filefoundWidth
- the glyph width found in the font program, a negative value if the CID is missing from the font.- Throws:
GlyphException
- the appropriate exception if the CID is invalid.
-
markAsValid
public final void markAsValid(int code)
-
markAsInvalid
public final void markAsInvalid(int code, GlyphException e)
-
-