Error drawing ofTrueTypeFont letters as rectangles

I’m copying the example fontsExample into a project that uses ofxNI2.
In the setup, everything with the font is correct:

    ofTrueTypeFont::setGlobalDpi(72);
    bool fontLoaded = myFont.load("helvetica.ttf", 35, true, true, true, false, 72);
    myFont.setLineHeight(1.0f);
    myFont.setLetterSpacing(1.0f);

in draw

    ofNoFill();
    ofSetColor(255,155,0);
    myFont.drawString("Testing", ofGetWidth()/2, ofGetHeight()/2);

For some reason, maybe a call inside openNI is causing the texture to draw only rectangles, not the letters.
I tried by chance to set ofDisableDepthTest(); glDepthMask(false) or glDepthMask(true).
But I can’t find what is causing that.
Any suggestion?

53

did you try stuff like wrapping the letters into some :

ofPushStyle();
ofPopStyle();

or

ofPushMatrix();
ofPopMatrix();

?

Hi Pierre,
Yes I also tried that. I started to play with gl cull face, but nothing. It looks like it’s something from ofxNI2, I replicated the project without Kinect library and the text appears as usual.

I have seen this on Android sometimes. I’m not sure what causes it exactly, but I think it is that the font has not been successfully loaded for some reason.

After calling the font first in setup, before kinect device, it started to draw the typography normally. I don’t get why kinect device is causing the issue but now it is resolved.

    ofTrueTypeFontSettings settings("helvetica.ttf", 24);
    settings.antialiased = true;
    bool fontLoaded= theFont.load(settings);

It seems to me that ofTrueTypeFont could really use ways to test and ensure a font is loaded correctly.