After verifying with friends that eBook readers do a decent job of rendering
technical content I purchased a Kobo Libra 2 this week. I loaded up some books
and started reading… but something was off. Sure enough, after verifying the
EPUB with Calibre on my computer I confirmed that the Kobo was not rendering
text with CSS rules like font-family: monospace
in a monospace font.
Update Aug 2022: I was told and have confirmed myself that the workaround described in this post no longer works with the latest firmware. I tested version 4.33.19759. If anyone knows how to restore the behaviour please get in touch.
I quickly discovered this is a known issue with Kobo readers dating back years: for reasons I can’t comprehend they do not include a monospace font on the device. I read many forum posts about how to add fonts but these were centred around adding fonts to the font selector for the body text. Eventually I found the solution via a summary of the release notes for a firmware update in 2019:
Path for monospace font changed to match other fonts and name is “Courier”. This should mean that any correctly sideloaded font whose name starts with “Courier” will be used when the monospace font face is specified.
With this knowledge in hand I was able to make it render monospace text in the one true monospace font, PragmataPro:
Instructions
- Connect the Kobo to your computer.
- Create a folder in the root of the device named
fonts
. - Put your chosen monospace font in the
fonts
folder. - Rename the fonts to follow this naming convention:
Courier <Font Family>-<Font Weight>.ttf
.- The leading
Courier
is required for the eReader to use the font for monospace text in books and not just show the font as an option in the reading settings.
- The leading
For example I renamed the PragmataPro font files to:
Courier PragmataPro Mono-Regular.ttf
Courier PragmataPro Mono-Bold.ttf
Courier PragmataPro Mono-Italic.ttf
Courier PragmataPro Mono-BoldItalic.ttf
I read in a forum thread that it’s important that the fonts be named like this with the actual font family name and the font weight names for them to work. GNOME Font Viewer in freedesktop.org environments or Font Book on macOS, or allsorts-tools on all platforms can show you the font family name for a font.
Happy reading!