
font2c Command in Linux
The font2c command converts PostScript Type 0 and Type 1 fonts into C code. It is part of the GhostScript package. This tool primarily converts fonts to C code to be embedded in applications.
Table of Contents
Here is a comprehensive guide to the options available with the font2c command −
- Syntax of font2c Command
- Options font2c Command
- Formats of PostScript Fonts
- Using font2c Command in Linux
Note: The PostScript fonts are developed by Adobe to be used with the PostScript printer. The PostScript Type 0 and Type 1 fonts are largely replaced by TTF and OTF fonts. Therefore, the font2c command is deprecated and removed from the recent version of GhostScript.
Syntax of font2c Command
The syntax of the Linux font2c command is as follows −
font2c [fontnames]
The [fontnames] field is used to specify the font name that needs to be converted to C code.
Options font2c Command
The options of the font2c command are listed below −
Options | Description |
---|---|
-q | It suppresses the startup messages. |
-dNODISPLAY | It prevents GhostScript from printing any graphical output. |
-dWRITESYSTEMDICT | It allows writing to the system dictionary (restricted by default). |
Formats of PostScript Fonts
PostScript Type 0 font files do not have an extension. They are defined within PostScript code and in PDF structures. However, the Type 1 font files have extensions.
The common file formats of PostScript fonts are listed below −
- .afm file
- .pfa file
- .pfb file
Using font2c Command in Linux
This section demonstrates the usage of the font2c command in Linux with examples −
- Converting a PostScript Font to C Code
- Converting Multiple PostScript Fonts to C Code
- Converting a PostScript Font to C Code Using Options
Converting a PostScript Font to C Code
To convert a PostScript font to C code, use the font2c command with the font name −
font2c slick.pfb
The above command converts the slick.pfb font to C code in the current working directory.
Converting Multiple PostScript Fonts to C Code
To convert multiple PostScript fonts to C code, simply pass the font names separated by a space to the font2c command −
font2c slick.pfb OpenSans-Regular.pfb
The above command converts both fonts to C codes in the current working directory.
Converting a PostScript Font to C Code Using Options
To convert a PostScript font to C code using the -q, -dNODISPLAY, -dWRITESYSTEMDICT options, use the font2c command in the following way −
font2c -q -dNODISPLAY -dWRITESYSTEMDICT slick.pfb
The -q option suppresses the output messages, the -dNODISPLAY option prevents any graphical output, and -dWRITESYSTEMDICT enables writing to the system dictionary.
Conclusion
The font2c command in Linux is used to convert the PostScript Type 0 and Type 1 fonts to C code. The C code of fonts helps embed them directly in applications. It is part of GhostScript.
PostScript fonts have been replaced with modern fonts such as TTF and OTF. However, if you are still using older fonts, then this utility can be handy.
In this tutorial, we explained the font2c command, its syntax, options, and usage in Linux with examples.