neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
929 stars 189 forks source link

TFT_eSPI and FreeFont (custom font) #419

Open reforket opened 1 year ago

reforket commented 1 year ago

Hello, Awasome lib! I use the TFT_eSPI lib and I'd like to use freeFonts.

Example: https://github.com/neu-rah/ArduinoMenu/blob/master/examples/adafruitGfx_eTFT/TFT_eSPI/TFT_eSPI.ino

With standard font, no issue:

#include "Free_Fonts.h"
#define fontW 12
#define fontH 18
gfx.setTextSize(2);
//gfx.setFreeFont(FS12); // Standart custom font "Free Serif 12pt" (TFT_eSPI\Fonts\GFXFF)

standart

With a custom font, the menu is not displayed correctly. All menu items text are shifted one to the top:

#include "Free_Fonts.h"
#define fontW 12
#define fontH 18
//gfx.setTextSize(2);
gfx.setFreeFont(FS12); // Standart custom font "Free Serif 12pt" (TFT_eSPI\Fonts\GFXFF)

fs12-h12-2

Need to move menu items text down. Changing a "fontH" increases the height of the menu items:

#include "Free_Fonts.h"
#define fontW 12
#define fontH 30
//gfx.setTextSize(2);
gfx.setFreeFont(FS12); // Standart custom font "Free Serif 12pt" (TFT_eSPI\Fonts\GFXFF)

fs12-h30

How can this be fixed?

Thanks !

neu-rah commented 11 months ago

please check construction paeameters ie:

PANELS(ucgPanels,{0,0,TFT_Width/fontX,TFT_Height/fontY});
TFTOut tftOut(tft,colors,ucg_tops,ucgPanels,fontX,fontY);

fontX and fontY must match your font dimensions the panel size/pos is also important, please check it is inside drawing area