In short words, it's a Lua script, that you provide a PNG file containing the characters, and a text file containing the same characters. The script converts everything to a C header file, which contains the RGBA pixels of the image, the glyphs (with Unicode codepoint, and location on the image).
Project link: https://github.com/ferreiradaselva/monoglyph
"But, there's only one font in the repository!" The objective is: if more people contribute, that could be a big database of monospaced bitmap fonts, easily accessible from C.
Example
This image:

This text file:
1 2 3 4 5 6 | !"#$%&'()*+,-./ 0123456789:;<=>? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]_a bcdefghijklmnopq rstuvwxyz{|} |
And this command:
1 2 3 4 5 | lua generate.lua /absolute/path/monoglyph/fonts/simple1_5x8x8 /absolute/path/monoglyph/fonts/simple1_5x8x8.png 128 48 // image size simple1_5x8x8 5 8 8 // font name, baseline, glyph width, glyph height /absolute/path/monoglyph/fonts/simple1_5x8x8.h |
Will generate a header like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #ifndef SIMPLE1_5X8X8_GLYPHS_H #define SIMPLE1_5X8X8_GLYPHS_H #include "monoglyph.h" static uint8_t simple1_5x8x8_rgba[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static struct glyph simple1_5x8x8_glyphs[] = { { /* " " */ .codepoint = 32, .col = 0, .row = 0 }, ... }; static struct glyph_set simple1_5x8x8_glyph_set = { .count = 0, .glyph_baseline = 5, .glyph_width = 8, .glyph_height = 8, .image_width = 128, .image_height = 48, .rgba = simple1_5x8x8_rgba, .glyphs = simple1_5x8x8_glyphs }; |