@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TYPE1_DAMAGED, this.font.getName() + ": The FontFile can't be read")); } } }
protected final byte[] getMetaDataStreamAsBytes(PDMetadata metadata) { try (InputStream metaDataContent = metadata.createInputStream()) { return IOUtils.toByteArray(metaDataContent); } catch (IOException e) { this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_STREAM, this.font.getName() + ": Unable to read font metadata due to : " + e.getMessage(), e)); return null; } }
/** * Test if both widths are consistent. At the end of this method, the CID is * marked as valid or invalid. * * @param code character code * @param expectedWidth expected with given in the PDF file * @param foundWidth 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. */ private void checkWidthsConsistency(int code, float expectedWidth, float foundWidth) throws GlyphException { // consistent is defined to be a difference of no more than 1/1000 unit. if (Math.abs(foundWidth - expectedWidth) > 1) { GlyphException e = new GlyphException(PreflightConstants.ERROR_FONTS_METRICS, code, "Width (" + foundWidth + ") of the character \"" + code + "\" in the font program \"" + this.font.getName() + "\" is inconsistent with the width (" + expectedWidth + ") in the PDF dictionary."); markAsInvalid(code, e); throw e; } markAsValid(code); }
String fontName = ((PDFontLike) font).getName(); if (font instanceof PDType0Font)
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TRUETYPE_DAMAGED, this.font.getName() + ": The FontFile can't be read")); } else { // there must be exactly one encoding in the "cmap" table if the font is symbolic TrueTypeFont ttf = pdTrueTypeFont.getTrueTypeFont(); try { if (pdTrueTypeFont.isSymbolic() && ttf.getCmap().getCmaps().length != 1) { this.fContainer.push(new ValidationError(ERROR_FONTS_ENCODING, this.font.getName() + ": Symbolic TrueType font has more than one 'cmap' entry")); } } catch (IOException e) { this.fContainer.push(new ValidationError(ERROR_FONTS_TRUETYPE_DAMAGED, this.font.getName() + ": The TTF 'cmap' could not be read")); } } } }
this.font.getName() + ": some required fields are missing from the Font dictionary: " + missingFields + "."));
+ code + " in the font program \"" + font.getName() + "\" is missing from the Character Encoding"); markAsInvalid(code, e);
@Override protected void checkMandatoryField() { boolean arePresent = fontDictionary.containsKey(COSName.TYPE); arePresent &= fontDictionary.containsKey(COSName.SUBTYPE); arePresent &= fontDictionary.containsKey(COSName.BASE_FONT); arePresent &= fontDictionary.containsKey(COSName.CIDSYSTEMINFO); arePresent &= fontDictionary.containsKey(COSName.FONT_DESC); if (!arePresent) { this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID, font.getName() + ": Required keys are missing")); } checkCIDSystemInfo(fontDictionary.getItem(COSName.CIDSYSTEMINFO)); checkCIDToGIDMap(fontDictionary.getItem(COSName.CID_TO_GID_MAP)); }
/** * Generate ID for font. Current method generate a string of the form * 'hashcode fontName', where 'hashcode' is hashcode of font dictionary * and 'fontName' is String * * @param font target font for generating ID * @return string representation of ID */ public static String generateID(PDFontLike font) { int hashcode = font instanceof COSObjectable ? ((COSObjectable) font).getCOSObject().hashCode() : -1; return String.valueOf(hashcode) + ' ' + font.getName(); }
this.font.getName() + ": FontDescriptor is null or is an AFM Descriptor")); this.fContainer.notEmbedded();
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TYPE1_DAMAGED, this.font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TYPE1_DAMAGED, this.font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, font.getName() + ": The FontFile can't be read")); } } }
@Override protected void processFontFile(PDFontDescriptor fontDescriptor, PDStream fontFile) { if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, font.getName() + ": The FontFile can't be read")); } } }