PdfType1Font(Type1Font type1Font, String encoding, boolean embedded) { super(); setFontProgram(type1Font); this.embedded = embedded && !type1Font.isBuiltInFont(); if ((encoding == null || encoding.length() == 0) && type1Font.isFontSpecific()) { encoding = FontEncoding.FONT_SPECIFIC; } if (encoding != null && FontEncoding.FONT_SPECIFIC.toLowerCase().equals(encoding.toLowerCase())) { fontEncoding = FontEncoding.createFontSpecificEncoding(); } else { fontEncoding = FontEncoding.createFontEncoding(encoding); } }
private static FontProgramDescriptor fetchType1FontDescriptor(String fontName, byte[] afm) throws java.io.IOException { //TODO close original stream, may be separate static method should introduced Type1Font fp = new Type1Font(fontName, null, afm, null); return new FontProgramDescriptor(fp.getFontNames(), fp.getFontMetrics()); }
/** * Find glyph by glyph name. * @param name Glyph name * @return Glyph instance if found, otherwise null. */ public Glyph getGlyph(String name) { int unicode = AdobeGlyphList.nameToUnicode(name); if (unicode != -1) { return getGlyph((int) unicode); } else { return null; } }
@Override public int getPdfFontFlags() { int flags = 0; if (fontMetrics.isFixedPitch()) { flags |= 1; } flags |= isFontSpecific() ? 4 : 32; if (fontMetrics.getItalicAngle() < 0) { flags |= 64; } if (fontNames.getFontName().contains("Caps") || fontNames.getFontName().endsWith("SC")) { flags |= 131072; } if (fontNames.isBold() || fontNames.getFontWeight() > 500) { flags |= 262144; } return flags; }
protected static Type1Font createStandardFont(String name) throws java.io.IOException { if (StandardFonts.isStandardFont(name)) { return new Type1Font(name, null, null, null); } else { throw new IOException("{0} is not a standard type1 font.").setMessageParams(name); } }
byte[] fontStreamBytes = ((Type1Font) getFontProgram()).getFontStreamBytes(); if (fontStreamBytes != null) { PdfStream fontStream = new PdfStream(fontStreamBytes); int[] fontStreamLengths = ((Type1Font) getFontProgram()).getFontStreamLengths(); for (int k = 0; k < fontStreamLengths.length; ++k) { fontStream.put(new PdfName("Length" + (k + 1)), new PdfNumber(fontStreamLengths[k]));
protected Type1Font(String baseFont) { this(); getFontNames().setFontName(baseFont); }
protected Type1Font(String metricsPath, String binaryPath, byte[] afm, byte[] pfb) throws java.io.IOException { this(); fontParser = new Type1Parser(metricsPath, binaryPath, afm, pfb); process(); }
@Override protected boolean isBuiltInFont() { return ((Type1Font) getFontProgram()).isBuiltInFont(); }
@Override public int getPdfFontFlags() { int flags = 0; if (fontMetrics.isFixedPitch()) { flags |= 1; } flags |= isFontSpecific() ? 4 : 32; if (fontMetrics.getItalicAngle() < 0) { flags |= 64; } if (fontNames.getFontName().contains("Caps") || fontNames.getFontName().endsWith("SC")) { flags |= 131072; } if (fontNames.isBold() || fontNames.getFontWeight() > 500) { flags |= 262144; } return flags; }
protected static Type1Font createStandardFont(String name) throws java.io.IOException { if (StandardFonts.isStandardFont(name)) { return new Type1Font(name, null, null, null); } else { throw new IOException("{0} is not a standard type1 font.").setMessageParams(name); } }
protected Type1Font(String baseFont) { this(); getFontNames().setFontName(baseFont); }
protected Type1Font(String metricsPath, String binaryPath, byte[] afm, byte[] pfb) throws java.io.IOException { this(); fontParser = new Type1Parser(metricsPath, binaryPath, afm, pfb); process(); }
private static FontProgramDescriptor fetchType1FontDescriptor(String fontName, byte[] afm) throws java.io.IOException { //TODO close original stream, may be separate static method should introduced Type1Font fp = new Type1Font(fontName, null, afm, null); return new FontProgramDescriptor(fp.getFontNames(), fp.getFontMetrics()); }
private static FontProgram createType1Font(String metricsPath, String binaryPath, byte[] afm, byte[] pfb, boolean cached) throws java.io.IOException { FontProgram fontProgram; FontCacheKey fontKey = null; if (cached) { fontKey = createFontCacheKey(metricsPath, afm); fontProgram = FontCache.getFont(fontKey); if (fontProgram != null) { return fontProgram; } } fontProgram = new Type1Font(metricsPath, binaryPath, afm, pfb); return cached ? FontCache.saveFont(fontProgram, fontKey) : fontProgram; }
/** * Find glyph by glyph name. * @param name Glyph name * @return Glyph instance if found, otherwise null. */ public Glyph getGlyph(String name) { int unicode = AdobeGlyphList.nameToUnicode(name); if (unicode != -1) { return getGlyph((int) unicode); } else { return null; } }
private static FontProgram createType1Font(String metricsPath, String binaryPath, byte[] afm, byte[] pfb, boolean cached) throws java.io.IOException { FontProgram fontProgram; FontCacheKey fontKey = null; if (cached) { fontKey = createFontCacheKey(metricsPath, afm); fontProgram = FontCache.getFont(fontKey); if (fontProgram != null) { return fontProgram; } } fontProgram = new Type1Font(metricsPath, binaryPath, afm, pfb); return cached ? FontCache.saveFont(fontProgram, fontKey) : fontProgram; }