davetcc / tcMenu

Menu library for Arduino, mbed and ESP with designer UI and remote control capabilities.
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/
Apache License 2.0
275 stars 25 forks source link

Font offset not calculated correctly when using fonts. #276

Closed rosenhauer closed 1 year ago

rosenhauer commented 1 year ago

When using non built in fonts (tested with Adafruit fonts) the offset is incorrectly calculated.

In tcAdaFruitGfx.cpp internalTextExtents function the line: bl = glyphHeight + pgm_read_byte(&allGlyphs[glIdx].yOffset); should be bl = glyphHeight + (signed char)pgm_read_byte(&allGlyphs[glIdx].yOffset); so that negative offsets are calculated correctly. But this still just uses the offset of the last character tested - the left parentheses.

or preferably it can be changed by eliminating the bl calculation and replacing

if(baseline) *baseline = bl; with if(baseline) *baseline = font->yAdvance - height;

This uses the line spacing for the font minus the tallest character.

This is using Arduino 1.8.16 to compile.

davetcc commented 1 year ago

Thanks for pointing this out, I'll look at this and try it out for both tcUnicode and native fonts. They both use the same calculation. I have a graphical example that shows this and can try it out.

davetcc commented 1 year ago

Many thanks, this somehow escaped through testing, I have fixed this as per your suggestion and it will be in 3.1 which is due very soon.

davetcc commented 1 year ago

I had not understood how serious this was, or I would have removed the touch change from 3.1 and released it earlier. As it is now 3.1 is probably a few days from release so it will go into that.

davetcc commented 1 year ago

The fix is already applied in - https://github.com/davetcc/tcMenu/blob/master/xmlPlugins/core-display/adaGfxDriver/tcMenuAdaFruitGfx.cpp

rosenhauer commented 1 year ago

You're welcome! Always glad to help out if I can.

On Tue, Jan 24, 2023 at 2:26 AM Dave Cherry @.***> wrote:

I had not understood how serious this was, or I would have removed the touch change from 3.1 and released it earlier. As it is now 3.1 is probably a few days from release so it will go into that.

— Reply to this email directly, view it on GitHub https://github.com/davetcc/tcMenu/issues/276#issuecomment-1401543532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBTUKA56FX7VIOPNJOSCT3WT6GZ7ANCNFSM6AAAAAATSHZHLA . You are receiving this because you authored the thread.Message ID: @.***>

-- Dave