OpenType fonts have font features or variants that you can use to represent certain characters differently.
For example, my beloved IBM Plex Mono1 has quite a few alternative glyphs to pick from:
I prefer the single story “g” and slashed “0” characters for clarity. But you’ll find no obvious way to turn these version of the characters on permanently. After searching and trying quite a few ways to do this, I found an approach that works pretty well.
This blog post will explain how you can pick alternative characters that come with certain open type fonts like IBM Plex Mono and build a version of the font that will permanently switch these alternative character variants on.
Step 1: obtain the complete .otf font file
It’s important to have your source .otf
file have the complete list of characters. If your font doesn’t have these to begin with, this approach will not work. As an example, IBM Plex Mono’s full otf can be downloaded here.
Step 2: identify the alternative character sets you want
Upload your font to wakamaifondue.com. You’ll get a neat summary of your font and all the available features variants.
Step 3: use pyftfeatfreeze
pyftfeatfreeze is a fantastic open source tool that allows you to create a new version of your font with the specific set of alternative characters chosen.
Here’s the entire set of commands I used to generate my variant of IBM Plex Mono:
#!/bin/zsh
fontSuffix="KG"
# create a new directory for your font
mkdir -p "IBM-Plex-Mono-$fontSuffix"
# change to directory that has original otf font
cd IBM-Plex-Mono
# install the tool
pipx install opentype-feature-freezer
# Pick the right combination of stylistic characters
# By default IBM Plex Mono ships:
# Regular - styled g; styled a (with caps)
# Italic - plain g ; plain a (without cap)
# I prefer keeping it all consistent
# so I change my italic fonts to also have the styled versions of g/a
# In the non-italic versions of IBM Plex Mono, change
# ss03 - slashed 0
for f in $(fd -HI ibmplexmono -e otf -E '*Italic.otf'); do
pyftfeatfreeze -f "ss03" -R "Mono/Mono $fontSuffix" -v $f "${f%.otf}.kg.otf"
done
# In the italicized versions of IBM Plex Mono, change
# ss01 - use stylistic variant of a (with the hat)
# ss02 - use g with a cap
# ss03 - slashed 0
for f in $(fd -HI Italic.otf -e otf); do
pyftfeatfreeze -f "ss03,ss01,ss02" -R "Mono/Mono $fontSuffix" -v $f "${f%.otf}.kg.otf"
done
# cleanup, rename and open the directory
mv *.kg.otf ../"IBM-Plex-Mono-$fontSuffix"/
cd ../"IBM-Plex-Mono-$fontSuffix"/
for f in *.kg.otf; do
mv $f "$(echo "$f" | sed s/"\.kg"/"-$fontSuffix"/)"
done
open .
I’ve created a repo
Double click the fonts and you have a customized version of IBM Plex Mono installed!
Bonus
If you just want the same version of IBM Plex Mono that I use, install it from my homebrew tap directly:
brew tap kaushikgopal/tools
brew install --cask font-ibm-plex-mono-kg
-
which I continue to use as my preferred monospace font for programming. ↩︎