Selecting Fonts, Adafruit_mfGFX , setfont() TROUBLE

Hey guys,
Was wondering if anyone else encountered this problem with the ported GFX library. When i try set the font to the “given” fonts in the font.cpp file. It just selects the default font (GLCDFONT).

void loop() {
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);
  tft.setCursor(100, 0);
  tft.setTextColor(ILI9341_WHITE,ILI9341_MAGENTA);  tft.setTextSize(2);
  // x = x+0.524;
  // delay(300);
  tft.setCursor(0, 100);
  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(2);
  tft.setCursor(100, 100);
  tft.setTextColor(ILI9341_WHITE,ILI9341_MAGENTA);  tft.setTextSize(2);


Are these fonts actually included by setting the respecitve compiler directives?

See this in fonts.h

//Font selection for compiling - comment out or uncomment definitions as required
//NOTE: GLCDFONT is default font and always included
//#define ARIAL8
//#define COMICSANSMS8
//#define TESTFONT

// Font selection descriptors - Add an entry for each new font and number sequentially
#define TIMESNR_8	0
#define CENTURY_8	1
#define ARIAL_8		2
#define COMICS_8	3
#define GLCDFONT	4
#define TEST		5

#define FONT_START 0
#define FONT_END 1

Granted, that’s not going to work in Web IDE, since you can’t edit fonts.h but maybe @peekay123 can elaborate how he’d intended to tackle this when he contributed this library.

1 Like

@ScruffR, when I post the library, the control of included fonts was something I did not have a solution for. The #defines are there to limit the amount of flash to only the desired fonts and the current Web IDE doesn’t allow for any editing or control of compile flags.

My best recommendation is to copy the library files to tabs in the current app or use CLI and make a local copy of the library so as to be able to modify the .h file.


This would make a nice feature Web IDE should have implemented right from the beginning. Like Desktop IDE (Dev) has an Import vs. Copy option in Library Manager.
Hopefully the new IDEs will allow for that.


I use the Particle DEV to edit the .H files for changing the included Fonts easily.

1 Like

@ScruffR and @peekay123 Thanks :slight_smile: it was the #define. time to add my own fonts :stuck_out_tongue_winking_eye:

1 Like

Got my fonts working, good instruction @peekay123! @ScruffR a sort of unrelated question. Is it possible to check the Flash usage on Desktop IDE?