Glyphs and Metrics of Type1 Fonts | Java

Get Font Metrics

Font metrics contain information such as Ascender, Descender, TypoAscender, TypoDescender and UnitsPerEm. Aspose.Font for Java API can read the Font Metrics information from the Type1 Font File using the following sample code.

 1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-Java
 2String fileName = Utils.getDataDir() + "courier.pfb"; //Font file name with full path
 3
 4FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName)));
 5      Type1Font font = (Type1Font) Font.open(fd);
 6
 7      String name = font.getFontName();
 8      System.out.println("Font name: " + name);
 9      System.out.println("Glyph count: " + font.getNumGlyphs());
10      String metrics = MessageFormat.format(
11          "Font metrics: ascender - {0}, descender - {1}, typo ascender = {2}, typo descender = {3}, UnitsPerEm = {4}",
12          font.getMetrics().getAscender(), font.getMetrics().getDescender(),
13          font.getMetrics().getTypoAscender(), font.getMetrics().getTypoDescender(), font.getMetrics().getUnitsPerEM());
14
15      System.out.println(metrics);

Detect Latin Symbols

Aspose.Font for Java lets you detect Latin Symbols from Type1 font files. This can be achieved using the following sample code.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.