Using ofTrueTypeFont when using Kinect v2 -> SOLVED!

I’m working with the Kinect v2 to capture the skeleton. And then I tried to draw a time counter on the screen using ofTrueTypeFont by printing time. But I’ve just realized that ofTrueTypeFont has been decreasing frame count with a considerable amount which makes my application so slow.

How can I print styled text without any loss? sorry my english. :stuck_out_tongue:

Hi, that sounds odd. can you please post the code you are using?
(I see no issues with your english) :slight_smile:

I try to post it in short. Because my code is too much to post all of it.


//counting time

ofSetColor(247, 157, 0);
int ti = (endTimer - ofGetElapsedTimeMillis()) / 60000;
int se = (endTimer - ofGetElapsedTimeMillis()) / ((ti + 1)*1000);
string strTime = "0" + ofToString(ti) + ":" + ofToString(se) + "";
myFont.load("/fonts/ITCKRIST.TTF", 20);
myFont.drawString(strTime, 350, 85);


//here kinect codes 
auto bodies = kinect.getBodySource()->getBodies();
		auto boneAtlas = ofxKinectForWindows2::Data::Body::getBonesAtlas();
		for (auto body : bodies) 
               //getting bodies

Hi, the problem is quite evident.
You are loading the font in the draw function. This means that it is reading the font file and loading each time that you are drawing, this is why the performance drops when you activate that part of the code.
Move the following line from the draw() function into the setup() function

myFont.load("/fonts/ITCKRIST.TTF", 20);

and your problem will go away

1 Like

Thank you so much. It works. :blush: