/** * Creates a new TrueType font embedder for the given TTF as a PDTrueTypeFont. * * @param document The parent document * @param dict Font dictionary * @param ttfStream TTF stream * @param encoding The PostScript encoding vector to be used for embedding. * @throws IOException if the TTF could not be read */ PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, Encoding encoding) throws IOException { super(document, dict, ttf, false); dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE); GlyphList glyphList = GlyphList.getAdobeGlyphList(); this.fontEncoding = encoding; dict.setItem(COSName.ENCODING, encoding.getCOSObject()); fontDescriptor.setSymbolic(false); fontDescriptor.setNonSymbolic(true); // add the font descriptor dict.setItem(COSName.FONT_DESC, fontDescriptor); // set the glyph widths setWidths(dict, glyphList); }
/** * Returns a PDFontDescriptor for the given PFB. */ static PDFontDescriptor buildFontDescriptor(Type1Font type1) { boolean isSymbolic = type1.getEncoding() instanceof org.apache.fontbox.encoding.BuiltInEncoding; PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(type1.getName()); fd.setFontFamily(type1.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(type1.getFontBBox())); fd.setItalicAngle(type1.getItalicAngle()); fd.setAscent(type1.getFontBBox().getUpperRightY()); fd.setDescent(type1.getFontBBox().getLowerLeftY()); fd.setCapHeight(type1.getBlueValues().get(2).floatValue()); fd.setStemV(0); // for PDF/A return fd; }
/** * Returns a PDFontDescriptor for the given AFM. Used only for Standard 14 fonts. * * @param metrics AFM */ static PDFontDescriptor buildFontDescriptor(FontMetrics metrics) { boolean isSymbolic = metrics.getEncodingScheme().equals("FontSpecific"); PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(metrics.getFontName()); fd.setFontFamily(metrics.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(metrics.getFontBBox())); fd.setItalicAngle(metrics.getItalicAngle()); fd.setAscent(metrics.getAscender()); fd.setDescent(metrics.getDescender()); fd.setCapHeight(metrics.getCapHeight()); fd.setXHeight(metrics.getXHeight()); fd.setAverageWidth(metrics.getAverageCharacterWidth()); fd.setCharacterSet(metrics.getCharacterSet()); fd.setStemV(0); // for PDF/A return fd; }
fd.setNonSymbolic(false);
/** * Creates a new TrueType font embedder for the given TTF as a PDTrueTypeFont. * * @param document The parent document * @param dict Font dictionary * @param ttfStream TTF stream * @param encoding The PostScript encoding vector to be used for embedding. * @throws IOException if the TTF could not be read */ PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, Encoding encoding) throws IOException { super(document, dict, ttf, false); dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE); GlyphList glyphList = GlyphList.getAdobeGlyphList(); this.fontEncoding = encoding; dict.setItem(COSName.ENCODING, encoding.getCOSObject()); fontDescriptor.setSymbolic(false); fontDescriptor.setNonSymbolic(true); // add the font descriptor dict.setItem(COSName.FONT_DESC, fontDescriptor); // set the glyph widths setWidths(dict, glyphList); }
/** * Creates a new TrueType font embedder for the given TTF as a PDTrueTypeFont. * * @param document The parent document * @param dict Font dictionary * @param ttfStream TTF stream * @param encoding The PostScript encoding vector to be used for embedding. * @throws IOException if the TTF could not be read */ PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, Encoding encoding) throws IOException { super(document, dict, ttf, false); dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE); GlyphList glyphList = GlyphList.getAdobeGlyphList(); this.fontEncoding = encoding; dict.setItem(COSName.ENCODING, encoding.getCOSObject()); fontDescriptor.setSymbolic(false); fontDescriptor.setNonSymbolic(true); // add the font descriptor dict.setItem(COSName.FONT_DESC, fontDescriptor); // set the glyph widths setWidths(dict, glyphList); }
/** * Returns a PDFontDescriptor for the given PFB. */ static PDFontDescriptor buildFontDescriptor(Type1Font type1) { boolean isSymbolic = type1.getEncoding() instanceof org.apache.fontbox.encoding.BuiltInEncoding; PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(type1.getName()); fd.setFontFamily(type1.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(type1.getFontBBox())); fd.setItalicAngle(type1.getItalicAngle()); fd.setAscent(type1.getFontBBox().getUpperRightY()); fd.setDescent(type1.getFontBBox().getLowerLeftY()); fd.setCapHeight(type1.getBlueValues().get(2).floatValue()); fd.setStemV(0); // for PDF/A return fd; }
/** * Returns a PDFontDescriptor for the given PFB. */ static PDFontDescriptor buildFontDescriptor(Type1Font type1) { boolean isSymbolic = type1.getEncoding() instanceof org.apache.fontbox.encoding.BuiltInEncoding; PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(type1.getName()); fd.setFontFamily(type1.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(type1.getFontBBox())); fd.setItalicAngle(type1.getItalicAngle()); fd.setAscent(type1.getFontBBox().getUpperRightY()); fd.setDescent(type1.getFontBBox().getLowerLeftY()); fd.setCapHeight(type1.getBlueValues().get(2).floatValue()); fd.setStemV(0); // for PDF/A return fd; }
/** * Returns a PDFontDescriptor for the given AFM. Used only for Standard 14 fonts. * * @param metrics AFM */ static PDFontDescriptor buildFontDescriptor(FontMetrics metrics) { boolean isSymbolic = metrics.getEncodingScheme().equals("FontSpecific"); PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(metrics.getFontName()); fd.setFontFamily(metrics.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(metrics.getFontBBox())); fd.setItalicAngle(metrics.getItalicAngle()); fd.setAscent(metrics.getAscender()); fd.setDescent(metrics.getDescender()); fd.setCapHeight(metrics.getCapHeight()); fd.setXHeight(metrics.getXHeight()); fd.setAverageWidth(metrics.getAverageCharacterWidth()); fd.setCharacterSet(metrics.getCharacterSet()); fd.setStemV(0); // for PDF/A return fd; }
/** * Returns a PDFontDescriptor for the given AFM. Used only for Standard 14 fonts. * * @param metrics AFM */ static PDFontDescriptor buildFontDescriptor(FontMetrics metrics) { boolean isSymbolic = metrics.getEncodingScheme().equals("FontSpecific"); PDFontDescriptor fd = new PDFontDescriptor(); fd.setFontName(metrics.getFontName()); fd.setFontFamily(metrics.getFamilyName()); fd.setNonSymbolic(!isSymbolic); fd.setSymbolic(isSymbolic); fd.setFontBoundingBox(new PDRectangle(metrics.getFontBBox())); fd.setItalicAngle(metrics.getItalicAngle()); fd.setAscent(metrics.getAscender()); fd.setDescent(metrics.getDescender()); fd.setCapHeight(metrics.getCapHeight()); fd.setXHeight(metrics.getXHeight()); fd.setAverageWidth(metrics.getAverageCharacterWidth()); fd.setCharacterSet(metrics.getCharacterSet()); fd.setStemV(0); // for PDF/A return fd; }