Font not Loading — even if it's in the data folder and declared

Hi,

I am having trouble with loading a Font.
The font is in the data folder and I am loading it in the setup().
I am even checking that it is loaded with .isLoaded() method.
Still, I get:

[ error ] ofTrueTypeFont: drawString(): font not allocated

If I start a project from scratch and load a font it works, so it must be something about my project.
It’s a project that communicates OSC messages with Ableton Live to produce visuals.
It has multiwindows, with GUI.

I’ll post my code. If you see something that might be causing the problem, or any ideas I can try please let me know! Thanks.

Here’s my main:

int main( ){
    
    ofGLFWWindowSettings settings;
    settings.width = 1280;
    settings.height = 720;
    settings.setPosition(ofVec2f(300,0));
    settings.resizable = true;
    shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
    
    settings.width = 300;
    settings.height = 800;
    settings.setPosition(ofVec2f(0,0));
    settings.resizable = false;
    // uncomment next line to share main's OpenGL resources with gui
    settings.shareContextWith = mainWindow;
    shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);
    guiWindow->setVerticalSync(false);
    
    shared_ptr<ofApp> mainApp(new ofApp);
    mainApp->setupGui();
    ofAddListener(guiWindow->events().draw,mainApp.get(),&ofApp::drawGui);
    
    ofRunApp(mainWindow, mainApp);
    ofRunMainLoop();

}

ofApp.h:

#pragma once

#include "ofMain.h"
#include "OSC.hpp"
#include "store.hpp"

#include "ofxGui.h"
#include "ofxXmlSettings.h"
#include "ofxOsc.h"

#define portIN 2346
#define portOUT 1234
#define host "192.168.1.67"



class ofApp : public ofBaseApp{

	public:
		void setup();
        void setupGui();
		void update();
		void draw();
        void drawGui(ofEventArgs & args);

		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void mouseEntered(int x, int y);
		void mouseExited(int x, int y);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
		
        ofParameterGroup allParameters;
    
        ofVideoPlayer video;
        ofFbo fboL, fboR;
        ofxPanel gui;
        OSC osc;

        ofTrueTypeFont verdana;
    
    
};

and ofApp.cpp:

#include "ofApp.h"

// This app works along with two M4L devices:

//      1. MultiMapperOSC device‚ for knob controllers
//      2. PMCA OSC MIDI Send on off‚ for MIDI notes


// 1. Input amount of desired controls to be mapped
// 2. Input the ID number of the M4L device
// 3. Input their labels
// 4. Input scaling factor (= maximum desired value for given parameter)

// HERE:

int connectionsNum = 5; // 1. AMOUNT of params. Set amount of params here
int initialID = 1; // 2. ID. Set ID of M4L device
string labels[2][5]  = {
    {"one", "two", "three", "four", "five"},
    {"1", "2", "3", "4", "5"}
};  // 3. LABELS. Input array's second dimension = connectionsNum. Set the labels here: first row is label of slider, second row is label of slider button
float scaling[5] = {10, 20, 30, 40, 50}; // SCALING. Input size of array = connectionsNum; then input desired maximum value for each parameter


// To map:
//      a. move a knob in M4L device, wait for one second
//      b. move the second slider of the desired parameter in openFrameworks' GUI window


float height, width, mouseX, mouseY;
int wA, hA, wB, hB;
//bool one, two, three, four, five, six, seven;
int smallFboNum = 5;
vector<float> times(5, 0);
vector<ofFbo> smallFbos;
bool guiSetup = false;
bool trigger;
int note, velocity;
bool loaded = false;



vector<string> text;
vector<OSC> connections;
vector<store> params;
vector<float> vals;
vector<store*> paramPointers;

string verses[] = {"THE INDIAN COULD NOT LIVE A LIFE",
    "THAT WAS HEMMED ABOUT BY WALLS",
    "AND ONE DAY",
    "HE WENT OFF IN SEARCH OF HIS WILDERNESS",
    "I WOULD LIKE TO KNOW",
    "WHAT HE FELT IN THAT MOMENT OF VERTIGO",
    "WHEN PAST AND PRESENT INTERMINGLED",
    "I WOULD LIKE TO KNOW",
    "WHETHER THE LOST SON",
    "REBORN AND DIED IN THAT ECSTATIC MOMENT",
    "AND WHETHER HE EVER MANAGED TO RECOGNIZE",
    "EVEN AS LITTLE AS A BABY OR A DOG MIGHT",
    "HIS PARENTS AND THE HOUSE",
};



//--------------------------------------------------------------
void ofApp::setup(){
    
    ofBackground(0, 0, 0);
    
//    verdana.load("verdana.ttf", 72, false);

    if (loaded == false) {
        bool test;
        verdana.load("verdana.ttf", 72);
        test = verdana.isLoaded();
        cout << "is verdana loaded?: " << test << endl;
 //        cout << "verdana loaded" << endl;
        loaded = true;
    }

    
    for (int i = 0; i < 2; i++) {
        cout << "row " << i << endl;
        for (int j = 0; j < 5; j++) {
            cout << "col " << j << endl;
            cout << labels[i][j] << endl;
        }
        cout << endl;
    }
    
    height = float(ofGetHeight());
    width = float(ofGetWidth());
    
    
    wA = ofGetWidth()/2;
    hA = ofGetHeight()/2;
    
    wB = ofGetWidth()/5;
    hB = ofGetHeight()/2;
    
    fboL.allocate(wA, hA);
    fboR.allocate(wA, hA);
    
    for (int i = 0; i < smallFboNum; i++) {
        ofFbo fbo;
        smallFbos.push_back(fbo);
        smallFbos[i].allocate(wB, hB);
        smallFbos[i].begin();
        ofBackground(0, 0, 0);
        //ofSetColor(0);
        //ofDrawRectangle(0, 0, wB, hB);
        smallFbos[i].end();
    }
    

    
    //  OSC stuff:
    
    osc.setup(portIN, portOUT, host);   //ofApp osc setup — needed?

    for (int i = 0; i < connectionsNum; i++) {
        store param;
        params.push_back(param);
        params[i].setup();      //     setup OSC for each param:
        params[i].setLabels(labels[0][i], labels[1][i]);     //     set their labels
        params[i].set(initialID, i);     //     set initial Mappings (M4L ID, knob number
        params[i].printLabel();         //     and print their labels into M4Live device in Ableton:
//        store* paramPointer;
//        paramPointers.push_back(paramPointer);
//        paramPointers[i] = &params[i];
    }
    
    
    cout << "INITIAL VALUES: " << endl;
    
    // initialize float values at arbitrary 0.7:
    for (int i = 0; i < connectionsNum; i++) {
        float val = 0.7; //intial value is arbitrary
        vals.push_back(val);
        cout << "value of vals at index " << i << ": "<< vals[i] << endl;
    }
    
    cout << endl;
    
    cout << "Params size: " << params.size() << endl;
//    cout << "paramPointers size: " << paramPointers.size() << endl;

    fboL.begin();
    ofBackground(0, 0, 0);
    fboL.end();
    
    fboR.begin();
    ofBackground(0, 0, 0);
    ofSetColor(256, 0, 0);
    ofDrawRectangle(0, 0, wA, hA);
    fboR.end();
  
    
    video.load("Jen.mov");
    video.play();
    
}

//--------------------------------------------------------------
void ofApp::setupGui() {
    ofBackground(255);
    

//        bool test;
//        verdana.load("verdana.ttf", 72);
//        test = verdana.isLoaded();
//        cout << "is verdana loaded?: " << test << endl;


    
    if (ofGetElapsedTimef() > 0.5) {
        for (int i = 0; i < connectionsNum; i++) {
            params[i].getLabels();
            params[i].setupGUI(scaling[i]/2, 0, scaling[i], 0, 0, 1);
            allParameters.add(params[i].parameterGroup);
            }
        }
    
    gui.setup(allParameters);
    ofSetBackgroundColor(0);
    
}

//--------------------------------------------------------------
void ofApp::update(){
    
    osc.update();
    int tempID = osc.getID();

    int tempKnob = osc.getKnob();
    float arg = osc.getArg();
    float time = osc.getTimeStamp();
    
    trigger = osc.getTrigger();
    note = osc.getNote();
    velocity = osc.getLastVelocity();

    
    if (ofGetElapsedTimef() > 4) {
        for (int i = 0; i < connectionsNum; i++) {
            vals[i] = params[i].update(tempID, tempKnob, arg, time, scaling[i]);
            }
    }

    video.update();
    
    fboL.begin();
    video.draw(0, 0, wA, hA);
    fboL.end();
    
        if (ofGetElapsedTimef() > 0.5 && guiSetup == false) {
            setupGui();
            guiSetup = true;
        }
  
    // INTENTAR DIBUJAR PARA FBOS PARA AQUELLAS NOTAS QUE ESTEN PRENDIDAS
    
    for (int i = 0; i < sizeof(verses); i++) {
        int theVelo = osc.getVelocity(i+37);
        if ( theVelo > 0) {
            int randomFbo = 4;
            cout << "randomFbo: " << randomFbo << endl;
            smallFbos[randomFbo].begin();
            ofSetColor(255, 255, 255);
            smallFbos[randomFbo].end();
        }
    }
    
    
}

//--------------------------------------------------------------
void ofApp::draw(){

    ofBackground(0, 0, 0);
    fboL.draw(0, 0);

    
    for (int i = 0; i < smallFboNum; i++) {
        smallFbos[i].draw(i*wB, hB);
    }



    ofSetColor(255, 255, 255);
    verdana.drawString("Hello", 100, 100);
    
    
    ofDrawBitmapString("frame rate" + ofToString(ofGetFrameRate()), 20, 20);
    ofDrawBitmapString("note: " + ofToString(note), 20, 35);
    ofDrawBitmapString("vel:  " + ofToString(velocity), 20, 50);
    ofDrawBitmapString("trig:  " + ofToString(trigger), 20, 65);
    
    
}

//--------------------------------------------------------------
void ofApp::drawGui(ofEventArgs & args){
    gui.draw();
    

    
    
}


//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    if (key == 'x') {
        

        mouseX = float (ofGetMouseX()) / 1. / float(width) * 100.;
        mouseY = float(ofGetMouseY()) * 1.0 / float(height) * 1.0 * 5.0;

        cout << "mouseX is: " << mouseX << endl;
        cout << "mouseY is: " << mouseY << endl;
        int totalFrames = video.getTotalNumFrames();
        cout << "totalFrames is: " << totalFrames << endl;
        int newPos;
        newPos = int (mouseX * totalFrames / 100 );
        cout << "newPos is: " << newPos << endl;
        cout << endl;
        video.setFrame(newPos);
        video.setSpeed(mouseY);
        video.play();
    }

    if (key == 'y') {
        cout << "mouseY is: " << mouseY << endl;
    }

    
    if (key ==  'p') {
        cout << endl;
        cout << "ID: " << osc.getID() << endl;
        cout << "Knob: " << osc.getKnob() << endl;
        cout << "Value: " << osc.getArg() << endl;
        cout << "TimeStamp: " << osc.getTimeStamp() << endl;
        cout << "one: " << vals[0]  << endl;
        cout << "two: " << vals[1] << endl;
        cout << "three: " << vals[2] << endl;
        
    }
    
    
}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){ 

}