Convert PFB to TTF using C#.

The Printer Font Binary (PFB) font is Adobe’s Type1 font. The Windows operating system uses Adobe Type 1 fonts stored in PFB files. In certain cases, we may need to convert PFB fonts to TTF programmatically. The True Type Font or TTF is used in operating systems for all digital platforms. In this article, we will learn how to convert PFB to TTF in C#.

The following topics shall be covered in this article:

  1. C# PFB to TTF Converter Font API
  2. Steps to Convert PFB to TTF
  3. Convert PFB to TTF using C#

C# PFB to TTF Converter Font API

For converting Type1 PFB font to TTF, we will be using the Aspose.Font for .NET API. It allows loading, saving, and extracting font information from supported font types.

In the API, the FontFileDefinition class represents the Font file definitions. The FontDefinition class represents the definition of the Font file set. It contains fields that are not part of the font’s internal data. A font source (file, memory, etc.) can be loaded from these fields to describe its placement and other data. The Font class is the base class for all Font classes. In order to open a font, it provides a method called Open(). It also allows saving the font into specified format using the SaveToFormat() method. The FontSavingFormats enumeration specifies Font types.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.Font

How to Convert PFB to TTF in C#

We can easily convert PFB font from .pfb file to TTF format using Aspose.Font for .NET by following the steps given below:

  1. Open PFB font.
  2. Specify the output settings for the TTF font.
  3. Save the TTF to the desired location.

The following section explains how to transform these steps into C# and convert PFB to TTF.

Convert PFB to TTF using C#

Please follow the steps given below to convert PFB to TTF programmatically in C#:

  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 Type1 and FontFileDefinition object.
  4. After that, open the font using the Font.Open() method with the FontDefinition object as an argument.
  5. Finally, call the SaveToFormat() method to save it. It takes the output file stream object and FontSavingFormats.TTF as arguments.

The following code sample shows how to convert PFB to TTF in 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 PFB Type1 fonts to True Type fonts (TTF) in C#. You can learn more about Aspose.Font for .NET API using documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also