private void addFontError(COSDictionary dictionary, PreflightContext context)
{
COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
if (!COSName.FONT.equals(type))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Expected 'Font' dictionary but found '" + type.getName() + "'"));
}
String fontName = "Unknown";
if (dictionary.containsKey(COSName.BASE_FONT))
{
fontName = dictionary.getNameAsString(COSName.BASE_FONT);
}
COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
if (COSName.TYPE1.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
"The FontFile can't be read for " + fontName));
}
else if (COSName.MM_TYPE1.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
"The FontFile can't be read for " + fontName));
}
else if (COSName.TRUE_TYPE.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TRUETYPE_DAMAGED,
"The FontFile can't be read for " + fontName));
}
else if (COSName.TYPE3.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE3_DAMAGED,
"The FontFile can't be read for " + fontName));
}
else if (COSName.TYPE0.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_CID_DAMAGED,
"The FontFile can't be read for " + fontName));
}
else if (COSName.CID_FONT_TYPE0.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unexpected CIDFontType0 descendant font for " + fontName));
}
else if (COSName.CID_FONT_TYPE2.equals(subType))
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unexpected CIDFontType2 descendant font for " + fontName));
}
else
{
addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unknown font type for " + fontName));
}
}