final String FONT = "c:/windows/... .ttf"; BaseFont bf = BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); document.add(new Paragraph("Font: " + bf.getPostscriptFontName() + " with encoding: " + bf.getEncoding()));
/** Gets all the names from the font. Only the required tables are read. * @param name the name of the font * @param encoding the encoding of the font * @param ttfAfm the true type font or the afm in a byte array * @throws DocumentException on error * @throws IOException on error * @return an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()} */ public static Object[] getAllFontNames(String name, String encoding, byte ttfAfm[]) throws DocumentException, IOException { String nameBase = getBaseName(name); BaseFont fontBuilt = null; if (nameBase.toLowerCase().endsWith(".ttf") || nameBase.toLowerCase().endsWith(".otf") || nameBase.toLowerCase().indexOf(".ttc,") > 0) fontBuilt = new TrueTypeFont(name, CP1252, false, ttfAfm, true, false); else fontBuilt = createFont(name, encoding, false, false, ttfAfm, null); return new Object[]{fontBuilt.getPostscriptFontName(), fontBuilt.getFamilyFontName(), fontBuilt.getFullFontName()}; }
/** Gets all the names from the font. Only the required tables are read. * @param name the name of the font * @param encoding the encoding of the font * @param ttfAfm the true type font or the afm in a byte array * @throws DocumentException on error * @throws IOException on error * @return an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()} */ public static Object[] getAllFontNames(String name, String encoding, byte ttfAfm[]) throws DocumentException, IOException { String nameBase = getBaseName(name); BaseFont fontBuilt = null; if (nameBase.toLowerCase().endsWith(".ttf") || nameBase.toLowerCase().endsWith(".otf") || nameBase.toLowerCase().indexOf(".ttc,") > 0) fontBuilt = new TrueTypeFont(name, CP1252, false, ttfAfm, true, false); else fontBuilt = createFont(name, encoding, false, false, ttfAfm, null); return new Object[]{fontBuilt.getPostscriptFontName(), fontBuilt.getFamilyFontName(), fontBuilt.getFullFontName()}; }
String fullName = bf.getFullFontName()[0][3].toLowerCase(); String familyName = bf.getFamilyFontName()[0][3].toLowerCase(); String psName = bf.getPostscriptFontName().toLowerCase(); registerFamily(familyName, fullName, null); trueTypeFonts.put(psName, path);
String fullName = bf.getFullFontName()[0][3].toLowerCase(); String familyName = bf.getFamilyFontName()[0][3].toLowerCase(); String psName = bf.getPostscriptFontName().toLowerCase(); registerFamily(familyName, fullName, null); trueTypeFonts.put(psName, path);
for (int i = 0; i < 4; i++) { bf = BaseFont.createFont(FONT, MOVIES[i][0], BaseFont.EMBEDDED); document.add(new Paragraph("Font: " + bf.getPostscriptFontName() + " with encoding: " + bf.getEncoding())); document.add(new Paragraph(MOVIES[i][1]));
if (baseFont.getPostscriptFontName().toLowerCase().indexOf("bold") < 0) {
@Override protected void checkFont(PdfWriter writer, int key, Object obj1) { BaseFont bf = (BaseFont) obj1; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { PdfStream prs = null; PdfDictionary fontDictionary = ((DocumentFont) bf).getFontDictionary(); PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR)); if (fontDescriptor != null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE)); if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2)); } if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3)); } } if (prs == null) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } } else { if (!bf.isEmbedded()) throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } }
@Override protected void checkFont(PdfWriter writer, int key, Object obj1) { BaseFont bf = (BaseFont) obj1; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { PdfStream prs = null; PdfDictionary fontDictionary = ((DocumentFont) bf).getFontDictionary(); PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR)); if (fontDescriptor != null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE)); if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2)); } if (prs == null) { prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3)); } } if (prs == null) { throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } } else { if (!bf.isEmbedded()) throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont) obj1).getPostscriptFontName())); } }
/** * Set the font and the size for the subsequent text writing. * * @param bf the font * @param size the font size in points */ @Override public void setFontAndSize(BaseFont bf, float size) { checkWriter(); state.size = size; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { state.fontDetails = new FontDetails(null, ((DocumentFont)bf).getIndirectReference(), bf); } else state.fontDetails = writer.addSimple(bf); PdfName psn = stdFieldFontNames.get(bf.getPostscriptFontName()); if (psn == null) { if (bf.isSubset() && bf.getFontType() == BaseFont.FONT_TYPE_TTUNI) psn = state.fontDetails.getFontName(); else { psn = new PdfName(bf.getPostscriptFontName()); state.fontDetails.setSubset(false); } } PageResources prs = getPageResources(); // PdfName name = state.fontDetails.getFontName(); prs.addFont(psn, state.fontDetails.getIndirectReference()); content.append(psn.getBytes()).append(' ').append(size).append(" Tf").append_i(separator); }
/** * Set the font and the size for the subsequent text writing. * * @param bf the font * @param size the font size in points */ @Override public void setFontAndSize(BaseFont bf, float size) { checkWriter(); state.size = size; if (bf.getFontType() == BaseFont.FONT_TYPE_DOCUMENT) { state.fontDetails = new FontDetails(null, ((DocumentFont)bf).getIndirectReference(), bf); } else state.fontDetails = writer.addSimple(bf); PdfName psn = stdFieldFontNames.get(bf.getPostscriptFontName()); if (psn == null) { if (bf.isSubset() && bf.getFontType() == BaseFont.FONT_TYPE_TTUNI) psn = state.fontDetails.getFontName(); else { psn = new PdfName(bf.getPostscriptFontName()); state.fontDetails.setSubset(false); } } PageResources prs = getPageResources(); // PdfName name = state.fontDetails.getFontName(); prs.addFont(psn, state.fontDetails.getIndirectReference()); content.append(psn.getBytes()).append(' ').append(size).append(" Tf").append_i(separator); }
if (dao[DA_FONT] != null) { BaseFont bf = (BaseFont)value; PdfName psn = PdfAppearance.stdFieldFontNames.get(bf.getPostscriptFontName()); if (psn == null) { psn = new PdfName(bf.getPostscriptFontName());
if (dao[DA_FONT] != null) { BaseFont bf = (BaseFont)value; PdfName psn = PdfAppearance.stdFieldFontNames.get(bf.getPostscriptFontName()); if (psn == null) { psn = new PdfName(bf.getPostscriptFontName());
case PdfIsoKeys.PDFISOKEY_FONT: if (!((BaseFont)obj1).isEmbedded()) throw new PdfXConformanceException(MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont)obj1).getPostscriptFontName())); break; case PdfIsoKeys.PDFISOKEY_IMAGE:
case PdfIsoKeys.PDFISOKEY_FONT: if (!((BaseFont)obj1).isEmbedded()) throw new PdfXConformanceException(MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", ((BaseFont)obj1).getPostscriptFontName())); break; case PdfIsoKeys.PDFISOKEY_IMAGE: