I like that website idea! For now, I reduced the verbosity of the command line:
lua generate.lua /absolute/path/ "font_name"
Now, it just needs the absolute path and the font name. The generator assumes that the image is named font name + ".png"
, and generates a header named font name + ".h"
All the other information now goes in the text file:
128 <--- image width
48 <--- image height
5 <--- glyph baseline
8 <--- glyph width
8 <--- glyph height
!"#$%&'()*+,-./ <--- start of the character set
As for iteration time, I'm thinking of a solution, I currently have this in mind:
- The generator parse the text file:
- find the lowest codepoint value (let's say it's 32)
- find the highest codepoint (let's say it's 255)
- Generate the array of glyphs with size 255 - 32
- The codepoint inside `struct glyph` will match the index in the array
- Depending on the font that someone created, there might be "holes" in the array (some wasted bytes), because they didn't include an specific character. Not really a problem, it's all a matter of what font you want to use and what that font offers
So, it will be possible get a glyph with codepoint-lowest_codepoint as index:
struct glyph *myglyph = &myfont_glyph_set.glyphs[codepoint - myfont_glyph_set.lowest_codepoint];
P.S.: Thanks for the tweet