public boolean equalToPDFont(PDFont compare) { // Appears you can have two different fonts with the same actual font name since text position font // references go off a seperate dict lookup name. PDFBox doesn't include the lookup name with the // PDFont, so might have to submit a change there to be really sure fonts are indeed the same. return compare.getName().equals(baseFont.getName()) && compare.getType().equals(baseFont.getType()) && compare.getSubType().equals(baseFont.getSubType()); }
@Override public String getType() { String type = null; if (this.pdFontLike instanceof org.apache.pdfbox.pdmodel.font.PDFont) { type = ((org.apache.pdfbox.pdmodel.font.PDFont) this.pdFontLike).getType(); } else if (this.pdFontLike instanceof PDCIDFont) { type = ((PDCIDFont) this.pdFontLike).getCOSObject().getNameAsString(COSName.TYPE); } return type; }
public static FVFont convertFont(PDFont font, FontFormat format) throws IOException { FVFont readFont = null; if (font instanceof PDTrueTypeFont) { if (font.getFontDescriptor() == null || font.getFontDescriptor().getFontFile2() == null) { log.warn("Skipped font: '{}'. No font file 2 found", font.getName()); return null; } byte[] data = font.getFontDescriptor().getFontFile2().toByteArray(); readFont = FontVerter.readFont(data); } else if (font instanceof PDType0Font) { readFont = convertType0FontToOpenType((PDType0Font) font); readFont.normalize(); } else if (font instanceof PDType1CFont) { byte[] data = font.getFontDescriptor().getFontFile3().toByteArray(); readFont = FontVerter.readFont(data); } else log.warn("Skipped font: '{}'. FontVerter does not support font type: '{}'", font.getName(), font.getType()); if (readFont == null) return null; if (!readFont.isValid()) readFont.normalize(); return FontVerter.convertFont(readFont, format); }