Turns a character set exported as segment bytes into the packed hex tables the
Wordclock firmware uses for its fonts
(FontCourierNew7x9, FontTahoma10x10, FontLucidaSans9x10, FontSprite5x8).
There are no command line arguments and no file input or output. The font lives in the source, and the result goes to standard output — so the workflow is paste, compile, run, copy:
-
Paste a character set into the
Font[][]table in main.cpp. Fonts/ holds the ones used so far as templates. -
Adjust the constants at the top of
main.cppto that set:Constant Meaning NUMBER_OF_CHARShow many characters the table holds (96 for ASCII, 224 with Latin-1) NUMBER_OF_COLUMNSentries per table row: one width byte plus two segment bytes per pixel column FONT_WIDTH,FONT_HEIGHTsize of a glyph in pixels -
Build and run, redirecting the output into a file.
g++ -std=c++11 -o fontcreator main.cpp
./fontcreator > font.txt- Copy the hex words into the
Font*.cppof the firmware.
DECODE at the top of main.cpp decides what is printed. With STD_ON it
prints the packed hex words that go into the firmware. With STD_OFF it prints
each glyph as ASCII art instead, which is the quick way to check that a pasted
font was decoded correctly before generating anything.
setVertical() against setHorizontal() in main() decides how the bitmap
is packed: setVertical() packs each pixel column into one word,
setHorizontal() each row. Which one a font needs depends on the class that
declares it in the firmware — FontCharVertical or FontCharHorizontal — and
both are in use, so this has to be picked per font rather than once. Getting it
wrong yields transposed glyphs rather than garbage, which makes it easy to miss.
The file names under Fonts/ say which of the two a template was made for.