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

Glyph column width should use the largest glyph width, not xAdvance #27

Closed petrbrouzda closed 3 years ago

petrbrouzda commented 3 years ago

When I extract font with big characters (attached), the UI is rendered incorrectly and font can't be edited. Chrome, Windows 10

image

Font file: IconsFont2.h.txt

tchapi commented 3 years ago

Oh ! It seems like the width calculation is off for the glyph columns

tchapi commented 3 years ago

I'll look into that, good catch

tchapi commented 3 years ago

The calculation is based on the max xAdvance figure found in the font. Is there any reason that this font only has a max of 4 pixels for that property ?

You can see the xAdvance here on this glyph: it's the second vertical red line. In a conventional font, it indicates how subsequent characters overlap:

Screenshot 2021-06-01 at 21 22 41

So basically if you use this font as-is and use two characters on a line, they will totally overlap (except for 4 pixels) which doesn't seem right.

While I think I should take into account the actual max width of a glyph instead in this tool, I think the xAdvance for the characters of this font is not correctly set up.

What do you think ?

petrbrouzda commented 3 years ago

Yes, xAdvance is set incorrectly. I didn't care about the xAdvance, because I'm using this font as iconset only - so I print only one character at a time, never more than one. Mea culpa. So I'm able to easily solve the problem by manualy editing xAdvance of one character - no fix from you is needed. Thank you.

tchapi commented 3 years ago

Still I think that the width should be calculated better. I have made a fix in a37d9d4, tell me if that still works well for you !

petrbrouzda commented 3 years ago

Works correctly now - even on a font with bad xAdvance. Thank you.