/** * Creates a new standard Helvetica font program file. * * @return a {@link FontProgram} object with Helvetica font description */ public static FontProgram createFont() throws java.io.IOException { return createFont(StandardFonts.HELVETICA); }
/** * Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file. * In case if TrueType Collection (.ttc), an additional parameter may be specified defining the index of the font * to be registered, e.g. "path/to/font/collection.ttc,0". The index is zero-based. * * @param path the path to a font file */ public static void registerFont(String path) { registerFont(path, null); }
/** * Creates a new Type 1 font by the corresponding AFM/PFM and PFB files * @param metricsPath path to the AFM or PFM metrics file * @param binaryPath path to the contents of the PFB file * @return created {@link FontProgram} instance */ public static FontProgram createType1Font(String metricsPath, String binaryPath) throws java.io.IOException { return createType1Font(metricsPath, binaryPath, DEFAULT_CACHED); }
if (font != null) return font; FontProgram ff2 = FontProgramFactory.createRegisteredFont(faceName, ((italic != 0) ? FontStyles.ITALIC : 0) | ((bold != 0) ? FontStyles.BOLD : 0)); encoding = FontEncoding.createFontEncoding(PdfEncodings.WINANSI); font = ff2; font = FontProgramFactory.createFont(fontName); encoding = FontEncoding.createFontEncoding(PdfEncodings.WINANSI);
FontCacheKey fontKey = null; if (cached) { fontKey = createFontCacheKey(name, fontProgram); fontFound = FontCache.getFont(fontKey); if (fontFound != null) { fontProgram = readFontBytesFromPath(baseName);
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; }
/** * Gets a set of registered font names. * * @return a set of registered fonts */ public static Set<String> getRegisteredFonts() { return FontProgramFactory.getRegisteredFonts(); }
/** * Gets a set of registered font families. * * @return a set of registered font families */ public static Set<String> getRegisteredFamilies() { return FontProgramFactory.getRegisteredFontFamilies(); }
/** * Creates {@link PdfFont} based on registered {@link FontProgram}'s. * * @see PdfFontFactory#register(String) * @see PdfFontFactory#register(String, String) * @see PdfFontFactory#registerFamily(String, String, String) * @see PdfFontFactory#registerDirectory(String) * @see PdfFontFactory#registerSystemDirectories() * @see PdfFontFactory#getRegisteredFamilies() * @see PdfFontFactory#getRegisteredFonts() */ public static PdfFont createRegisteredFont(String fontName, String encoding, boolean embedded, int style, boolean cached) throws IOException { FontProgram fp = FontProgramFactory.createRegisteredFont(fontName, style, cached); return createFont(fp, encoding, embedded); }
FontCacheKey fontKey = null; if (cached) { fontKey = createFontCacheKey(name, fontProgram); fontFound = FontCache.getFont(fontKey); if (fontFound != null) { fontProgram = readFontBytesFromPath(baseName);
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; }
/** * Creates a new standard Helvetica font program file. * * @return a {@link FontProgram} object with Helvetica font description */ public static FontProgram createFont() throws java.io.IOException { return createFont(StandardFonts.HELVETICA); }
/** * Register a font file and use an alias for the font contained in it. * * @param path the path to a font file * @param alias the alias you want to use for the font */ public static void register(String path, String alias) { FontProgramFactory.registerFont(path, alias); }
/** * Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files * @param afm the contents of the AFM or PFM metrics file * @param pfb the contents of the PFB file * @param cached specifies whether to cache the created {@link FontProgram} or not * @return created {@link FontProgram} instance */ public static FontProgram createType1Font(byte[] afm, byte[] pfb, boolean cached) throws java.io.IOException { return createType1Font(null, null, afm, pfb, cached); }
/** * Creates a new font program. This font program can be one of the 14 built in fonts, * a Type1 font referred to by an AFM or PFM file, a TrueType font or * a CJK font from the Adobe Asian Font Pack. * Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". * This would get the second font (indexes start at 0), in this case "MS PGothic". * <p> * The fonts are cached and if they already exist they are extracted from the cache, * not parsed again. * <p> * * @param fontProgram the name of the font or its location on file * @param cached whether to to cache this font program after it has been loaded * @return returns a new {@link FontProgram}. This font program may come from the cache */ public static FontProgram createFont(String fontProgram, boolean cached) throws java.io.IOException { return createFont(fontProgram, null, cached); }
/** * Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file. * In case if TrueType Collection (.ttc), an additional parameter may be specified defining the index of the font * to be registered, e.g. "path/to/font/collection.ttc,0". The index is zero-based. * * @param path the path to a font file */ public static void registerFont(String path) { registerFont(path, null); }
/** * Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files * @param afm the contents of the AFM or PFM metrics file * @param pfb the contents of the PFB file * @return created {@link FontProgram} instance */ public static FontProgram createType1Font(byte[] afm, byte[] pfb) throws java.io.IOException { return createType1Font(afm, pfb, DEFAULT_CACHED); }
/** * Creates a new font program. This font program can be one of the 14 built in fonts, * a Type1 font referred to by an AFM or PFM file, a TrueType font or * a CJK font from the Adobe Asian Font Pack. * Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". * This would get the second font (indexes start at 0), in this case "MS PGothic". * <p> * The fonts are cached and if they already exist they are extracted from the cache, * not parsed again. * <p> * * @param fontProgram the byte contents of the font program * @return returns a new {@link FontProgram}. This font program may come from the cache */ public static FontProgram createFont(byte[] fontProgram) throws java.io.IOException { return createFont(null, fontProgram, DEFAULT_CACHED); }
/** * Creates a new Type 1 font by the corresponding AFM/PFM and PFB files * @param metricsPath path to the AFM or PFM metrics file * @param binaryPath path to the contents of the PFB file * @param cached specifies whether to cache the created {@link FontProgram} or not * @return created {@link FontProgram} instance */ public static FontProgram createType1Font(String metricsPath, String binaryPath, boolean cached) throws java.io.IOException { return createType1Font(metricsPath, binaryPath, null, null, cached); }
/** * Creates a new font program. This font program can be one of the 14 built in fonts, * a Type1 font referred to by an AFM or PFM file, a TrueType font or * a CJK font from the Adobe Asian Font Pack. * Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". * This would get the second font (indexes start at 0), in this case "MS PGothic". * <p> * The fonts are cached and if they already exist they are extracted from the cache, * not parsed again. * <p> * * @param fontProgram the name of the font or its location on file * @param cached whether to to cache this font program after it has been loaded * @return returns a new {@link FontProgram}. This font program may come from the cache */ public static FontProgram createFont(String fontProgram, boolean cached) throws java.io.IOException { return createFont(fontProgram, null, cached); }