Convert Type1 font to TrueType | Java API Solution
Overview
This article explains how to convert Type1 font to TTF using Java. It covers the following topics.
- Understanding Type 1 fonts and their use in PostScript
- Java How to convert Type1 font to TrueType
- Java Type1 to TTF example
Understanding Type 1 fonts and their use in PostScript
Type 1 fonts, developed by Adobe in the 1980s, are a key component of digital typography, particularly in the realm of desktop publishing and graphic design. These fonts are widely recognized for their high-quality rendering and compatibility with the PostScript page description language, which revolutionized the printing industry.
What are Type 1 fonts?
Type 1 fonts are a vector-based font format that allows for scalable and high-resolution text rendering. They consist of two main files: the outline file (with a .PFB extension) that contains the font’s vector outlines, and the metric file (with a .AFM extension) that provides information about the font’s metrics, such as character widths and kerning data. This separation of outlines and metrics allows for efficient storage and manipulation of font data. However .PFB files can be used without *.AFM files.
Advantages of Type 1 fonts
Scalability: Being vector-based, Type 1 fonts can be resized without loss of quality, making them ideal for various applications, from small text to large banners.
Precision: The mathematical definitions of Type 1 fonts enable precise rendering, ensuring that type appears sharp and clear on printed materials.
Wide Compatibility: Type 1 fonts are widely supported in Adobe applications and are integral to the PostScript language, making them a standard choice for professional typesetting.
Rich Features: Type 1 fonts support advanced typographic features, including kerning and ligatures, enhancing the overall aesthetic of printed text.
Type 1 fonts in PostScript
Type 1 fonts are integral to PostScript because they provide the necessary information for rendering high-quality text. When a PostScript file is processed, the instructions for displaying text are linked to the corresponding Type 1 font files.
In a PostScript document, text is defined using commands that reference Type 1 fonts. For example, a command can specify the font to use, the size, and the position of the text. The PostScript interpreter then uses the information from the Type 1 font files to accurately render the text on the output device, whether it be a laser printer or an image setter.
Java How to convert Type1 font to TrueType
In order to convert a given Type1 font, the file containing it must contain only that font and nothing else. This can be a PFB file or a PS file containing only the font. Actually, that’s all you need for conversion.
So there are only two steps for converting Type1 font to TrueType in Java follows:
- Create new PsDocument object.
- Convert input Type1 font to TTF with the static method convertType1FontToTTF.
You can check the Type1 font to TTF conversion functionality online on our Type1 Converter web application.
Convert Type1 to TTF in Java
In the following Java code snippet we convert Type1 font to TrueType font:
1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
2
3// The path to the documents directory.
4String dataDir = getDataDir();
5
6//Create new PsDocument object
7PsDocument doc = new PsDocument();
8
9//Convert Type1 font from the file 'Type1_Arial_Bold.ps' to TTF font in dataDir folder.
10//Exstension of file can be ".ps", ".pfb", ".pfa" or something else. The main thing is that there is only a font Type1 inside.
11doc.convertType1FontToTTF(dataDir + "Type1_Arial_Bold.ps", dataDir);
Evaluate conversion of Type1 font to TTF online via Convert Type1 font web application. You can convert Type1 font to TTF and dowload result in a few seconds.
You can download examples and data files from GitHub.