Converting BDF / PCF fonts? #6905
Replies: 1 comment
-
Posted at 2024-04-23 by @gfwilliams Good question! I have a font converter at https://github.com/espruino/EspruinoWebTools/blob/master/fontconverter.js which I'm using for most stuff now (like creating the font pack apps, and hopefully at some point https://www.espruino.com/Font+Converter), but it doesn't handle BDF yet. I've got a very hacky tool that I don't think I ever released, which I've attached below. It loads BDF and spits out a C file that can be compiled into Espruino. If you were up for a challenge it'd be awesome if you could add the BDF loading code from that tool into the main https://github.com/espruino/EspruinoWebTools/blob/master/fontconverter.js - that way you could export to JS (or a PBF file) to try things out more easily. Attachments: Posted at 2024-04-23 by prehensile Thanks for the code, @gfwilliams! I'm up for a challenge :) I've been poking around some other font related code from the Espruino repos - I'm wondering what the format of the font bitmap data is, as passed to Posted at 2024-04-24 by @gfwilliams I think this might help - short, but I think it contains the jist of it: https://www.espruino.com/Fonts#custom-fonts
Posted at 2024-04-25 by prehensile Yep yep, it was that bit of documentation which led to the question: afiak, there's not a specific definition of "font bitmap"? Maybe I haven't grokked "column-first, most significant bit first" properly. It's not super-important I guess, since most of the code seems to be working with per-glyph bitmaps and sticking it all together is already managed by Posted at 2024-04-25 by @gfwilliams Basically imagine writing all your characters in a line: There's this tool to create 7 segment fonts which may/may not be useful - it runs on Espruino and generates the bitmap using a Graphics instance: https://github.com/espruino/EspruinoDocs/blob/master/modules/sevenseg_font_tools.js#L119-L120 Posted at 2024-04-25 by prehensile Ohhh, I get it now. Flipping it through 90 degrees was the bit that made it all click. Thankyou! I'll crack on when I next get some tinkering time. Posted at 2024-05-01 by @gfwilliams Just to add that https://github.com/espruino/EspruinoWebTools/blob/master/fontconverter.js will now load BDF files, although current tests seem to show it outputting fonts upside-down which is a bit confusing (as the edit: it's fine now - not upside-down, but the x/y offsets of characters weren't working |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-04-22 by prehensile
Hello! I can see from the Espruino source that a few fonts (like Haxor Narrow) were converted from bdf / pcf font files.
I'd like to try out some other bdf fonts. Is the converter you used available anywhere @gfwilliams, before I try to make one myself?
Beta Was this translation helpful? Give feedback.
All reactions