trueType font loading problem on .h file [SOLVED]

Hi all OF lovers,

so I have this problem:

in myMtRotatableScalableItem.h file, while using the MTActions example i get this warning:

OF: OF_LOG_ERROR: ofTrueTypeFont::drawString - Error : font not allocated – line 726 in /Users/admin/Desktop/of_preRelease_v007_osx/libs/openFrameworksCompiled/project/osx/…/…/…/openFrameworks/graphics/ofTrueTypeFont.cpp

the code for this ttf load is:

  
  
class myMtRotatableScalableItem : public ofxMtActionsObject{  
	  
public:  
	  
  
	myMtRotatableScalableItem(){  
		franklinBook.loadFont("frabk.ttf", 26);  
		rotation = ofRandom(1.0f, PI*2.0f);  
	}  
	  
	...  
        ....  
	ofTrueTypeFont  franklinBook;  
  
};  

I checked the bin/data/ folder has the type. So, which mistake are we doing here???

thank you !

this is a bug that was closed by https://github.com/openframeworks/openFrameworks/issues/734. you have three options:

1 download the latest OF from github (it’s a very large download)
2 wait for the next version of OF to be released (no guarantees)
3 move the loadFont() into your myMtRotatableScalableItem::setup() instead of the constructor

Hi kyle,

so i just did what you said, moved loadfont() to the draw() function in .h file. And it worked !!!

So thank you very much, again. What a good of community we have !!

By the way, i am migrating my processing code to OF, that is used in our app tangiblex.Alive (check www.tangiblex.net). So i will need a good Multitouch framework or classes. That is why i am looking to smallfly “multitouchAction” example, which is good. With the info I will learn i will make a tutorial about MT in OF, which is a topic that i think will be interesting. Any ideas about other tutorials, examples?

thank you!
miguel.
www.tangiblex.net

hi miguel – glad it worked! setup() is better than draw() because it’s a bad idea to load the font every frame. it will make your app very slow.

multitouch isn’t really my specialty, i only know a little about CCV and that’s it. maybe someone else here knows more?