Issue trueTypeFont drawing in Raspberry Pi 2

Hello,

I have built an app with XCode under macOS El Capitan in order to use it under Raspberry Pi 2 model B under latest Raspbian PIXEL

I am displaying a countdown using tryeTypeFont draw()

Under macOS no problem

Under Raspberry, it only displays a plain square

void Timer::drawCountdown(int maskW, int maskH) {
    if(!bTimeout && countdown >= 1) {
        string count = ofToString(countdown);
        ofRectangle contour = countdownText.getStringBoundingBox(count, 0, 0);
        
        ofSetColor(255, 255);
        
        int x, y;
        if (bCenter) {
            // Draw Center
            x = (ofGetWidth() / 2) - (contour.getWidth() / 2);
            y = (ofGetHeight() / 2) - (contour.getHeight() / 2) + countdownText.getLineHeight();
            countdownText.drawString(count, x, y);
        }
        else {
            // Draw Left
            x = (maskW / 2) - (contour.getWidth() / 2);
            y = (maskH / 2) - (contour.getHeight() / 2) + countdownText.getLineHeight();
            countdownText.drawString(count, x, y);
            
            // Draw Right
            x = ((ofGetWidth() - (maskW / 2)) - (contour.getWidth() / 2));
            y = (maskH / 2) - (contour.getHeight() / 2) + countdownText.getLineHeight();
            countdownText.drawString(count, x, y);
        }
    }
}

do you think there is anything dealing with openGL vs openGL ES ?

Hello,

I am still looking for an answer about this issue.

I still don’t understand what is going on…

Would be great if someone could explain what is going on here

thanks a lot

can you check if the fonts examples that come with OF work ok?

Hello,

yes the fontExample works great.

I do have some other font drawing in the app though, and it works fine.

void TextPicker::draw() {
    ofRectangle bounds = verdana.getStringBoundingBox(pickedText, 0, 0);
    float x = (ofGetWidth() / 2) - (bounds.getWidth() / 2);
    float y = ofGetHeight() - verdana.getLineHeight() + 5;
    ofSetColor(0, 151);
    ofDrawRectangle(x - bounds.getWidth() / 4, y - bounds.getHeight(), bounds.getWidth() + bounds.getWidth() / 2, bounds.getHeight() + bounds.getHeight() / 2);
    ofSetColor(255, 255);
    verdana.drawString(pickedText, x, y);
}

While some other part of the code doesn’t work (see image in the first post)

void Timer::drawCountdown(int maskW, int maskH) {
    if(!bTimeout && countdown >= 1) {
        string count = ofToString(countdown);
        ofRectangle contour = countdownText.getStringBoundingBox(count, 0, 0);
        
        ofSetColor(255, 255);
        
        int x, y;
            // Draw Left
            x = (maskW / 2) - (contour.getWidth() / 2);
            y = (maskH / 2) - (contour.getHeight() / 2) + countdownText.getLineHeight();
            countdownText.drawString(count, x, y);
            
            // Draw Right
            x = ((ofGetWidth() - (maskW / 2)) - (contour.getWidth() / 2));
            y = (maskH / 2) - (contour.getHeight() / 2) + countdownText.getLineHeight();
            countdownText.drawString(count, x, y);
    }
}

Here is where i draw those fonts

void ofApp::draw(){
    
    ofSetColor(255, 255);
    preview.draw();
    
    if(!timer.isTimedOut()) {
        word.draw();
        timer.drawCountdown(preview.maskW, preview.maskH);
    }
    
    if(bSetup) {
        gui.draw();
    }
}

For the record here is the logic :

1 - draw video preview
2 - draw masks on the right and left side of the preview
3 - draw a rectangle (as a background) and a word inside in the bottom of the preview (works)
4 - draw a countdown on the left and right sides (over the masks) of the preview (doesn’t work)

I added an ofParameter before for the font size and i am using it in a GUI which value i have never saved in the settings.xml

Recalling the setting didn’t throw any error but messed the font up.

I swapped off the setting.xml and saved the parameters again.

Everything is fine now.

Thanks a lot