Xteink-X4-crosspoint-reader/docs/FONT_CONVERSION.md

2.7 KiB

Font Conversion Guide

To use custom fonts with the CrossPoint Reader, you must convert standard .ttf or .otf font files into the specific .epdfont binary format used by the compiled firmware.

Supported Formats

The CrossPoint Reader supports two versions of the .epdfont format:

  1. Version 1 (Recommended): The newer, optimized format generated by the web converter.
  2. Version 0 (Legacy): The original format generated by the Python script.

The easiest way to generate compatible fonts is using the online converter.

  1. Go to https://epdfont.clev.app/.
  2. Select your .ttf or .otf file.
  3. Choose the font size (e.g., 18).
  4. Download the generated .epdfont file.

Filename Requirements

The firmware scans for fonts in the /fonts directory on the SD card. It attempts to parse the filename to determine the Font Family, Style, and Size.

For best results, rename your downloaded file to match one of these patterns:

  • Family_Style_Size.epdfont (e.g., Aileron_Regular_18.epdfont)
  • Family-Style-Size.epdfont (e.g., LibreBaskerville-Bold-14.epdfont)

Supported Styles:

  • Regular
  • Bold
  • Italic
  • BoldItalic

Note: If you download a file named just Aileron.epdfont, the reader will try to load it, but using the explicit naming convention above ensures the correct style and size are recognized.

Method 2: Python Script (Improved)

You can also use the included Python script located at lib/EpdFont/scripts/fontconvert.py. This script has been recently updated to ensure high-precision metric calculations (fixing issues with spacing and em-dashes).

Requirements

  • Python 3
  • freetype-py library (pip install freetype-py)

Usage

Run the script from the project root:

python3 lib/EpdFont/scripts/fontconvert.py --binary [Family-Style-Size] [Size] [PathToFont]

Arguments

  1. name: The output filename (without extension). Convention: Family-Style-Size (e.g. Bookerly-Regular-12).
  2. size: The integer point size (e.g. 12).
  3. fontstack: Path to the source font file (e.g. fonts/Bookerly-Regular.ttf).
  4. --binary: REQUIRED. Flags the script to output the .epdfont binary instead of a C header.

Example

To convert Bookerly-Regular.ttf to a size 12 font:

python3 lib/EpdFont/scripts/fontconvert.py --binary Bookerly-Regular-12 12 fonts/Bookerly-Regular.ttf

This will generate Bookerly-Regular-12.epdfont in your current directory.

Installing on Device

  1. Copy your generated .epdfont files to the /fonts directory on your SD card.
  2. Restart the CrossPoint Reader.
  3. Go to Settings -> Set Custom Font Family to select your loaded fonts.