Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFT_eSPI and FreeFont (custom font) #419

Open
reforket opened this issue May 3, 2023 · 1 comment
Open

TFT_eSPI and FreeFont (custom font) #419

reforket opened this issue May 3, 2023 · 1 comment

Comments

@reforket
Copy link

reforket commented May 3, 2023

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
Copy link
Owner

neu-rah commented Jul 10, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants