TFT_eISP custom font does not work all of a sudden <SOLVED>

Hello

Found the excellent page where you can make almost any font you want (I would like a 100p Arial but nope) but are going through those that are there and hope I find one as similar as possible.

I did one font before that was 75p and it worked flawlessly but wasn't really perfect so I took another font and made it a little bigger in 100p and now it complain that it is not declared which I don't get.

I guess its something very obvious but I just can't see it and it feels like I have tested everything.

#include <TFT_eSPI.h> // Hardware-specific library
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();       // Invoke custom library

#include "Fonts/Arimo100.h"

void setup(void) {

  tft.init();

  tft.setFreeFont(&Arimo100);

  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  
  tft.setCursor(0, 100);

  tft.print("E+-0123456789");
}

void loop() {


}

The code might not be exactly the same in the above and in the files since I have tested so much in between.

And btw what is the reason for the "&" sign before the font name in the program?

Files.zip (15.6 KB)

/Kevin

You named the font Arimo_Regular_100, not Arimo100.

The & passes the memory address of Arimo100 to the function, instead of the data stored there.

Hello

There is a limit on how big an array can be, on 8-bits arduinos this limit is 32768 bytes, and unfortunately your array Arimo_Regular_100Bitmaps has a size of 34378 bytes

TFT_eSPI only runs on ARM and ESP Targets. There is no restriction on array size.

Seriously, start with library examples.

From the font file in your ZIP

const GFXfont Arimo_Regular_100 PROGMEM = {

which means that your sketch should say

tft.setFreeFont(&Arimo_Regular_100);

David.

Aha, knew it had to be something simple and thanks for the "&" explanation that makes of course total sense.

Yes I did start with library examples and did the same there but naively thought that as long as the font file had the same name everywhere in the sketch the name there wouldn't matter since I thought it would take whatever it needed from the file included the real name of it and such so you could then write much less amount of text when activate a font instead of the entire name every time and so on, but obviously that is not how it works. Haven't tested it yet but will when I get home.

And of course it work as it should, thanks!

I'm quite sure I did that with the other font but missed that, oh well.

The Adafruit FreeFont header files use the same name for the Font object as the filename.

Just be careful with random FreeFont files. Check the actual GFXfont object name.

Got it and I have learned that now, thanks.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.