Detect Latin Symbols in TrueType and Type1 Fonts using Java

Fonts are a set of printable or displayable characters with different styles, weights, etc. They are used to add a different look and feel to documents or web pages based on different requirements. Font files contain the design and other information regarding the font. In this article, we will use the font files to detect whether a font supports Latin symbols or not programmatically with Java.

Java API for Detecting Latin Symbols in TrueType and Type1 Fonts

Aspose.Font for Java is a library for working with fonts such as TrueType, CFF, Type1, etc. The API supports loading, saving, and extracting information regarding fonts. The API also lets you detect the support for Latin symbols in fonts. You can either download the API using Maven or download the JAR from the downloads section.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-font</artifactId>
    <version>21.4</version>
</dependency>

Detect Latin Symbols in TrueType Fonts using Java

The following are the steps to detect if a particular TrueType font supports Latin symbols or not.

  • Create an instance of the FontDefinition class using the font file.
  • Create an instance of the TtfFont class using the object of FontDefinition created in the previous step.
  • Loop through the different codes and decode them into glyph IDs.
  • Check the glyph IDs for the support of Latin symbols.

The following sample code shows how to detect if a particular TrueType font supports Latin symbols or not.

Detect Latin Symbols in Type1 Fonts using Java

The process for detecting support for Latin symbols in Type1 fonts is similar to TrueType fonts. The only difference is that we will use the Type1Font class to access the font information. The following are the steps to detect the support for Latin symbols in Type1 fonts.

  • Create an instance of the FontDefinition class using the font file.
  • Create an instance of the Type1Font class using the object of FontDefinition created in the previous step.
  • Loop through the different codes and decode them into glyph IDs.
  • Check the glyph IDs for the support of Latin symbols.

The following sample code shows how to detect if a particular Type1 font supports Latin symbols or not.

Get a Free License

In order to try the API without evaluation limitations, you can request a free temporary license.

Conclusion

In this article, you have learned how to detect the support for Latin symbols in fonts using Java. The shared code samples enable you to detect whether a particular font supports Latin symbols or not. Aspose.Font for Java provides many additional features for working with fonts that you can explore in detail by visiting the official documentation. In case of any questions, please feel free to reach us at our free support forum.

See Also