use of org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding in project pdfbox by apache.
the class TrueTypeFontValidator method checkEncoding.
@Override
protected void checkEncoding() {
PDTrueTypeFont ttFont = (PDTrueTypeFont) font;
PDFontDescriptor fd = ttFont.getFontDescriptor();
if (fd != null) {
/*
* only MacRomanEncoding or WinAnsiEncoding are allowed for a non symbolic font.
*/
if (fd.isNonSymbolic()) {
Encoding encodingValue = ttFont.getEncoding();
if (!(encodingValue instanceof MacRomanEncoding || encodingValue instanceof WinAnsiEncoding)) {
this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING, fd.getFontName() + ": The Encoding is invalid for the NonSymbolic TTF"));
}
}
/*
* For symbolic font, no encoding entry is allowed and only one encoding entry is expected into the FontFile
* CMap (Check latter when the FontFile stream will be checked)
*/
if (fd.isSymbolic() && fontDictionary.getItem(COSName.ENCODING) != null) {
this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING, fd.getFontName() + ": The Encoding should be missing for the Symbolic TTF"));
}
}
}
Aggregations