/** * Returns the descendant CIDFont. */ public PDCIDFont getCIDFont() throws IOException { return new PDCIDFontType2(cidFont, parent, ttf); } }
@Override public boolean hasGlyph(int code) throws IOException { return codeToGID(code) != 0; } }
@Override public GeneralPath getNormalizedPath(int code) throws IOException { boolean hasScaling = ttf.getUnitsPerEm() != 1000; float scale = 1000f / ttf.getUnitsPerEm(); int gid = codeToGID(code); GeneralPath path = getPath(code); // Acrobat only draws GID 0 for embedded CIDFonts, see PDFBOX-2372 if (gid == 0 && !isEmbedded()) { path = null; } if (path == null) { // empty glyph (e.g. space, newline) return new GeneralPath(); } else { if (hasScaling) { path.transform(AffineTransform.getScaleInstance(scale, scale)); } return path; } }
private TrueTypeFont findFontOrSubstitute() throws IOException { TrueTypeFont ttfFont; CIDFontMapping mapping = FontMappers.instance() .getCIDFont(getBaseFont(), getFontDescriptor(), getCIDSystemInfo()); if (mapping.isCIDFont()) { ttfFont = mapping.getFont(); } else { ttfFont = (TrueTypeFont)mapping.getTrueTypeFont(); } if (mapping.isFallback()) { LOG.warn("Using fallback font " + ttfFont.getName() + " for CID-keyed TrueType font " + getBaseFont()); } return ttfFont; }
if (t0font.getDescendantFont() instanceof PDCIDFontType2) int unitsPerEm = ((PDCIDFontType2) t0font.getDescendantFont()).getTrueTypeFont().getHeader().getUnitsPerEm(); at.scale(1000d / unitsPerEm, 1000d / unitsPerEm);
PDFontDescriptor fd = getFontDescriptor(); if (trueTypeFont != null) LOG.info("OpenType Layout tables used in font " + getBaseFont() + " are not implemented in PDFBox and will be ignored"); LOG.warn("Could not read embedded OTF for font " + getBaseFont(), e); ttfFont = findFontOrSubstitute(); cid2gid = readCIDToGIDMap();
String.format("No glyph for U+%04X in font %s", unicode, getName())); return encodeGlyphId(cid);
@Override public BoundingBox getBoundingBox() throws IOException { if (fontBBox == null) { fontBBox = generateBoundingBox(); } return fontBBox; }
private BoundingBox generateBoundingBox() throws IOException { if (getFontDescriptor() != null) { PDRectangle bbox = getFontDescriptor().getFontBoundingBox(); if (bbox != null && (Float.compare(bbox.getLowerLeftX(), 0) != 0 || Float.compare(bbox.getLowerLeftY(), 0) != 0 || Float.compare(bbox.getUpperRightX(), 0) != 0 || Float.compare(bbox.getUpperRightY(), 0) != 0)) { return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(), bbox.getUpperRightX(), bbox.getUpperRightY()); } } return ttf.getFontBBox(); }
String.format("No glyph for U+%04X in font %s", unicode, getName()));
/** * Constructor. * * @param type0Font Type0 font, with CIDFontType2 descendant */ TTFGlyph2D(PDType0Font type0Font) throws IOException { this(((PDCIDFontType2)type0Font.getDescendantFont()).getTrueTypeFont(), type0Font, true); vectorFont = type0Font; }
PDFontDescriptor fd = getFontDescriptor(); if (trueTypeFont != null) LOG.info("OpenType Layout tables used in font " + getBaseFont() + " are not implemented in PDFBox and will be ignored"); LOG.warn("Could not read embedded OTF for font " + getBaseFont(), e); LOG.warn("Could not read embedded OTF for font " + getBaseFont(), e); ttfFont = findFontOrSubstitute(); cid2gid = readCIDToGIDMap();
@Override public GeneralPath getNormalizedPath(int code) throws IOException { boolean hasScaling = ttf.getUnitsPerEm() != 1000; float scale = 1000f / ttf.getUnitsPerEm(); int gid = codeToGID(code); GeneralPath path = getPath(code); // Acrobat only draws GID 0 for embedded CIDFonts, see PDFBOX-2372 if (gid == 0 && !isEmbedded()) { path = null; } if (path == null) { // empty glyph (e.g. space, newline) return new GeneralPath(); } else { if (hasScaling) { path.transform(AffineTransform.getScaleInstance(scale, scale)); } return path; } }
private TrueTypeFont findFontOrSubstitute() throws IOException { TrueTypeFont ttfFont; CIDFontMapping mapping = FontMappers.instance() .getCIDFont(getBaseFont(), getFontDescriptor(), getCIDSystemInfo()); if (mapping.isCIDFont()) { ttfFont = mapping.getFont(); } else { ttfFont = (TrueTypeFont)mapping.getTrueTypeFont(); } if (mapping.isFallback()) { LOG.warn("Using fallback font " + ttfFont.getName() + " for CID-keyed TrueType font " + getBaseFont()); } return ttfFont; }
@Override public BoundingBox getBoundingBox() throws IOException { if (fontBBox == null) { fontBBox = generateBoundingBox(); } return fontBBox; }
private BoundingBox generateBoundingBox() throws IOException { if (getFontDescriptor() != null) { PDRectangle bbox = getFontDescriptor().getFontBoundingBox(); if (bbox != null && (Float.compare(bbox.getLowerLeftX(), 0) != 0 || Float.compare(bbox.getLowerLeftY(), 0) != 0 || Float.compare(bbox.getUpperRightX(), 0) != 0 || Float.compare(bbox.getUpperRightY(), 0) != 0)) { return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(), bbox.getUpperRightX(), bbox.getUpperRightY()); } } return ttf.getFontBBox(); }
String.format("No glyph for U+%04X in font %s", unicode, getName()));
if (cidFont instanceof PDCIDFontType2) ttf = ((PDCIDFontType2)cidFont).getTrueTypeFont();
@Override public boolean hasGlyph(int code) throws IOException { return font.codeToGID(code) != 0; } }