private static FontProgramDescriptor fetchCidFontDescriptor(String fontName) { CidFont font = new CidFont(fontName, null); return new FontProgramDescriptor(font.getFontNames(), font.getFontMetrics()); }
CidFont(String fontName, Set<String> cmaps, Map<String, Object> fontDescription) { initializeCidFontNameAndStyle(fontName); initializeCidFontProperties(fontDescription); compatibleCmaps = cmaps; }
fontMetrics.updateBbox(llx, lly, urx, ury); registry = (String) fontDesc.get("Registry"); String uniMap = getCompatibleUniMap(registry); if (uniMap != null) { IntHashtable metrics = (IntHashtable) fontDesc.get("W"); unicodeToGlyph.put(uni, glyph); fixSpaceIssue(); if (codeToGlyph.size() != 0) { avgWidth /= codeToGlyph.size();
PdfType0Font(CidFont font, String cmap) { super(); if (!CidFontProperties.isCidFont(font.getFontNames().getFontName(), cmap)) { throw new PdfException("Font {0} with {1} encoding is not a cjk font.") .setMessageParams(font.getFontNames().getFontName(), cmap); } this.fontProgram = font; vertical = cmap.endsWith("V"); String uniMap = getCompatibleUniMap(fontProgram.getRegistry()); cmapEncoding = new CMapEncoding(cmap, uniMap); longTag = new HashSet<>(); cidFontType = CID_FONT_TYPE_0; }
private void initializeCidFontNameAndStyle(String fontName) { String nameBase = trimFontStyle(fontName); if (nameBase.length() < fontName.length()) { fontNames.setFontName(fontName); fontNames.setStyle(fontName.substring(nameBase.length())); } else { fontNames.setFontName(fontName); } fontNames.setFullName(new String[][]{new String[]{"", "", "", fontNames.getFontName()}}); }
fontBuilt = new Type1Font(name, null, null, null); } else if (isCidFont) { fontBuilt = new CidFont(name, FontCache.getCompatibleCmaps(baseName)); } else if (".ttf".equals(fontFileExtension) || ".otf".equals(fontFileExtension)) { if (fontProgram != null) {
/** * Created a {@link PdfFont} instance given the given underlying {@link FontProgram} instance. * * @param fontProgram the font program of the {@link PdfFont} instance to be created * @param encoding the encoding of the font to be created. See {@link PdfEncodings} * @param embedded indicates whether the font is to be embedded into the target document * @return created {@link PdfFont} instance */ public static PdfFont createFont(FontProgram fontProgram, String encoding, boolean embedded) { if (fontProgram == null) { return null; } else if (fontProgram instanceof Type1Font) { return new PdfType1Font((Type1Font) fontProgram, encoding, embedded); } else if (fontProgram instanceof TrueTypeFont) { if (PdfEncodings.IDENTITY_H.equals(encoding) || PdfEncodings.IDENTITY_V.equals(encoding)) { return new PdfType0Font((TrueTypeFont) fontProgram, encoding); } else { return new PdfTrueTypeFont((TrueTypeFont) fontProgram, encoding, embedded); } } else if (fontProgram instanceof CidFont) { if (((CidFont) fontProgram).compatibleWith(encoding)) { return new PdfType0Font((CidFont) fontProgram, encoding); } else { return null; } } else { return null; } }
fontMetrics.updateBbox(llx, lly, urx, ury); registry = (String) fontDesc.get("Registry"); String uniMap = getCompatibleUniMap(registry); if (uniMap != null) { IntHashtable metrics = (IntHashtable) fontDesc.get("W"); unicodeToGlyph.put(uni, glyph); fixSpaceIssue(); if (codeToGlyph.size() != 0) { avgWidth /= codeToGlyph.size();
private void initializeCidFontNameAndStyle(String fontName) { String nameBase = trimFontStyle(fontName); if (nameBase.length() < fontName.length()) { fontNames.setFontName(fontName); fontNames.setStyle(fontName.substring(nameBase.length())); } else { fontNames.setFontName(fontName); } fontNames.setFullName(new String[][]{new String[]{"", "", "", fontNames.getFontName()}}); }
fontBuilt = new Type1Font(name, null, null, null); } else if (isCidFont) { fontBuilt = new CidFont(name, FontCache.getCompatibleCmaps(baseName)); } else if (".ttf".equals(fontFileExtension) || ".otf".equals(fontFileExtension)) { if (fontProgram != null) {
private static FontProgramDescriptor fetchCidFontDescriptor(String fontName) { CidFont font = new CidFont(fontName, null); return new FontProgramDescriptor(font.getFontNames(), font.getFontMetrics()); }
CidFont(String fontName, Set<String> cmaps, Map<String, Object> fontDescription) { initializeCidFontNameAndStyle(fontName); initializeCidFontProperties(fontDescription); compatibleCmaps = cmaps; }
CidFont(String fontName, Set<String> cmaps) { this.fontName = fontName; compatibleCmaps = cmaps; fontNames = new FontNames(); initializeCidFontNameAndStyle(fontName); Map<String, Object> fontDesc = CidFontProperties.getAllFonts().get(fontNames.getFontName()); if (fontDesc == null) { throw new IOException("There is no such predefined font: {0}").setMessageParams(fontName); } initializeCidFontProperties(fontDesc); }
CidFont(String fontName, Set<String> cmaps) { this.fontName = fontName; compatibleCmaps = cmaps; fontNames = new FontNames(); initializeCidFontNameAndStyle(fontName); Map<String, Object> fontDesc = CidFontProperties.getAllFonts().get(fontNames.getFontName()); if (fontDesc == null) { throw new IOException("There is no such predefined font: {0}").setMessageParams(fontName); } initializeCidFontProperties(fontDesc); }