/glcd-font-extractor

Generates you to use different fonts for the Adafruit GFX LED Matrix Library

Primary LanguagePythonMIT LicenseMIT

GLCD Font Extractor for Adafruit GFX LED Matrix Library

Allows you to use different fonts for a matrix LED display

The Adafruit-GFX-Library only comes with one font. This script takes a TTF "Bitmap Font" and rasterizes it into a C++ array format suitable for use with the Adafruit-GFX-Library for use and tested on MAX7219 dot matrix LED modules.

For more information on the format of the font and how the glcdfont.c works and is constructed, see Smart Interaction Lab's article on Customizing Adafruit’s 32×32 LED Matrix.

Caveats and Notes

  1. You may need licensing permission to do this to a font you don't own.
  2. It will not work on non-bitmap, anti-aliased fonts e.g. Times New Roman, as it won't be able to detect clean edges of the font.
  3. Mono-spaced fonts will also give you better, more even spacing/kerning.
  4. Alternative: This UI-based font creator might work for you instead - GLCD Font Creator.

Installation

  1. Clone repo or download zip.
  2. Install dependencies via requirements.txt e.g. pip install -r requirements.txt

Usage

To create a pixel font array out of gameboy.ttf and write it to a file, run:

font-extractor/font-extractor.py test/fonts/gameboy.ttf --output=glcdfont.c --default-array-size

This example will output a partial glcdfont.c whose contents can be copied and pasted into array section of you glcdfont.c file in your Adafruit-GFX-Library location e.g. ~/Documents/Arduino/libraries/Adafruit-GFX-Library-master

You can run font-extractor.py for a list of all arguments.