PdfTrueTypeFont extends PdfSimpleFont<TrueTypeFont> { @Override public Glyph getGlyph(int unicode) { if (fontEncoding.canEncode(unicode)) { Glyph glyph = getFontProgram().getGlyph(fontEncoding.getUnicodeDifference(unicode)); if (glyph == null && (glyph = notdefGlyphs.get(unicode)) == null) { Glyph notdef = getFontProgram().getGlyphByCode(0); if (notdef != null) { glyph = new Glyph(getFontProgram().getGlyphByCode(0), unicode); notdefGlyphs.put(unicode, glyph); } } return glyph; } return null; } PdfTrueTypeFont(TrueTypeFont ttf, String encoding, boolean embedded);   PdfTrueTypeFont(PdfDictionary fontDictionary); @Override Glyph getGlyph(int unicode); @Override boolean containsGlyph(int unicode); @Override void flush();  }
@Test public void testReadingPdfTrueTypeFontWithType1StandardFontProgram() throws IOException { String filePath = SOURCE_FOLDER + "trueTypeFontWithStandardFontProgram.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(filePath)); PdfDictionary fontDict = pdfDocument.getPage(1).getResources().getResource(PdfName.Font).getAsDictionary(new PdfName("F1")); PdfFont pdfFont = PdfFontFactory.createFont(fontDict); Assert.assertEquals(542, pdfFont.getFontProgram().getAvgWidth()); Assert.assertEquals(556, pdfFont.getGlyph('a').getWidth()); }