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; } }
+ code + " in the font program \"" + font.getName() + "\" is missing from the Character Encoding"); markAsInvalid(code, e); float expectedWidth = font.getWidth(code); float foundWidth = font.getWidthFromFont(code); checkWidthsConsistency(code, expectedWidth, foundWidth);
public void validate() PDFontDescriptor fd = this.font.getFontDescriptor(); boolean isStandard14 = false; if (this.font instanceof PDFont) this.font.getName() + ": FontDescriptor is null or is an AFM Descriptor")); this.fContainer.notEmbedded();
private PDStream getCIDSetStream() { PDFontDescriptor fontDescriptor = this.pdFontLike.getFontDescriptor(); PDStream cidSet; if (fontDescriptor != null) { cidSet = fontDescriptor.getCIDSet(); return cidSet; } return null; }
private List<FontProgram> getFontFile() { if (!getSubtype().equals(FontFactory.TYPE_3) && (this.pdFontLike.isEmbedded())) { if (getSubtype().equals(FontFactory.TRUE_TYPE)) { PBoxTrueTypeFontProgram trueTypeFontProgram = new PBoxTrueTypeFontProgram( ((PDTrueTypeFont) this.pdFontLike).getTrueTypeFont(), getisSymbolic()); return PBoxPDFont.getFontProgramList(trueTypeFontProgram); } PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor(); PDStream fontFile; if (getSubtype().equals(FontFactory.TYPE_1)) { if (this.pdFontLike instanceof PDType1CFont) { fontFile = fontDescriptor.getFontFile3(); } else { fontFile = fontDescriptor.getFontFile(); } } else if (getSubtype().equals(FontFactory.CID_FONT_TYPE_2)) { fontFile = fontDescriptor.getFontFile2(); } else { fontFile = fontDescriptor.getFontFile3(); } if (fontFile != null) { return PBoxPDFont.getFontProgramList(new PBoxFontProgram(fontFile)); } } return Collections.emptyList(); }
public void validate() PDFontDescriptor fd = this.font.getFontDescriptor(); boolean isStandard14 = false; if (this.font instanceof PDFont) this.font.getName() + ": FontDescriptor is null or is an AFM Descriptor")); this.fContainer.notEmbedded();
@Override public String getCharSet() { PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor(); return fontDescriptor != null ? fontDescriptor.getCharSet() : 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); }
+ code + " in the font program \"" + font.getName() + "\" is missing from the Character Encoding"); markAsInvalid(code, e); float expectedWidth = font.getWidth(code); float foundWidth = font.getWidthFromFont(code); checkWidthsConsistency(code, expectedWidth, foundWidth);
public void validate() PDFontDescriptor fd = this.font.getFontDescriptor(); boolean isStandard14 = false; if (this.font instanceof PDFont) this.font.getName() + ": FontDescriptor is null or is an AFM Descriptor")); this.fContainer.notEmbedded();
@Override public Boolean getisSymbolic() { PDFontDescriptor fontDescriptor = this.pdFontLike.getFontDescriptor(); return Boolean.valueOf(fontDescriptor.isSymbolic()); }
String fontName = ((PDFontLike) font).getName(); if (font instanceof PDType0Font)
+ code + " in the font program \"" + font.getName() + "\" is missing from the Character Encoding"); markAsInvalid(code, e); float expectedWidth = font.getWidth(code); float foundWidth = font.getWidthFromFont(code); checkWidthsConsistency(code, expectedWidth, foundWidth);
@Override public Boolean getcharSetListsAllGlyphs() { try { PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor(); if (fontDescriptor != null) { String charSet = fontDescriptor.getCharSet();
@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")); } } } }
PDFontDescriptor fontDescriptor = fontLike.getFontDescriptor(); if (fontDescriptor != null) { this.fontDescriptor = new PDFontDescriptorAdapter(fontDescriptor);