Can't display GFX font with TFT_eSPI

Hi,
I’m going crazy over this problem: I can’t properly display GFX fonts (or any other C bitmap font) using the TFT_eSPI library on PlatformIO.
Here’s how my .ini file is configured:

[env:esp32]
platform = espressif32@5.4.0
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	${common.lib_deps}
	fastled/FastLED@^3.6
	bodmer/TFT_eSPI@^2.5.43
	# add any libraries that are specific for the esp32

# this sets your board to 240MHz, not all boards support this, but if yours does, uncomment.
board_build.f_cpu = 240000000L

build_src_filter =
	# include all files
	+<*>
	-<.git>
	# exclude the ESP-NOW bridge
	-<main-espnow-bridge.cpp>
build_flags = 
	-w 
	-D ESP32=1
;	 -D ARDUINO_USB_MODE=0 # Uncomment this if your device supports USB OTG (which means it can be used as an HID device)

monitor_speed = 115200
monitor_filters = esp32_exception_decoder
;upload_port = COM4

In the TFT_eSPI library, I’ve modified User_Setup_Select.h to work with my ESP32 and 3.5" TFT display shield.
I simply commented out the #include for User_Setup.h and uncommented the one for the ILI9488 parallel driver:

// This header file contains a list of user setup files and defines which one the
// compiler uses when the IDE performs a Verify/Compile or Upload.
//
// Users can create configurations for different boards and TFT displays.
// This makes selecting between hardware setups easy by "uncommenting" one line.

// The advantage of this hardware configuration method is that the examples provided
// with the library should work with immediately without any other changes being
// needed. It also improves the portability of users sketches to other hardware
// configurations and compatible libraries.
//
// Create a shortcut to this file on your desktop to permit quick access for editing.
// Re-compile and upload after making and saving any changes to this file.

// Example User_Setup files are stored in the "User_Setups" folder. These can be used
// unmodified or adapted for a particular hardware configuration.

#ifndef USER_SETUP_LOADED //  Lets PlatformIO users define settings in
                          //  platformio.ini, see notes in "Tools" folder.

///////////////////////////////////////////////////////
//   User configuration selection lines are below    //
///////////////////////////////////////////////////////

// Only ONE line below should be uncommented to define your setup.  Add extra lines and files as needed.

//#include <User_Setup.h>           // Default setup is root library folder

//#include <User_Setups/Setup1_ILI9341.h>  // Setup file for ESP8266 configured for my ILI9341
//#include <User_Setups/Setup2_ST7735.h>   // Setup file for ESP8266 configured for my ST7735
//#include <User_Setups/Setup3_ILI9163.h>  // Setup file for ESP8266 configured for my ILI9163
//#include <User_Setups/Setup4_S6D02A1.h>  // Setup file for ESP8266 configured for my S6D02A1
//#include <User_Setups/Setup5_RPi_ILI9486.h>        // Setup file for ESP8266 configured for my stock RPi TFT
//#include <User_Setups/Setup6_RPi_Wr_ILI9486.h>     // Setup file for ESP8266 configured for my modified RPi TFT
//#include <User_Setups/Setup7_ST7735_128x128.h>     // Setup file for ESP8266 configured for my ST7735 128x128 display
//#include <User_Setups/Setup8_ILI9163_128x128.h>    // Setup file for ESP8266 configured for my ILI9163 128x128 display
//#include <User_Setups/Setup9_ST7735_Overlap.h>     // Setup file for ESP8266 configured for my ST7735
//#include <User_Setups/Setup10_RPi_touch_ILI9486.h> // Setup file for ESP8266 configured for ESP8266 and RPi TFT with touch

//#include <User_Setups/Setup11_RPi_touch_ILI9486.h> // Setup file configured for ESP32 and RPi TFT with touch
//#include <User_Setups/Setup12_M5Stack_Basic_Core.h>// Setup file for the ESP32 based M5Stack (Basic Core only)
//#include <User_Setups/Setup13_ILI9481_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup14_ILI9341_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup15_HX8357D.h>           // Setup file for ESP8266 configured for HX8357D
#include <User_Setups/Setup16_ILI9488_Parallel.h>  // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup17_ePaper.h>            // Setup file for ESP8266 and any Waveshare ePaper display
//#include <User_Setups/Setup18_ST7789.h>            // Setup file for ESP8266 configured for ST7789

//#include <User_Setups/Setup19_RM68140_Parallel.h>	 // Setup file configured for RM68140 with parallel bus

//#include <User_Setups/Setup20_ILI9488.h>           // Setup file for ESP8266 and ILI9488 SPI bus TFT
//#include <User_Setups/Setup21_ILI9488.h>           // Setup file for ESP32 and ILI9488 SPI bus TFT

//#include <User_Setups/Setup22_TTGO_T4.h>           // Setup file for ESP32 and TTGO T4 version 1.2
//#include <User_Setups/Setup22_TTGO_T4_v1.3.h>      // Setup file for ESP32 and TTGO T4 version 1.3
//#include <User_Setups/Setup23_TTGO_TM.h>           // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT
//#include <User_Setups/Setup24_ST7789.h>            // Setup file for DSTIKE/ESP32/ESP8266 configured for ST7789 240 x 240
//#include <User_Setups/Setup25_TTGO_T_Display.h>    // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT
//#include <User_Setups/Setup26_TTGO_T_Wristband.h>  // Setup file for ESP32 and TTGO T-Wristband ST7735 SPI bus TFT

//#include <User_Setups/Setup27_RPi_ST7796_ESP32.h>    // ESP32   RPi MHS-4.0 inch Display-B
//#include <User_Setups/Setup28_RPi_ST7796_ESP8266.h>  // ESP8266 RPi MHS-4.0 inch Display-B

//#include <User_Setups/Setup29_ILI9341_STM32.h>          // Setup for Nucleo board
//#include <User_Setups/Setup30_ILI9341_Parallel_STM32.h> // Setup for Nucleo board and parallel display
//#include <User_Setups/Setup31_ST7796_Parallel_STM32.h>  // Setup for Nucleo board and parallel display
//#include <User_Setups/Setup32_ILI9341_STM32F103.h>      // Setup for "Blue/Black Pill"

//#include <User_Setups/Setup33_RPi_ILI9486_STM32.h>      // Setup for Nucleo board

//#include <User_Setups/Setup34_ILI9481_Parallel_STM32.h> // Setup for Nucleo board and parallel display
//#include <User_Setups/Setup35_ILI9341_STM32_Port_Bus.h> // Setup for STM32 port A parallel display

//#include <User_Setups/Setup36_RPi_touch_ST7796.h>      // Setup file configured for ESP32 and RPi ST7796 TFT with touch

//#include <User_Setups/Setup42_ILI9341_ESP32.h>           // Setup file for ESP32 and SPI ILI9341 240x320
//#include <User_Setups/Setup43_ST7735.h>            // Setup file for ESP8266 & ESP32 configured for my ST7735S 80x160
//#include <User_Setups/Setup44_TTGO_CameraPlus.h>   // Setup file for ESP32 and TTGO T-CameraPlus ST7789 SPI bus TFT    240x240
//#include <User_Setups/Setup45_TTGO_T_Watch.h>      // Setup file for ESP32 and TTGO T-Watch ST7789 SPI bus TFT  240x240
//#include <User_Setups/Setup46_GC9A01_ESP32.h>      // Setup file for ESP32 and GC9A01 SPI bus TFT  240x240

//#include <User_Setups/Setup47_ST7735.h>            // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes

//#include <User_Setups/Setup50_SSD1963_Parallel.h>  // Setup file for ESP32 and SSD1963 TFT display

//#include <User_Setups/Setup51_LilyPi_ILI9481.h>    // Setup file for LilyGo LilyPi with ILI9481 display
//#include <User_Setups/Setup52_LilyPi_ST7796.h>     // Setup file for LilyGo LilyPi with ST7796 display

//#include <User_Setups/Setup60_RP2040_ILI9341.h>              // Setup file for RP2040 with SPI ILI9341
//#include <User_Setups/Setup61_RP2040_ILI9341_PIO_SPI.h>      // Setup file for RP2040 with PIO SPI ILI9341
//#include <User_Setups/Setup62_RP2040_Nano_Connect_ILI9341.h> // Setup file for RP2040 with SPI ILI9341

//#include <User_Setups/Setup66_Seeed_XIAO_Round.h>     // Setup file for Seeed XIAO with GC9A01 240x240

//#include <User_Setups/Setup70_ESP32_S2_ILI9341.h>     // Setup file for ESP32 S2 with SPI ILI9341
//#include <User_Setups/Setup70b_ESP32_S3_ILI9341.h>    // Setup file for ESP32 S3 with SPI ILI9341
//#include <User_Setups/Setup70c_ESP32_C3_ILI9341.h>    // Setup file for ESP32 C3 with SPI ILI9341
//#include <User_Setups/Setup70d_ILI9488_S3_Parallel.h> // Setup file for ESP32 S3 with SPI ILI9488

//#include <User_Setups/Setup71_ESP32_S2_ST7789.h>       // Setup file for ESP32 S2 with ST7789
//#include <User_Setups/Setup72_ESP32_ST7789_172x320.h>  // Setup file for ESP32 with ST7789 1.47" 172x320

//#include <User_Setups/Setup100_RP2040_ILI9488_parallel.h> // Setup file for Pico/RP2040 with 8-bit parallel ILI9488
//#include <User_Setups/Setup101_RP2040_ILI9481_parallel.h> // Setup file for Pico/RP2040 with 8-bit parallel ILI9481
//#include <User_Setups/Setup102_RP2040_ILI9341_parallel.h> // Setup file for Pico/RP2040 with 8-bit parallel ILI9341
//#include <User_Setups/Setup103_RP2040_ILI9486_parallel.h> // Setup file for Pico/RP2040 with 8-bit parallel ILI9486
//#include <User_Setups/Setup104_RP2040_ST7796_parallel.h>  // Setup file for Pico/RP2040 with 8-bit parallel ST7796

//#include <User_Setups/Setup105_RP2040_ST7796_16bit_parallel.h>  // Setup file for RP2040 16-bit parallel display
//#include <User_Setups/Setup106_RP2040_ILI9481_16bit_parallel.h> // Setup file for RP2040 16-bit parallel display
//#include <User_Setups/Setup107_RP2040_ILI9341_16bit_parallel.h> // Setup file for RP2040 16-bit parallel display
//#include <User_Setups/Setup108_RP2040_ST7735.h> // Setup file for Waveshare RP2040 board with onboard ST7735 0.96" 160x80 display

//#include <User_Setups/Setup135_ST7789.h>           // Setup file for ESP8266 and ST7789 135 x 240 TFT

//#include <User_Setups/Setup136_LilyGo_TTV.h>       // Setup file for ESP32 and Lilygo TTV ST7789 SPI bus TFT  135x240
//#include <User_Setups/Setup137_LilyGo_TDisplay_RP2040.h>  // Setup file for Lilygo T-Display RP2040 (ST7789 on SPI bus with 135x240 TFT)

//#include <User_Setups/Setup138_Pico_Explorer_Base_RP2040_ST7789.h> // Setup file for Pico Explorer Base by Pimoroni for RP2040 (ST7789 on SPI bus with 240x240 TFT)

//#include <User_Setups/Setup200_GC9A01.h>           // Setup file for ESP32 and GC9A01 240 x 240 TFT

//#include <User_Setups/Setup201_WT32_SC01.h>        // Setup file for ESP32 based WT32_SC01 from Seeed

//#include <User_Setups/Setup202_SSD1351_128.h>      // Setup file for ESP32/ESP8266 based SSD1351 128x128 1.5inch OLED display

//#include <User_Setups/Setup203_ST7789.h>     // Setup file for ESP32/ESP8266 based ST7789 240X280 1.69inch TFT 

//#include <User_Setups/Setup204_ESP32_TouchDown.h>     // Setup file for the ESP32 TouchDown based on ILI9488 480 x 320 TFT 

//#include <User_Setups/Setup205_ESP32_TouchDown_S3.h>     // Setup file for the ESP32 TouchDown S3 based on ILI9488 480 x 320 TFT 

//#include <User_Setups/Setup206_LilyGo_T_Display_S3.h>     // For the LilyGo T-Display S3 based ESP32S3 with ST7789 170 x 320 TFT
//#include <User_Setups/Setup207_LilyGo_T_HMI.h>            // For the LilyGo T-HMI S3 based ESP32S3 with ST7789 240 x 320 TFT
//#include <User_Setups/Setup209_LilyGo_T_Dongle_S3.h>      // For the LilyGo T-Dongle S3 based ESP32 with ST7735 80 x 160 TFT
//#include <User_Setups/Setup210_LilyGo_T_Embed_S3.h>         // For the LilyGo T-Embed S3 based ESP32S3 with ST7789 170 x 320 TFT
//#include <User_Setups/Setup211_LilyGo_T_QT_Pro_S3.h>         // For the LilyGo T-QT Pro S3 based ESP32S3 with GC9A01 128 x 128 TFT
// #include <User_Setups/Setup212_LilyGo_T_PicoPro.h>         // For the LilyGo T-PICO-Pro with ST7796 222 x 480 TFT
// #include <User_Setups/Setup213_LilyGo_T_Beam_Shield.h>         // For the LilyGo T-BEAM V1.x with ST7796 222 x 480 TFT

//#include <User_Setups/Setup250_ESP32_S3_Box_Lite.h>      // For the ESP32 S3 Box Lite
//#include <User_Setups/Setup251_ESP32_S3_Box.h>            // For the ESP32 S3 Box

//#include <User_Setups/Setup301_BW16_ST7735.h>            // Setup file for Bw16-based boards with ST7735 160 x 80 TFT
//#include <User_Setups/Setup302_Waveshare_ESP32S3_GC9A01.h>            // Setup file for Waveshare ESP32-S3-Touch-LCD-1.28 board with GC9A01 240*240 TFT

//#include <User_Setups/SetupX_Template.h>     // Template file for a setup


//#include <User_Setups/Dustin_ILI9488.h>          // Setup file for Dustin Watts PCB with ILI9488
//#include <User_Setups/Dustin_ST7796.h>           // Setup file for Dustin Watts PCB with ST7796
//#include <User_Setups/Dustin_ILI9488_Pico.h>     // Setup file for Dustin Watts Pico PCB with ST7796
//#include <User_Setups/Dustin_ST7789_Pico.h>      // Setup file for Dustin Watts PCB with ST7789 240 x 240 on 3.3V adapter board
//#include <User_Setups/Dustin_GC9A01_Pico.h>      // Setup file for Dustin Watts PCB with GC9A01 240 x 240 on 3.3V adapter board
//#include <User_Setups/Dustin_GC9A01_ESP32.h>     // Setup file for Dustin Watts PCB with GC9A01 240 x 240 on 3.3V adapter board
//#include <User_Setups/Dustin_STT7789_ESP32.h>    // Setup file for Dustin Watts PCB with ST7789 240 x 240 on 3.3V adapter board
//#include <User_Setups/Dustin_ILI9341_ESP32.h>    // Setup file for Dustin Watts PCB with ILI9341
//#include <User_Setups/ILI9225.h>

#endif // USER_SETUP_LOADED



/////////////////////////////////////////////////////////////////////////////////////
//                                                                                 //
//     DON'T TINKER WITH ANY OF THE FOLLOWING LINES, THESE ADD THE TFT DRIVERS     //
//       AND ESP8266 PIN DEFINITONS, THEY ARE HERE FOR BODMER'S CONVENIENCE!       //
//                                                                                 //
/////////////////////////////////////////////////////////////////////////////////////


// Identical looking TFT displays may have a different colour ordering in the 16-bit colour
#define TFT_BGR 0   // Colour order Blue-Green-Red
#define TFT_RGB 1   // Colour order Red-Green-Blue

// Legacy setup support, RPI_DISPLAY_TYPE replaces RPI_DRIVER
#if defined (RPI_DRIVER)
  #if !defined (RPI_DISPLAY_TYPE)
    #define RPI_DISPLAY_TYPE
  #endif
#endif

// Legacy setup support, RPI_ILI9486_DRIVER form is deprecated
// Instead define RPI_DISPLAY_TYPE and also define driver (e.g. ILI9486_DRIVER) 
#if defined (RPI_ILI9486_DRIVER)
  #if !defined (ILI9486_DRIVER)
    #define ILI9486_DRIVER
  #endif
  #if !defined (RPI_DISPLAY_TYPE)
    #define RPI_DISPLAY_TYPE
  #endif
#endif

// Invoke 18-bit colour for selected displays
#if !defined (RPI_DISPLAY_TYPE) && !defined (TFT_PARALLEL_8_BIT) && !defined (TFT_PARALLEL_16_BIT) && !defined (ESP32_PARALLEL)
  #if defined (ILI9481_DRIVER) || defined (ILI9486_DRIVER) || defined (ILI9488_DRIVER)
    #define SPI_18BIT_DRIVER
  #endif
#endif

// Load the right driver definition - do not tinker here !
#if   defined (ILI9341_DRIVER) || defined(ILI9341_2_DRIVER) || defined (ILI9342_DRIVER)
     #include <TFT_Drivers/ILI9341_Defines.h>
     #define  TFT_DRIVER 0x9341
#elif defined (ST7735_DRIVER)
     #include <TFT_Drivers/ST7735_Defines.h>
     #define  TFT_DRIVER 0x7735
#elif defined (ILI9163_DRIVER)
     #include <TFT_Drivers/ILI9163_Defines.h>
     #define  TFT_DRIVER 0x9163
#elif defined (S6D02A1_DRIVER)
     #include <TFT_Drivers/S6D02A1_Defines.h>
     #define  TFT_DRIVER 0x6D02
#elif defined (ST7796_DRIVER)
      #include "TFT_Drivers/ST7796_Defines.h"
      #define  TFT_DRIVER 0x7796
#elif defined (ILI9486_DRIVER)
     #include <TFT_Drivers/ILI9486_Defines.h>
     #define  TFT_DRIVER 0x9486
#elif defined (ILI9481_DRIVER)
     #include <TFT_Drivers/ILI9481_Defines.h>
     #define  TFT_DRIVER 0x9481
#elif defined (ILI9488_DRIVER)
     #include <TFT_Drivers/ILI9488_Defines.h>
     #define  TFT_DRIVER 0x9488
#elif defined (HX8357D_DRIVER)
     #include "TFT_Drivers/HX8357D_Defines.h"
     #define  TFT_DRIVER 0x8357
#elif defined (EPD_DRIVER)
     #include "TFT_Drivers/EPD_Defines.h"
     #define  TFT_DRIVER 0xE9D
#elif defined (ST7789_DRIVER)
     #include "TFT_Drivers/ST7789_Defines.h"
     #define  TFT_DRIVER 0x7789
#elif defined (R61581_DRIVER)
     #include "TFT_Drivers/R61581_Defines.h"
     #define  TFT_DRIVER 0x6158
#elif defined (ST7789_2_DRIVER)
     #include "TFT_Drivers/ST7789_2_Defines.h"
     #define  TFT_DRIVER 0x778B
#elif defined (RM68140_DRIVER)
     #include "TFT_Drivers/RM68140_Defines.h"
     #define  TFT_DRIVER 0x6814
#elif defined (SSD1351_DRIVER)
     #include "TFT_Drivers/SSD1351_Defines.h"
     #define  TFT_DRIVER 0x1351
#elif defined (SSD1963_480_DRIVER)
     #include "TFT_Drivers/SSD1963_Defines.h"
     #define  TFT_DRIVER 0x1963
#elif defined (SSD1963_800_DRIVER)
     #include "TFT_Drivers/SSD1963_Defines.h"
     #define  TFT_DRIVER 0x1963
#elif defined (SSD1963_800ALT_DRIVER)
     #include "TFT_Drivers/SSD1963_Defines.h"
     #define  TFT_DRIVER 0x1963
#elif defined (SSD1963_800BD_DRIVER)
     #include "TFT_Drivers/SSD1963_Defines.h"
     #define  TFT_DRIVER 0x1963
#elif defined (GC9A01_DRIVER)
     #include "TFT_Drivers/GC9A01_Defines.h"
     #define  TFT_DRIVER 0x9A01
#elif defined (ILI9225_DRIVER)
     #include "TFT_Drivers/ILI9225_Defines.h"
     #define  TFT_DRIVER 0x9225
#elif defined (RM68120_DRIVER)
     #include "TFT_Drivers/RM68120_Defines.h"
     #define  TFT_DRIVER 0x6812
#elif defined (HX8357B_DRIVER)
     #include "TFT_Drivers/HX8357B_Defines.h"
     #define  TFT_DRIVER 0x835B
#elif defined (HX8357C_DRIVER)
     #include "TFT_Drivers/HX8357C_Defines.h"
     #define  TFT_DRIVER 0x835C

                              // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
                              // XYZZY_init.h and XYZZY_rotation.h must also be added in TFT_eSPI.cpp
#elif defined (XYZZY_DRIVER)
     #include "TFT_Drivers/XYZZY_Defines.h"
     #define  TFT_DRIVER 0x0000
#else
     #define  TFT_DRIVER 0x0000
#endif

// These are the pins for ESP8266 boards
//      Name   GPIO    NodeMCU      Function
#define PIN_D0  16  // GPIO16       WAKE
#define PIN_D1   5  // GPIO5        User purpose
#define PIN_D2   4  // GPIO4        User purpose
#define PIN_D3   0  // GPIO0        Low on boot means enter FLASH mode
#define PIN_D4   2  // GPIO2        TXD1 (must be high on boot to go to UART0 FLASH mode)
#define PIN_D5  14  // GPIO14       HSCLK
#define PIN_D6  12  // GPIO12       HMISO
#define PIN_D7  13  // GPIO13       HMOSI  RXD2
#define PIN_D8  15  // GPIO15       HCS    TXD0 (must be low on boot to enter UART0 FLASH mode)
#define PIN_D9   3  //              RXD0
#define PIN_D10  1  //              TXD0

#define PIN_MOSI 8  // SD1          FLASH and overlap mode
#define PIN_MISO 7  // SD0
#define PIN_SCLK 6  // CLK
#define PIN_HWCS 0  // D3

#define PIN_D11  9  // SD2
#define PIN_D12 10  // SD4

Then, I have a .ttf font (though I’ve tried multiple fonts) that I converted using Truetype2GFX.
This is the generated output:
const uint8_t Race_Sport12pt7bBitmaps[] PROGMEM = { 0x00, 0xFF, 0xFF, 0xFF, 0 - Pastebin.com (I had to use Pastebin because the forum limits the number of characters).

I include it with:
#include "Rally_Italic12pt7b.h"

Then, I try to display it on the screen with:

tft.setTextDatum(MC_DATUM);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setCursor(150, 150);
tft.setFreeFont(&Race_Sport12pt7b); // Set the custom font
tft.drawString("123", 160, 140, 1);

But I get a glitched text that’s only about 3 pixels high and stretches horizontally across the screen.

The only way I’ve managed to make it work is by following this tutorial:

He basically takes the .ttf file, converts it to .vlw using a software called Processing, and then converts it again with Tomeko dot net.

However, the generated file is huge—around 17,000 lines—and takes up nearly 70% of the flash memory. But I only need numbers, not even letters, just digits. I need to keep at least 40% of the flash free for my own project, so I can’t afford to waste 70% just for a font.

Does anyone have any ideas? I’ve tried every possible solution I could find online before coming here. Honestly, I don’t even remember what I’ve tried and what I haven’t, but I feel like I’ve tried everything.

Thanks to anyone who can help!

Don’t modify the library files. Use the platformio.ini to configure the library instead. Check TFT_eSPI/docs/PlatformIO/Configuring options.txt at master · Bodmer/TFT_eSPI · GitHub

Hi,
so since my setup works with this configuration:

// See SetupX_Template.h for all options available
#define USER_SETUP_ID 16

#define ESP32_PARALLEL


#define ILI9488_DRIVER


// ESP32 pins used
#define TFT_CS   33  // Chip select control pin
#define TFT_DC   15  // Data Command control pin - must use a pin in the range 0-31
#define TFT_RST  32  // Reset pin

#define TFT_WR    4  // Write strobe control pin - must use a pin in the range 0-31
#define TFT_RD    2

#define TFT_D0   12  // Must use pins in the range 0-31 for the data bus
#define TFT_D1   13  // so a single register write sets/clears all bits
#define TFT_D2   26
#define TFT_D3   25
#define TFT_D4   17
#define TFT_D5   16
#define TFT_D6   27
#define TFT_D7   14


#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

#define SMOOTH_FONT

And I should not modify the library files, I will set the library as deafault, and my .ini will be something like that?:

[common]
lib_deps =
	adafruit/Adafruit GFX Library@^1.11.5
	adafruit/Adafruit LED Backpack Library@^1.1
	adafruit/Adafruit NeoPixel@^1.10.5
	adafruit/Adafruit PCD8544 Nokia 5110 LCD library@^2.0.1
	adafruit/Adafruit SSD1306@2.5.9
	adafruit/Adafruit WS2801 Library@1.1.1
	#includes fixes for esp
	https://github.com/9khil/LedControl#913cbcebb8ceea6783bb271d385d18b99c2d5e79
	blackhack/LCD_I2C @ ^2.3.0
	mathertel/LiquidCrystal_PCF8574@^2.2.0
	smougenot/TM1637@0.0.0-alpha+sha.9486982048
	https://github.com/paulo-raca/ArduinoBufferedStreams.git#5e3a1a3d140955384a07878c64808e77fa2a7521
	noah1510/LedController @ ^1.7.0
	locoduino/RingBuffer@^1.0.4
	https://github.com/maxint-rd/TM16xx#95a1bdd959bf6fce75d0059f129386155f49f984
	makuna/NeoPixelBus @ ^2.8
	https://github.com/me-no-dev/ESPAsyncWebServer#7f3753454b1f176c4b6d6bcd1587a135d95ca63c
	https://github.com/khoih-prog/ESPAsync_WiFiManager#e83343f4c2df14b504d284982152539692ac2078
	
[env:esp32]
platform = espressif32@5.4.0
; platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.07/platform-espressif32.zip
# this should be set to your flavor of esp32, for instance wemos_d1_mini32, esp32doit-devkit-v1, seeed_xiao_esp32c3, esp32-s3-devkitc-1
# BOARD LIST: https://docs.platformio.org/en/latest/boards/index.html#espressif-32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	${common.lib_deps}
	fastled/FastLED@^3.6
	bodmer/TFT_eSPI@^2.5.43
	# add any libraries that are specific for the esp32

# this sets your board to 240MHz, not all boards support this, but if yours does, uncomment.
board_build.f_cpu = 240000000L

build_src_filter =
	# include all files
	+<*>
	-<.git>
	# exclude the ESP-NOW bridge
	-<main-espnow-bridge.cpp>
build_flags = 
	-w 
	-D ESP32=1
;	 -D ARDUINO_USB_MODE=0 # Uncomment this if your device supports USB OTG (which means it can be used as an HID device)
  ; Define the TFT driver, pins etc. here:
	-DUSER_SETUP_LOADED=16
	-DILI9488_DRIVER=1
	-DTFT_WIDTH=480
	-DTFT_HEIGHT=320
	-DTFT_CS=33
	-DTFT_DC=15
	-DTFT_RST=32
	-DTFT_WR=4
	-DTFT_RD=2
	-DTFT_D0=12
	-DTFT_D1=13
	-DTFT_D2=26
	-DTFT_D3=25
	-DTFT_D4=17
	-DTFT_D5=16
	-DTFT_D6=27
	-DTFT_D7=14

	; Font settings
	-DLOAD_GLCD=1
	-DLOAD_FONT2=1
	-DLOAD_FONT4=1
	-DLOAD_FONT6=1
	-DLOAD_FONT7=1
	-DLOAD_FONT8=1
	-DLOAD_GFXFF=1
	-DSMOOTH_FONT=1
	-DSPI_FREQUENCY=27000000

monitor_speed = 115200
monitor_filters = esp32_exception_decoder
;upload_port = COM4

When I get home I will try.
Thanks.

The build_flags for TFT_eSPI look good to me at first glance (not tested)

Your lib_deps are a different topic… There is a lot to optimize there. Especially the “version specification” based on a commit is very unusual.

me-no-dev/ESPAsyncWebServer has already been replaced by esp32async/ESPAsyncWebServer. This one is actively developed and maintained.

khoih-prog/ESPAsync_WiFiManager is only a fork whose development was already discontinued 2 years ago. I think the original is GitHub - tzapu/WiFiManager: ESP8266 WiFi Connection manager with web captive portal

But unfortunately none of this will help you with your problem with the font.

Hi, i finally got home and i tried with the new .ini, but still not working. I see only a blank screen.

Did you try a super simple example like drawing a few dots, lines etc?

I mean tried with an empty project with the .ini like this:

[env:esp32doit-devkit-v1]
platform = espressif32@5.4.0
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	bodmer/TFT_eSPI@^2.5.43 

board_build.f_cpu = 240000000L

build_flags = 
	-w 
	-D ESP32=1
;	 -D ARDUINO_USB_MODE=0 # Uncomment this if your device supports USB OTG (which means it can be used as an HID device)
	-DUSER_SETUP_LOADED=16
	-DILI9488_DRIVER=1
	-DTFT_WIDTH=480
	-DTFT_HEIGHT=320
	-DTFT_CS=33
	-DTFT_DC=15
	-DTFT_RST=32
	-DTFT_WR=4
	-DTFT_RD=2
	-DTFT_D0=12
	-DTFT_D1=13
	-DTFT_D2=26
	-DTFT_D3=25
	-DTFT_D4=17
	-DTFT_D5=16
	-DTFT_D6=27
	-DTFT_D7=14
	; Font settings
	-DLOAD_GLCD=1
	-DLOAD_FONT2=1
	-DLOAD_FONT4=1
	-DLOAD_FONT6=1
	-DLOAD_FONT7=1
	-DLOAD_FONT8=1
	-DLOAD_GFXFF=1
	-DSMOOTH_FONT=1
	-DSPI_FREQUENCY=27000000

and the main.cpp like this:

#include <Arduino.h>
#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

void setup() {
	tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_RED);
}

void loop() {

}

I had to edit the User_Setup_Select.h commenting out the:

//#ifndef USER_SETUP_LOADED

because otherwise the esp32 will not even start and will be stuck.

I see only a blank screen now.

platform = espressif32@5.4.0
Wow, what an ancient version! This is Arduino 2.0.7 released in Jun 23, 2023.
Any reason for this?

What are the reasons for

build_flags = 
	-w 
	-D ESP32=1
;	 -D ARDUINO_USB_MODE=0 # Uncomment this if your device supports USB OTG (which means it can be used as an HID device)

and

board_build.f_cpu = 240000000L

?

Are you 100% sure you need this?

Ususally you don’t have to edit any of the library files if you use the configuration via platformio.ini.

If you already edited the library files, run a “full clean” to get rid of those edits and pull a clean library.

Also make sure that the used PINs are correct. Did you had a working example in ArduinoIDE or any other working project before?

I also tried:

platform = espressif32

And the reaseons of:

build_flags = 
	-w 
	-D ESP32=1
;	 -D ARDUINO_USB_MODE=0 # Uncomment this if your device supports USB OTG (which means it can be used as an HID device)

i don’t really know… I took this project from this github:

because it was already here. I took this project and I’m modifying it. Now the .ini looks like that:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	bodmer/TFT_eSPI@^2.5.43 

build_flags = 
	-DILI9488_DRIVER=1
	-DTFT_WIDTH=480
	-DTFT_HEIGHT=320
	-DTFT_CS=33
	-DTFT_DC=15
	-DTFT_RST=32
	-DTFT_WR=4
	-DTFT_RD=2
	-DTFT_D0=12
	-DTFT_D1=13
	-DTFT_D2=26
	-DTFT_D3=25
	-DTFT_D4=17
	-DTFT_D5=16
	-DTFT_D6=27
	-DTFT_D7=14
	; Font settings
	-DLOAD_GLCD=1
	-DLOAD_FONT2=1
	-DLOAD_FONT4=1
	-DLOAD_FONT6=1
	-DLOAD_FONT7=1
	-DLOAD_FONT8=1
	-DLOAD_GFXFF=1
	-DSMOOTH_FONT=1

but still a blank screen.
The only way to make it work was modifing directly the library files as I did in my first post here. The only problem with how it was working is that I coulnd’t render properly the custom GFX fonts.

platform = espressif32

The latest official espressif32 platform version is 6.10.0. If 5.4.0 is the only one installed on your system, it will still be in use. So change this to

platform = espressif32 @ 6.10.0
build_flags = 
	-DILI9488_DRIVER=1

Now your build_flags are missing

    -DUSER_SETUP_LOADED=1

Then there is still something wrong (probably the missing USER_SETUP_LOADED macro)

If the minimal example is running (using the config via platformio.ini) I suggest to file an issue at Bodmer/TFT_eSPI/issues and ask for help about the GFX font issue.

Just to be sure, this is my .ini now:

[env:esp32doit-devkit-v1]
platform = espressif32@6.10.0
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
	bodmer/TFT_eSPI@^2.5.43 

build_flags = 
	-DUSER_SETUP_LOADED=1
	-DILI9488_DRIVER=1
	-DTFT_WIDTH=480
	-DTFT_HEIGHT=320
	-DTFT_CS=33
	-DTFT_DC=15
	-DTFT_RST=32
	-DTFT_WR=4
	-DTFT_RD=2
	-DTFT_D0=12
	-DTFT_D1=13
	-DTFT_D2=26
	-DTFT_D3=25
	-DTFT_D4=17
	-DTFT_D5=16
	-DTFT_D6=27
	-DTFT_D7=14

	; Font settings
	-DLOAD_GLCD=1
	-DLOAD_FONT2=1
	-DLOAD_FONT4=1
	-DLOAD_FONT6=1
	-DLOAD_FONT7=1
	-DLOAD_FONT8=1
	-DLOAD_GFXFF=1
	-DSMOOTH_FONT=1

i set as default the TFT_eSPI library, so with the

#ifndef USER_SETUP_LOADED

not commented.

I still see a blank screen.
The strange thing is that on the esp32 board, the blue led that usually turns on, now it doesn’t turn on when I don’t comment the #ifndef

I also tried the board:

board = esp32dev 

Ok now the display is working. This time I was determined XD.

I opened the Setup16_ILI9488_Parallel.h file since this was the only one working, and i noticed that there were some #define that i didn’t set in the .ini:

// See SetupX_Template.h for all options available
#define USER_SETUP_ID 16
#define ESP32_PARALLEL
#define ILI9488_DRIVER

so my .ini now is:


[env:esp32doit-devkit-v1]
platform = espressif32@6.10.0
board = esp32dev 
framework = arduino
lib_deps = 
	bodmer/TFT_eSPI@^2.5.43 

build_flags =  
    -DUSER_SETUP_ID=16
	-DUSER_SETUP_LOADED=1
	-DILI9488_DRIVER=1
    -DESP32_PARALLEL=1
	-DTFT_WIDTH=320
	-DTFT_HEIGHT=480
	-DTFT_CS=33
	-DTFT_DC=15
	-DTFT_RST=32
	-DTFT_WR=4
	-DTFT_RD=2
	-DTFT_D0=12
	-DTFT_D1=13
	-DTFT_D2=26
	-DTFT_D3=25
	-DTFT_D4=17
	-DTFT_D5=16
	-DTFT_D6=27
	-DTFT_D7=14
	; Font settings
	-DLOAD_GLCD=1
	-DLOAD_FONT2=1
	-DLOAD_FONT4=1
	-DLOAD_FONT6=1
	-DLOAD_FONT7=1
	-DLOAD_FONT8=1
	-DLOAD_GFXFF=1
	-DSMOOTH_FONT=1

and it working! now i try with the custom GFX fonts.

1 Like

Now it is working :slight_smile: !
i used Truetype2GFX to convert my .ttf into a GFX font, then included the file it generated in my src folder. Then with this simple code works:

#include <Arduino.h>
#include <TFT_eSPI.h>
#include "Rally_Italic12pt7b.h"

#define GFXFF 1
#define CF_SM50 &Rally_Italic12pt7b


TFT_eSPI tft = TFT_eSPI();

void setup() {
	tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_RED);
  
  tft.setTextDatum(MC_DATUM);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.setFreeFont(CF_SM50);
  tft.drawString("12:55", 160, 100, GFXFF);
}

void loop() {
	delay(1000);
}

Thanks sivar!

1 Like