Now you can easily generate your own TTF versions of the Terminus font

On in “Devstuff” by Tblue3 comments
Last updated: Sat, 12 June 2021 22:08 CEST
Tags: , , ,

More than 6 months ago, I wrote about generating TTF versions of the Terminus font (and published mine on that occasion), but I didn’t actually explain how to generate them.

I found the answer to my problem (“How do I get TTF files from the Terminus BDF source files?”) in the FontForge FAQ:

  • Create a new font.
  • Import the different sizes (one BDF file per font size). Make sure to import the BDF file with the biggest bitmaps into the glyph background!
  • Select all glyphs.
  • Autotrace them.
  • Add extrema.
  • Simplify all glyphs.
  • Save as TTF.

This process requires the AutoTrace program and FontForge, obviously. While repeating these steps at least two times (for the medium and bold versions of Terminus) is not that hard, I really like to automate things. I also wanted an italic version (I accomplished that by running the BDF files through mkitalic).

Fortunately, FontForge is scriptable! This allowed me to write a script in FontForge’s own “legacy” scripting language (the build I used didn’t support Python scripts…) to perform the steps described above, a small wrapper for AutoTrace to remove the obnoxious borders it adds to the resulting Postscript “images” and a small shell script wrapper that runs mkitalic to produce italic BDF files, tells FontForge to use my AutoTrace wrapper and finally runs the FontForge script for the three different font weights (medium, bold and italic).

Since I had to do some research to obtain the above information, I thought it would be nice to allow other people to easily generate TTF versions of Terminus (mind you, I might lose interest some day!). The scripts I wrote were only tested on unixoid systems (I didn’t test whether they correctly run on Windows, e. g. using Cygwin or CoLinux; they probably do, though).

Get the scripts here: https://github.com/Tblue/mkttf/archive/master.zip.

Also check out my Git repository on GitHub.

Read the included README file for information on how to use the mkttf.sh script. Feel free to post comments (questions, constructive criticism…)!

You might want to use these scripts to generate TTF versions of other fonts than Terminus, too; since the scripts are all fairly generic, it should be sufficient to modify mkttf.sh.

Have fun!


Comment by Mr.Cat

You’re the best! I found this solution and i’m happy!

I use Gentoo on my notebook and Terminus font used in the console. I switch rendering fonts type in X11 from “cleartype” to “lcdfilter”, but Terminus font do not work for this rendering type. I generated TTF Terminus and it work now with cyrillic symbols!

Comment by Infinality

Awesome script! Unfortunately I only found it AFTER I spent time figuring out some fontforge scripting. Still good though because now I know what I’m doing ;)

Here’s something I thought was worth bringing up: The way fontconfig/freetype renders fonts that contain outlines with embedded bitmaps is that if a size is requested for which a bitmap exists, it will use the bitmap. If a size is requested for which no bitmap exists, it will use the outline. This means that as you go through the sizes for this font, some will look great, and other will look like total crap. I figured out that if you completely remove the outlines, and only include embedded bitmaps, fontconfig will choose the best bitmap to display, for sizes that don’t have bitmaps. This way, no matter which font size you select, you will get a crisp, clean font.

In order for this to work, this has to be set for the font(s) in fontconfig:

<edit name="embeddedbitmap" mode="assign">
    <bool>true</bool>
</edit>

So, my request is that you allow an option in the mkttf.ff script to either autotrace an outline font, or to create no outline font at all. This will essentially allow everything good about a bitmap font to be included into the font, and nothing bad (i.e. weird outlines).

Comment by Tblue

Just for the record: Infinality found out that this requires even more special fontconfig rules than expected and additionally only seems to work correctly in Firefox (if I got that right). Thus, an option in mkttf.ff to disable outline generation would only be of limited use as it won’t automatically cause all applications to use the embedded bitmaps.