Convert EOT to TTF in Java.

Operating systems for all digital platforms use True Type Fonts (TTF). In order to add a special touch to web pages, Microsoft has introduced EOT fonts. Embedded Open Type fonts (EOT) are OpenType fonts embedded within a document. In certain cases, we may need to convert EOT fonts to TTF programmatically. In this article, we will learn how to convert EOT to TTF in Java.

The following topics shall be covered in this article:

  1. Java EOT to TTF Converter API
  2. Steps to Convert EOT to TTF
  3. Convert EOT to TTF using Java

Java EOT to TTF Converter API

We will be using the Aspose.Font for Java API for converting EOT to TTF. It allows loading, saving, and extracting font information from supported font types.

The API provides the FontFileDefinition class that represents the Font file definition. The FontDefinition class represents the Font file set definition. It contains fields that are not related to font internal data. These fields describe font placement and other data needed to load the font from some font source(file, memory, etc). We have the Font class which is the base Font class. It provides the open() method to open a font. It also allows saving the font using the save() method.

Please either download the JAR of the API or add the following pom.xml configuration in a Maven-based Java application.

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

Steps to Convert EOT to TTF

We can easily convert EOT font from .eot file to TTF format by following the steps given below:

  1. Load the font file.
  2. Create font definition as TTF.
  3. Open EOT font.
  4. Save the TTF to the desired location.

The following section describes how to transform these steps into Java and convert EOT to TTF.

Convert EOT to TTF using Java

We can convert EOT to TTF programmatically by following the steps given below:

  1. Firstly, load the font file using the FileSystemStreamSource class.
  2. Next, create an instance of the FontFileDefinition class with the source file object as an argument.
  3. Then, initialize the FontDefinition class object with Font type as TTF and FontFileDefinition object.
  4. After that, open the font using the Font.open() method with FontDefinition object as an argument.
  5. Finally, call the save() method to save it. It takes the output file path as an argument.

The following code sample shows how to convert EOT to TTF in Java.

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to convert Embedded Open Type fonts (EOT) to True Type fonts (TTF) in Java. Besides, you can learn more about Aspose.Font for Java API using documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also