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:
C# PFB to TTF Converter Font API
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.
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:
- Open PFB font.
- Specify the output settings for the TTF font.
- 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#:
- Firstly, load the font file using the FileSystemStreamSource class.
- Next, create an instance of the FontFileDefinition class with the source file object as an argument.
- Then, initialize the FontDefinition class object with Font type as Type1 and FontFileDefinition object.
- After that, open the font using the Font.Open() method with the FontDefinition object as an argument.
- 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.
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.