For those who deal with writing or design projects, it's common to come across a font that your application can't support. It could be a Macintosh font, a bitmap font, or an open type font (otf). For one reason or another, you can't get your Ubuntu machine to read it. In such cases, the best way is to convert these fonts to the ttf format. In Ubuntu, TrueType (ttf) stands for
Fontforge It is a detailed font editor that allows you to create your own footer, truetype, opentype, cid-keyed, multi-master, cff, svg, and bitmap (bdf, ftp, ffnt) fonts. It also allows you to edit existing formats and convert one format to another.
Install Fontforge
The program is available in the apt repository for Ubuntu, so you can easily install the program by running the following command:
sudo apt install fontforge
Convert fonts in Ubuntu using FontForge
- After installing FontForge , Click on Win key , then type “fontforge”.
- Click icon Fontforge to turn it on.
- Once Fontforge is up and running, load the font you want to convert. This will load a preview of all the glyphs available for your font file.
- push the button "a file" In the Fontforge menu bar, select “Create fonts”This will open a small dialog box with a drop-down list where you can select the format you want to convert to.
- Locate TrueType.
- push the button "construction" In the lower left corner of the dialog box.
- Depending on the source file, it may produce some error messages. Click "Yeah" To continue the conversion process.
Using Fontforge's Command Line Interface (CLI) to convert fonts
In addition to running the Fontforge GUI, it's also possible to use the program to convert fonts from within your device. This can be particularly useful for users who want to create scripts that can quickly and automatically convert fonts.
By default, the CLI allows you to run Fontforge-specific functions. For example, running the following command will automatically convert an OTF font to TTF:
fontforge -lang=ff -c 'Open($1); Generate($2);' original-font.otf converted-font.ttf
- The mark tells -lang=ff Fontforge Using only its built-in functions for this.
- On the other hand, the tag will be loaded. -c and run the Fontforge functions built into your terminal. In this case, the function Open() Loads your font file into memory and it will create () Convert it to the format you want.
- Finally, you need to provide the path to both the original font and the converted font. For this, you also need to enter the appropriate file extensions for both fonts. This means that if you are converting from O.T.F. To FTT , then you need to write “.otf” At the end of the original line and “ttf.” At the end of the converted line.
for i in *.otf; do fontforge -lang=ff -c 'Open($1); Generate($1:r+".ttf");' $i; done. done
Convert fonts using woff2
While Fontforge is a powerful font editing program, it doesn't convert some common font types correctly. For example, WOFF2 is a format used by most websites today. As such, it can be a problem for users who want to use web fonts in their local documents.
To convert WOFF2 fonts, you first need to install the appropriate utilities. You can do this by running the following command:
sudo apt install woff2
Once you've done this, you can now convert your WOFF2 font to TTF:
woff2_decompress font.woff2
Similar to Fontforge CLI, you can: Create a basic script To automate the process of converting WOFF2 fonts, for example, the following line of code will loop through all fonts in the current directory and convert them to TTF:
for i in *.woff2; do woff2_decompress $i; done. done
Install your new font
With your new fonts available, you can now install them on your system. To do this, first navigate to your home directory:
cd /home/$USER
Create new folder and name it “.font” (Include the dot in front of the line) and copy the new ttf line into the folder:
mkdir .font && cp font.ttf /home/$USER/.font
Restart the application or reload the font cache. To do the latter, run the following command:
sudo fc-cache reload
The device should now be able to detect the new line.
Frequently Asked Questions
Q1. Is it possible to convert fonts back to WOFF2 format?
answer. You can convert any TTF fonts to WOFF2 using the command: woff2_compress font.ttf.
Q2. My fonts are not showing up after I converted them.
answer. The most common reason is that your device is missing the appropriate local setting.
You can solve this problem by adding the following line: export LC_ALL=en_US.UTF-8 to your .bash_profile file.