WIP for bitmap font support. #141
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to use a couple bitmap fonts in an e-paper project I was working on, and I noticed that unscii-8 was getting converted from TTF. That didn't seem right, when LVGL already has a perfectly good bitmap format already! Of course, when I did the initial pass, I discovered that the TTF is perfectly fine for the 8px font, and in fact generates identical glyphs to the pcf (as near as I could tell). This was dismaying, but I decided to press on with the 16px version and, to my surprise I realized the bundled version was just the 8px version scaled up, and I could actually use the native 16px version now! So I started trying out some other fonts and thought, what the heck, bpf isn't that much different, why not add that too? Around then the special casing was getting kind of messy and so I dusted off my (admittedly out of date) javascript and did a little refactor to make an abstract-class-style FontReader and, well, here we are.
For fun, I did a few more, and it seems to work well, though I had to walk a couple of them through otb/yaff with monobit
This might be fairly niche, and perhaps I got carried away with the refactoring, but perhaps also it is a good foundation for supporting other bitmap fonts (provided there are enough of them out there still that are worth writing a UI in).
There are some open questions about how to handle scaling (or not), and what to do about writing direction, both of which throw errors if they get confused at the moment, and I have not tried to integrate it into the UI at all, but I've tried to stay faithful to parsing the formats insofar as bitmaps fall out the other side in what appear to be the right configuration. It's certainly enough for my little project, and I'll probably rewrite it in a language I'm better at if it's too much to include here.
Let me know what you think!
Changes: