TFT_eSPI.h Fonts?

Hi All,

Just having fun playing with a 3.5” SPI TFT 480x320 screen …. looks great.

But, I want to use large text, to read at a distance, which limits the characters I can put on screen.

I would like to “squeeze” the font width, or make BOLD to make it more readable.

I’ve googled everything I can find on how to use the range of TFT_eSPI.h fonts, but I admit, I didn’t understand much of it and no success. How do I get to change fonts ?

My Platformio.ini

[env:nodemcu-32s]

platform = espressif32

board = nodemcu-32s

framework = arduino

monitor_speed = 115200

lib_deps =

build_flags =

-D USER_SETUP_LOADED

-D ILI9488_DRIVER

-D TFT_CS=15

-D TFT_RST=4

-D TFT_DC=2

-D TFT_MOSI=23

-D TFT_SCLK=18

-D LOAD_GLCD=1

-D LOAD_FONT2

-D LOAD_FONT3

-D LOAD_FONT4

-D LOAD_FONT6

-D LOAD_FONT7

-D LOAD_FONT8

-D LOAD_GFXFF

-D SMOOTH_FONT

-D SPI_FREQUENCY=27000000

My User_setup.h

#define LOAD_GLCD

#define LOAD_FONT2

#define LOAD_FONT3

#define LOAD_FONT4

#define LOAD_FONT6

#define LOAD_FONT7

#define LOAD_FONT8

//#define LOAD_FONT8N

#define LOAD_GFXFF

#define SMOOTH_FONT

Trevor

I think github.com/Bodmer/TFT_eSPI/tree/master/examples/480 x 320/Free_Font_Demo9 is the best demo for it. It has all the built in fonts available which just have to set using

While examples like https://github.com/Bodmer/TFT_eSPI/blob/master/examples/Smooth%20Fonts/FLASH_Array/Font_Demo_1_Array/Font_Demo_1_Array.ino showcase how to include new fonts as data arrays and then use loadFont on them.

You should definitely try out all the free fonts of different sizes first per the Free_Front_Demo.ino

Oh wow thanks Max,

I’ll have a play thank you.

The main problem I’m having with ESP32 is finding out about all this stuff. I’m from the PIC controller world, where you chose a device and get a 1000 page datasheet, explaining everything possible :joy:

I’ll let you know how I get on.

Thank you

you should take a look at Larry Banks bb_lcd_spi library it is usable on the newer ESP32 devices and is far better than the older TFT_ESPI library. There are many examples and many predefined devices. There is no need for for the clunky individual setup files used with TFT_eSPI. fonts can be added by using an oon-line font creator.

1 Like

Great news Bob, thank you.

I’ll check that out tomorrow and let you know how I get on.

Obviously the TFT display thing is going to be just a part of any project, so any easier / more efficient way of doing things will be very valuable.

Trevor

https://rop.nl/truetype2gfx/

With this tool you can convert any ttf font and choose any size..

1 Like

Thanks noobmastha,

Sounds really handy

Well,

I’ve been distracted elsewhere and when I’ve returned, I can’t get my display working now !

Got all sorts of compiler errors all of a sudden.

It doesn’t like any of my Platformio.ini lines now …..

Warning! Could not find the package with ‘-D USER_SETUP_LOADED’ requirements for your system ‘windows_amd64’
Warning! Could not find the package with ‘-D ILI9488_DRIVER’ requirements for your system ‘windows_amd64’
Warning! Could not find the package with ‘-D LOAD_FONT4’ requirements for your system ‘windows_amd64’

and so on …

Also …

Compiling .pio\build\nodemcu-32s\libf55\Adafruit DHT Unified\DHT_U.cpp.o
In file included from .pio/libdeps/nodemcu-32s/Adafruit DHT Unified/DHT_U.cpp:22:
.pio/libdeps/nodemcu-32s/Adafruit DHT Unified/DHT_U.h:26:10: fatal error: DHT.h: No such file or directory

All very strange, was working fine yesterday !

HELP !

Sorry guys, ignore my last post.
I’d somehow deleted the “build_flags =” line in my Platformio.ini
No idea when that happened.

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
lib_deps = bodmer/TFT_eSPI@^2.5.43

build_flags = 
	-D USER_SETUP_LOADED
	-D ILI9488_DRIVER
	-D TFT_CS=15
	-D TFT_RST=4
	-D TFT_DC=2
	-D TFT_MOSI=23
	-D TFT_SCLK=18
	-D LOAD_GLCD=1
	-D LOAD_FONT2
	-D LOAD_FONT3
	-D LOAD_FONT4
	-D LOAD_FONT6
	-D LOAD_FONT7
	-D LOAD_FONT8
	-D LOAD_GFXFF
	-D SMOOTH_FONT
	-D SPI_FREQUENCY=27000000

You will, no doubt, come a cross the term CYD, Cheap Yellow display. It used to refer to the original 2.8” display with an onboard ESP32 but nowadays it has become almost generic for a whole range of displays from small round displays to 7” touch screens. I mention it because there is an excellent Discord site called Blough that covers almost anything display related. The site belongs to Brian Lough and there is a lot of information on displays including the TFT_ESPI library and the bb_lcd_spi I mentioned earlier.

Thanks Bob, I’ll Google that, will be very helpful.

The biggest problem I have, is finding out what c++ commands to use, when trying to do things.

Just last night reading a text file from SD card. I read card ok, put characters on display, all good. But then I need to work on some integer numbers from the file. Trying to make “6” and “2” = number 62 took ages, because I can’t find the commands I need. Always some compiler error, that doesn’t help me much. Got there eventually, so I could add up a few numbers.

I’m learning, but need find better training type resources. Putting queries on Google leads you down so many rabbit holes.

Thank you for your help.

Trevor

Here is my project where I am playing around with creating new fonts, loading different fonts, both from Flash and from SD Card. Using TFT_eSPI library.