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

wrong computation of view boundaries #28

Closed petrbrouzda closed 2 years ago

petrbrouzda commented 2 years ago

I've got this font: https://lovecka.info/tmp/YanoneKaffeesatz-SemiBold13pt8b.h

When I load it into app, characters shows croped from bottom. image

The data are there - if I click "-base", character rolls up and it contains all the missing parts: image

I think app computes character boundary wrong... App can be used for editing of this font - just move every character up by -base, edit and then move down by base+. Font data are not destroyed.

tchapi commented 2 years ago

Hmm, that's interesting. I think it's just a display problem, but it may be that the font file has misleading indications in it.

I'm going to have a look

tchapi commented 2 years ago

Where does this font file come from ? I mean, which tool created it ?

petrbrouzda commented 2 years ago

Where does this font file come from ? I mean, which tool created it ?

It was created by adafruit's fontconvert. (by a little modified version, which exports extended set of symbols for our language: https://github.com/petrbrouzda/fontconvert8-iso8859-2/tree/main/fontconvert8 )

Source font is here: https://lovecka.info/tmp/YanoneKaffeesatz-SemiBold.ttf

tchapi commented 2 years ago

Thanks

tchapi commented 2 years ago
const GFXfont YanoneKaffeesatz_SemiBold13pt8b PROGMEM = {
  (uint8_t  *)YanoneKaffeesatz_SemiBold13pt8bBitmaps,
  (GFXglyph *)YanoneKaffeesatz_SemiBold13pt8bGlyphs,
  0x20, 0xDF, 25 };

ok, so that's because of this 25 here at the end of your file, that dictates the yAdvance, which limits the height of each character. Not sure if my calculation should be different or if the file indication is misleading but this line hints that it's a limitation of the fontconvert tool:

https://github.com/petrbrouzda/fontconvert8-iso8859-2/blob/main/fontconvert8/fontconvert8.c#L286

In the case of this font, the height is assumed to be 25, but the ] character is actually 26 pixels, so this height is wrong.

I think I can optimize because I should take the whole span of +/- yOffset. I'm going to try that.

tchapi commented 2 years ago

Ok, I think https://github.com/tchapi/Adafruit-GFX-Font-Customiser/commit/205c5334647ba8d545792488e232641908bcca81 should fix it

Can you test on your side and confirm ?

petrbrouzda commented 2 years ago

Yes, it works perfectly. Thank you!