Trying to make/understand font file for adding to a sketch

Let me start with Coding is not my strong point..
I have a sketch for a 8x8 led matrix to display scrolling text. (I did not write it, just borrowed it :slight_smile: )
(Thank you Andrew who ever you are)
the letters displayed on the matrix are defined in the sketch (see below)

I can see font .h files added to other peoples sketches, I assume the whole alphabet + numbers
and symbols is defined in the file.

In this sketch the letters are a 5x7 font defined in decimal form
EX: #define R {127, 72, 76, 74, 49}

Is there a better way to do this?
Every time I change the sketch to display something new I have to add a new #define of the symbol,letter or whatever.
Can I make a Complete font file that can be called by importing a library within a sketch?

what is the best format for defining letters,numbers, and symbols?
I have seen the letter "A" defined different ways, hex, decimal, binary.....

how do you call the letters, to be used from a font file to the sketch?

Remember, coding is not my strong point

Thank Tim

/*
 * Show messages on an 8x8 led matrix (cathode rows),
 * scrolling from right to left.
 *
 * Pinouts & code by Andrew
 */

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 8, 9, 10, 11, 12, 13, 6, 7};
// (for some reason I ended up with different pinouts that Andrew's)

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

// Letter definitions based on 5 bit-wise columns (5 x 7 font)

#define SM {98,97,9,97,98}      // Smiley
#define LE {0,251,251,0,0}      //Thick Exclamation
#define SP {0, 0, 0, 0, 0}      //Space
#define EX {0, 125, 0, 0, 0}    // !
#define PE {1,0,0,0,0}          //.
#define A {31, 36, 68, 36, 31}
#define B {127, 73, 73, 73, 54}
#define C {62, 65, 65, 65, 34}
#define D {127, 65, 65, 34, 28}
#define E {127, 73, 73, 65, 65}
#define F {127, 72, 72, 72, 64}
#define G {62, 65, 65, 69, 38}
#define H {127, 8, 8, 8, 127}
#define I {0, 65, 127, 65, 0}
#define J {2, 1, 1, 1, 126}
#define K {127, 8, 20, 34, 65}
#define L {127, 1, 1, 1, 1}
#define M {127, 32, 16, 32, 127}
#define N {127, 32, 16, 8, 127}
#define O {62, 65, 65, 65, 62}
#define P {127, 72, 72, 72, 48}
#define Q {62, 65, 69, 66, 61}
#define R {127, 72, 76, 74, 49}
#define S {50, 73, 73, 73, 38}
#define T {64, 64, 127, 64, 64}
#define U {126, 1, 1, 1, 126}
#define V {124, 2, 1, 2, 124}
#define W {126, 1, 6, 1, 126}
#define X {99, 20, 8, 20, 99}
#define Y {96, 16, 15, 16, 96}
#define Z {67, 69, 73, 81, 97}

int dispSpeed = 10;					 // Constrols scroll speed (1 minimum, way too fast)
byte bit[8] = {128, 64, 32, 16, 8, 4, 2, 1};	// Used for bit comparisons
byte colVals[8] = {0, 0, 0, 0, 0, 0, 0, 0};	 // Hold display columns (initaly blank)

// Define display string here
const int charNum = 25;				    // Number of letters in display string
//byte string[charNum][5] = {LE,SP,SP};
byte string[charNum][5] = {T,I,M,SP,I,S,SP,T,H,E,SP,G,R,E,A,T,E,S,T,LE,SP,SM,SP,SP};
//byte string[charNum][5] = {A,R,D,U,I,N,O,SP,R,O,C,K,S,EX,SP,SP};

void setup() {
  Serial.begin(9600);			  // for troubleshooting
  for (int i = 1; i <= 16; i++) {	  // sets the pins as output
    pinMode(pins[i], OUTPUT); }
  for (int col = 0; col < 8; col++) {    // set up cols and rows
    digitalWrite(cols[col], HIGH);  }
  for (int row = 1; row < 8; row++) {
    digitalWrite(rows[row], HIGH);
  }
  Serial.println(availableMemory());     // 670 bytes for charNum = 15
}

void loop() {

  for (int ltr = 0; ltr < charNum; ltr++){// For each letter in string array
    for (int y = 0; y < 6; y++){	    // For each columin in letter + one space
	shiftLeft();				// shifts display columns left
	if (y < 5){
	  colVals[7] = string[ltr][y]; }    // add new letter column on right
	else {colVals[7] = 0; }		 // or empty space between
	for (int x = 0; x < dispSpeed; x++){// loop to refresh display x times ton control scrolling
	  display();
	}
    }
  }
}


void shiftLeft(){
 for (int x = 0; x < 7; x++){
  colVals[x] = colVals[x + 1];
 }
}


void display() {

   for (int col = 0; col < 8; col++){
    for (int row = 0; row < 8; row++){
	if (colVals[col] & bit[row]){
	  digitalWrite(rows[row], HIGH);}
	}
    digitalWrite(cols[col], LOW);  // Turn on column
    delay(1);  // Delay for POV
    for (int row = 0; row < 8; row++){
	digitalWrite(rows[row], LOW);
    }
    digitalWrite(cols[col], HIGH);  // And off
  }
}

// this function will return the number of bytes currently free in RAM
// written by David A. Mellis
// based on code by Rob Faludi http://www.faludi.com
int availableMemory() {
  int size = 1024;
  byte *buf;
  while ((buf = (byte *) malloc(--size)) == NULL);
  free(buf);
  return size;
}

I can see font .h files added to other peoples sketches, I assume the whole alphabet + numbers
and symbols is defined in the file.

In this sketch the letters are a 5x7 font defined in decimal form
EX: #define R {127, 72, 76, 74, 49}

Is there a better way to do this?
Every time I change the sketch to display something new I have to add a new #define of the symbol,letter or whatever.
Can I make a Complete font file that can be called by importing a library within a sketch?

Importing a header file, yes. A library is a header file and matching source file located in a libraries folder. That won't be what you have. People typically name that header file font.h for some strange reason.

what is the best format for defining letters,numbers, and symbols?
I have seen the letter "A" defined different ways, hex, decimal, binary.....

Whichever way makes most sense to you.

how do you call the letters, to be used from a font file to the sketch?

Just like you do here:

byte string[charNum][5] = {T,I,M,SP,I,S,SP,T,H,E,SP,G,R,E,A,T,E,S,T,LE,SP,SM,SP,SP};

Instead of #define A SomeValues, you could have const byte A = {SomeValues};
Then, when you want to print "A big mess", you would loop through each letter ('A', ' ' , etc.) and use an if statement to determine what to print:

switch (letter)
{
   case 'A': print(A); break;
// More cases
}

Thank you for the information...