Choosing the right font for the display is always a difficult task. Especially for small displays there is only a limited number of fonts available and often they come from the display manufacturer and have some restrictions on their library. On the other hand there are nearly unlimited true type fonts available on your computer.
So I wrote a converter.
My display EA DOGM128-6 comes with a library. This library doesn't map the display content in its memory but writes it directly to the display and uses the memory of the display controller. The advantage of this behavior is that it only needs very little RAM. The downside is that always 8 vertical bits of the display have to be written. So everything is aligned to multiples of 8 and nothing overlaps.
This is also true for the font files. The fonts are always multiples of 8 high and additionally all characters have the same width (monospaced font).
The converter uses the FreeType library (https://www.freetype.org/ ) and is intended to run on Linux. On my machine I use Ubuntu.
The converter accepts any font which is supported by FreeType. This should be any font available on a Linux system. Also most of these fonts come with an open source license. So licensing shouldn't be an issue any more. Generating display fonts which are only 8 bits high is a little bit tricky as most fonts don't scale down very good. Generating fonts with 16 bit height works very well. The converter accepts the following arguments
usage: -f <path to file> path to file with font -n <name> name for header file with font and name of font constant -s <number> font-size -b <number> baseline for the font in pixels from top -g <number> height of font in bytes for generated file -d printf debug messages -h print this help
Name is only the name for the generated file and font and can be chosen randomly. Font size should be chosen according to the height of the font in bits. If the font is 16 bits high a font size of 16 is a good start. But not all fonts scale evenly and this has to be adjusted to get the optimal size. Also the baseline of the font can be set. The baseline should be somewhere in the lower quarter of the hieght. So if the font is 16 bits high then the baseline should be at the 12th bit from top. But this can also be adjusted for optimal size.
The source code and makefile for the converter are available on github: https://github.com/generationmake/freetypeconverter
This is an example font file (16 bit high) generated from the font UbuntuMono-B.ttf:
/* file generated by freetype converter 0.1 - 2019-06-23 */ /* find the latest version on https://github.com/generationmake/freetypeconverter */ /* converter called with: */ /* ./freetypeconverter -n UBUNTUMONO_B_16 -f /usr/share/fonts/truetype/ubuntu/UbuntuMono-B.ttf */ #define UBUNTUMONO_B_16_LEN 1528 const byte UBUNTUMONO_B_16[UBUNTUMONO_B_16_LEN] __attribute__((section(".progmem.data"))) = { 70,86,0x20,0x7E,8,16,2,16, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,0x00,0x00,0x00, 0x3E,0x3E,0x00,0x3E,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x30,0x30,0xF0,0x3C,0xF0,0xFC,0x3C,0x30,0x03,0x0F,0x03,0x0F,0x0F,0x03,0x03,0x03, 0x70,0xF8,0xDE,0xDE,0x98,0x18,0x00,0x00,0x06,0x0C,0x3C,0x3D,0x0F,0x07,0x00,0x00, 0x3C,0x24,0x3C,0xC0,0x30,0x08,0x04,0x00,0x08,0x06,0x01,0x00,0x0F,0x09,0x0F,0x00, 0x00,0xB8,0x7C,0xCC,0xBC,0x18,0xC0,0x00,0x07,0x0F,0x0C,0x0C,0x0F,0x07,0x0F,0x0C, 0x3E,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xE0,0xF8,0x1C,0x06,0x02,0x00,0x00,0x00,0x07,0x1F,0x38,0x70,0x20,0x00,0x00,0x00, 0x02,0x06,0x0C,0x18,0xF0,0xE0,0x00,0x00,0x00,0x60,0x30,0x3C,0x0F,0x07,0x00,0x00, 0x30,0xB0,0xE0,0x7C,0xE0,0xB0,0x30,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00, 0x80,0x80,0x80,0xF0,0xF0,0x80,0x80,0x80,0x01,0x01,0x01,0x0F,0x0F,0x01,0x01,0x01, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x6E,0x3E,0x1E,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x04,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xC0,0xF8,0x3E,0x06,0x00,0x00,0x60,0x7E,0x1F,0x01,0x00,0x00,0x00,0x00, 0xF0,0xFC,0xCC,0xCC,0xFC,0xF0,0x00,0x00,0x03,0x0F,0x0C,0x0C,0x0F,0x03,0x00,0x00, 0x10,0x18,0x18,0xFC,0xFC,0x00,0x00,0x00,0x00,0x0C,0x0C,0x0F,0x0F,0x0C,0x0C,0x00, 0x08,0x0C,0x8C,0xCC,0x7C,0x38,0x00,0x00,0x0E,0x0F,0x0D,0x0C,0x0C,0x0C,0x00,0x00, 0x08,0xCC,0xCC,0xCC,0xFC,0x38,0x00,0x00,0x0C,0x0C,0x0C,0x0C,0x0F,0x07,0x00,0x00, 0x80,0xC0,0x70,0x18,0xFC,0xFC,0x00,0x00,0x03,0x03,0x03,0x03,0x0F,0x0F,0x03,0x00, 0x00,0x7C,0x7C,0xEC,0xEC,0xCC,0x00,0x00,0x0C,0x0C,0x0C,0x0C,0x07,0x07,0x00,0x00, 0xE0,0xF0,0xD8,0xCC,0xCC,0x8C,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x0F,0x07,0x00,0x00, 0x0C,0x0C,0x8C,0xEC,0x3C,0x1C,0x00,0x00,0x00,0x0E,0x0F,0x01,0x00,0x00,0x00,0x00, 0xB8,0xFC,0xCC,0xCC,0xFC,0xB8,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x0F,0x07,0x00,0x00, 0x78,0xFC,0xCC,0xCC,0xFC,0xF0,0x00,0x00,0x00,0x0C,0x0C,0x06,0x07,0x01,0x00,0x00, 0x20,0x70,0x20,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x04,0x00,0x00,0x00,0x00,0x00, 0x00,0x20,0x70,0x20,0x00,0x00,0x00,0x00,0x40,0x6E,0x3E,0x1E,0x00,0x00,0x00,0x00, 0xF0,0xF0,0xF8,0x9C,0x0C,0x0E,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x00,0x00, 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0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0x04,0x1C,0x78,0xC0,0xC0,0x78,0x1C,0x04,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00, 0x0C,0x0C,0xCC,0x7C,0x1C,0x0C,0x00,0x00,0x0C,0x0F,0x0D,0x0C,0x0C,0x0C,0x00,0x00, 0xFE,0xFE,0x06,0x06,0x00,0x00,0x00,0x00,0x7F,0x7F,0x60,0x60,0x00,0x00,0x00,0x00, 0x06,0x3E,0xF8,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x1F,0x7C,0x60,0x00,0x00, 0x06,0x06,0xFE,0xFE,0x00,0x00,0x00,0x00,0x60,0x60,0x7F,0x7F,0x00,0x00,0x00,0x00, 0x00,0x70,0x38,0x1C,0x1C,0x38,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60, 0x04,0x06,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xB0,0xB0,0xB0,0xB0,0xF0,0xE0,0x00,0x07,0x0F,0x0D,0x0D,0x0D,0x0F,0x0F,0x00, 0xFE,0xFE,0x30,0x30,0xF0,0xE0,0x00,0x00,0x0F,0x0F,0x0C,0x0C,0x07,0x03,0x00,0x00, 0xC0,0xE0,0x70,0x30,0x30,0x30,0x00,0x00,0x03,0x07,0x0E,0x0C,0x0C,0x0C,0x00,0x00, 0xC0,0xF0,0x30,0x30,0x30,0xFE,0xFE,0x00,0x03,0x07,0x0E,0x0C,0x0C,0x0F,0x0F,0x00, 0xC0,0xE0,0xB0,0xB0,0xB0,0xF0,0xC0,0x00,0x03,0x07,0x0D,0x0D,0x0D,0x0D,0x0D,0x00, 0x30,0x30,0xFC,0xFE,0x36,0x36,0x36,0x06,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00, 0xC0,0xE0,0x70,0x30,0x30,0xF0,0xF0,0x00,0x03,0x6F,0x6C,0x6C,0x6C,0x7F,0x3F,0x00, 0xFE,0xFE,0x30,0x30,0xF0,0xE0,0x00,0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,0x00, 0x30,0x36,0xF6,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x0C,0x00, 0x00,0x30,0x30,0x30,0xF6,0xF6,0x00,0x00,0x00,0x70,0x60,0x60,0x7F,0x3F,0x00,0x00, 0xFE,0xFE,0x80,0xE0,0x70,0x30,0x10,0x00,0x0F,0x0F,0x01,0x03,0x07,0x0C,0x08,0x00, 0x06,0x06,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x00,0x00, 0xF0,0xF0,0x30,0xF0,0x30,0xF0,0xE0,0x00,0x0F,0x0F,0x00,0x01,0x00,0x0F,0x0F,0x00, 0xF0,0xF0,0x30,0x30,0x30,0xF0,0xE0,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00, 0xC0,0xE0,0x30,0x30,0x30,0xE0,0xC0,0x00,0x03,0x07,0x0C,0x0C,0x0C,0x07,0x03,0x00, 0xF0,0xF0,0x30,0x30,0xF0,0xC0,0x00,0x00,0x7F,0x7F,0x0C,0x0C,0x0F,0x07,0x00,0x00, 0xC0,0xE0,0x30,0x30,0xF0,0xF0,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x7F,0x7F,0x00,0x00, 0xF0,0xF0,0x30,0x30,0x30,0x30,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00, 0xE0,0xF0,0xB0,0xB0,0x30,0x30,0x00,0x00,0x06,0x0C,0x0D,0x0D,0x0F,0x07,0x00,0x00, 0x30,0x30,0xFC,0xFC,0x30,0x30,0x30,0x00,0x00,0x00,0x07,0x0F,0x0C,0x0C,0x0C,0x00, 0xF0,0xF0,0x00,0x00,0x00,0xF0,0xF0,0x00,0x07,0x0F,0x0C,0x0C,0x0C,0x0F,0x0F,0x00, 0x30,0xF0,0xC0,0x00,0xC0,0xF0,0x30,0x00,0x00,0x01,0x07,0x0E,0x07,0x01,0x00,0x00, 0xF0,0xF0,0x00,0xC0,0xC0,0x00,0xF0,0xF0,0x01,0x0F,0x0F,0x01,0x01,0x0F,0x0F,0x01, 0x10,0x30,0x70,0xE0,0xC0,0xF0,0x30,0x10,0x08,0x0C,0x0E,0x03,0x03,0x07,0x0E,0x08, 0x00,0x30,0xF0,0xC0,0x00,0xC0,0xF0,0x30,0x60,0x60,0x61,0x77,0x3E,0x0F,0x01,0x00, 0x30,0x30,0xB0,0xF0,0x70,0x30,0x00,0x00,0x0C,0x0E,0x0F,0x0C,0x0C,0x0C,0x00,0x00, 0x80,0x80,0xFC,0x7E,0x06,0x06,0x00,0x00,0x01,0x01,0x3F,0x7E,0x60,0x60,0x00,0x00, 0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0x06,0x7E,0xFC,0x80,0x80,0x00,0x00,0x60,0x60,0x7E,0x3F,0x01,0x01,0x00,0x00, 0x80,0xC0,0xC0,0xC0,0x80,0xC0,0xC0,0x00,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00 };
On the display it looks like this: