tchapi / Adafruit-GFX-Font-Customiser

A little utility to customise pixel fonts for the Adafruit GFX library
https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
MIT License
90 stars 47 forks source link

Can't parse all the stock Adafruit-GFX-Library/Fonts/ #8

Closed BillyDonahue closed 4 years ago

BillyDonahue commented 4 years ago

What a fun JS tool!

I tried it on a few of the Fonts/*.h files. Failed to parse the TomThumb.h file. At least one problem I can see is the regex that tries to extract a size from the font's name. This works for the fontconvert.c -generated Fonts/ files, but TomThumb isn't one of those. There are a few others of that kind in there, like Org_01.h, and PicoPixel.h

https://github.com/tchapi/Adafruit-GFX-Font-Customiser/blob/8d1b9f0ecdcbb1dbf9128a82e1d770d2a5215101/index.html#L222

BillyDonahue commented 4 years ago

I was wondering why that font pt size would matter to a tool like this. It is used to select a "Semantic UI" Grid column class.

Maybe that can be done based on something more intrinsic to the font data, like the yAdvance? yAdvance should be proportional to pt-size.

tchapi commented 4 years ago

Hi @BillyDonahue

Thanks for the report! You're right. It's really only used to "pretty print" the font name and to scale columns for display.

Would you have enough bandwidth to propose a PR for that improvement, maybe ? I'm quite busy right now and won't have time to look at it before another week or so, and I would be happy to see how you use yAdvance to find a somehow correct pt font size

Thanks ! BR Cyril

BillyDonahue commented 4 years ago

I can give it a whirl. Also busy w/work tho. :)

BillyDonahue commented 4 years ago

Oh, not complicated! 72 pt/in, and fontconvert assumes a 141 dpi screen res. So (72pt/in) / (141 px/in) = .51pt/px. yAdvance is in px, so P=yAdvance*(.51pt/px). Point size is about half of yAdvance.

Ooh, calculating pt size is more complicated than that, as pt size is the height of the EM square, and yAdvance is the spacing between rows. But there's no real need to calculate point size for this app. This app is more interested in dots on an arbitrarily sized grid anyway.

tchapi commented 4 years ago

Alright, would you mind having a look at https://github.com/tchapi/Adafruit-GFX-Font-Customiser/pull/10 ?

And possibly give me link to the .h files that were not working before so I can add them in the /test directory of this repo