In the sketch, fonts are chosen using this code:
// Declare which fonts we will be using
extern uint8_t SmallFont;
extern uint8_t BigFont;
extern uint8_t SevenSegNumFont;
And in the library …
void UTFT::setFont(uint8_t* font)
I am completely thrown by the extern uint8_t followed by what looks like an array - declaration of font size … can someone explain to me what is really happening here, and how the library knows which font to pick based on the declaration given? Cause I see no reference to those words (SmallFont etc.) in the library.
Those fonts must be somewhere in that library. Maybe they're in a separate included file.
Either way, the extern modifier just tells the compiler that the variable isn't defined in that file. If you didn't have that line you'd get the old "not declared in this scope" error. By using extern you're telling the compiler, "it's alright, I know it's not defined here but you'll find it in another file and can use it from there.".
The libraries get compiled separately and are linked to your sketch in a later step. The 'linker' puts each library into memory and then goes to your sketch and fills in the addresses of global variables and functions that are defined in the library. The 'extern' declaration means the global variable is an array defined in a library somewhere.
When you pass BigFont to the setFont function the compiler sets aside a couple of bytes to hold the address of BigFont and marks those bytes to tell that linker to fill in the value when it knows where BigFont will land in memory.
When your sketch runs, the address of BigFont gets passed to setFont which uses that address as a pointer. Through that pointer it can reach the BigFont array. It doesn't know the size of the array, just the address, but the address should be enough.
Thank you both for your response. That does clarify things for me. I'll do a search through the library folder for any file with those key words in it .... I should then be able to see the picture a little more clearly.