Convert WOFF to TTF using C#.

The True Type Font or TTF is used in operating systems for all digital platforms. In the previous post, we have seen how to convert TTF to web fonts. The Web Open Font Format or simply WOFF is a web font mostly used on web pages. In certain cases, we may also need to convert Web fonts to true-type fonts. In this article, we will learn how to convert WOFF to TTF using C#.

The following topics shall be covered in this article:

WOFF to TTF Converter C# API

For converting WOFF to TTF, we will be using the Aspose.Font for .NET API. It allows loading, saving, and extracting information from supported font types. Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.Font

Convert WOFF to TTF using C#

We can easily convert Web Open Fonts (WOFF) to True Type Fonts (TTF) 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 file extension as “woff” and the source file object as arguments.
  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 argument.
  5. Finally, call the SaveToFormat() method to save it. It takes the output file path and FontSavingFormats to TTF as arguments.

The following code sample demonstrates how to convert WOFF to TTF using C#.

Convert WOFF2 to TTF in C#

We can also convert WOFF2 to TTF by following the steps mentioned earlier. However, we just need to set the file extension as “woff2” in the second step.

The following code sample demonstrates how to convert WOFF2 to TTF using C#.

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 Web Open Fonts to True Type Fonts in C#. We have also seen how to save WOFF2 as TTF programmatically. Besides, you can learn more about Aspose.Font for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also