How to pass a GFXfont (using TFT_eSPI lib)

Hi all,
I'm using the TFT_eSPI lib, with a Nodemcu v0.9 board and a 1.8"TFT display.
All works very well, but i'm stuck with a problem.

I have this:

#include "fonts/Dialog8.h"
#include "fonts/Dialog10.h"
#include "fonts/Dialog12.h"
#include "fonts/Dialog14.h"

struct editable
{
int posX;
int posY;
int fuente;
int *valor;
char **origen;
bool editar;
};

editable variables[] = { { 2, 5, <font_name>, &any, some_array, false },
{ 30, 60, <font_name>, &anymore, more_array, true } };

I need to store the font name for each variable.
The problem is I dont know how to store the font.
If I use:

tft.setFreeFont(&Dialog14);

it's work. But I need a way to point to the name of the font in order to store in the "editable" struct.
Can someone help me?

Thanks in advance, friends!

When posting code, please enclose it in code tags to make it easy to read. The code tags button is the </> one in the top left of the post editor.
It is usually also helpful to post all your code instead of just a few lines.

At a guess, maybe something like this is what you want:

struct MyFont
{
  const char* name;
  const GFXfont* font;
};

MyFont fontList[] = {
  { "font1", &FreeSerifItalic12pt7b },
  { "font2", &FreeSerifBold9pt7b },
  // { "font3", etc }
};

struct editable
{
  int posX;
  int posY;
  int fuente; // index into fontList
  int *valor;
  char **origen;
  bool editar;
};

editable variables[] = {
  {  2, 5,    1,    &any, some_array, false },
  { 30, 60,   0,    &anymore,  more_array, true  }
};

Thank you very much, arduarn. :slight_smile: