Files
kobo-font-fix/README.md
Nico Verbruggen eee6b0d739 Max 10k pairs per kern subtable (Fixes #1)
- Fixes script
- Adds kern diff script to compare fonts to helpers
- Moved ttfconv to helpers folder
- Updated README
2025-08-22 11:16:03 +02:00

2.6 KiB

Kobo Font Fix

Overview

kobofix.py is a Python script designed to process TTF fonts for Kobo e-readers.

It generates a renamed font, fixes PANOSE information based on the filename, adjusts the baseline with the font-line utility, and adds a legacy kern table which allows the kepub engine for improved rendering of kerned pairs.

You can use this to modify or fix your own, legally acquired fonts (assuming you are permitted to do so).

Requirements

Python 3, FontTools, font-line.

You can install them like so:

pip3 install fonttools
pip3 install font-line

On macOS, if you're using the built-in version of Python (via Xcode), you may need to first add a folder to your PATH to make font-line available, like:

echo 'export PATH="$HOME/Library/Python/3.9/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Usage

  1. Open a terminal and navigate to the directory containing your font files.

  2. Run the script with a glob pattern to include all TTF files:

    python3 kobofix.py *.ttf
    
  3. The default script will:

    • Validate the file names (must end with -Regular, -Bold, -Italic or -BoldItalic so they're valid for Kobo devices).
    • Process each font (e.g. "Lora" becomes "KF Lora").
    • Apply kerning, rename, PANOSE adjustments, and baseline shift.
    • Save output as KF_<original_filename>.

You can customize what the script does.

Customization

Generating KF fonts

This applies the KF prefix, applies 20 percent line spacing and adds a Kobo kern table. Ideal if you have an existing TrueType font and you want it on your Kobo device.

The --name parameter is used to change the name of the font family.

./kobofix.py --prefix KF --name="Fonty" --line-percent 20 *.ttf

To process fonts from my ebook-fonts collection which are prefixed with "NV", you can replace the prefix and make adjustments in bulk.

To process all fonts with the "Kobo Fix" preset, simply run:

./kobofix.py --prefix KF --remove-prefix="NV" --line-percent 0 *.ttf

(In this case, we'll set --line-percent to 0 so the line height changes aren't made, because the fonts in the NV Collection should already have those changes applied.)

Generating NV fonts

Tight spacing, with a custom font family name:

./kobofix.py --prefix NV --name="Fonty" --line-percent 20 --skip-kobo-kern *.ttf

Relaxed spacing, with a custom font family name:

./kobofix.py --prefix NV --name="Fonty" --line-percent 50 --skip-kobo-kern *.ttf

You can play around with --line-percent to see what works for you.