font char with ofxBox2d

Anyone used ofxBox2d with font , i mean add physics behavior to fonts with ofxBox2d lib? if someone already did this , please let me know.

Yes this should be very possible. A way to go about it would be to use ofTrueTypeFont which lets you get each x , y point of a character and add this to a box2D polygon. You would probably only need to grab the points from the outer most contour. Looking at the box2D examples ( ) if you combined ComplexPolygonExample with the Open Frameworks FontShapesExample that should have everything you need.

i was looking to the ComplexPolygonExample and i was wondering how grab vertices for the Polyline but you give me a good input with ofTrueTypeFont . i think in this way shouldn’t be too difficult to do this. I will post my result on the forum.

I have some result,see the picture attached , there is an ‘A’ char but all vertices are connected. I found this post that i think it will help me:
here a bit of code:

// in testApp::setup()  
 vector<ofTTFCharacter> str = ttf.getStringAsPoints(text);  
    ofPath ch = ttf.getCharacterAsPoints(letter);  
    vector<ofPolyline> outline = ch.getOutline();  
    vector <ofVec2f> pts;  
      for (int j=0; j<outline.size(); j++) {  
        int iMax = outline[j].getVertices().size();  
        for (int i=0; i<iMax; i++) {  
            ofVec2f a = outline[j].getVertices()[i];  
         ofxBox2dPolygon poly;  
	// loop and add vertex points  
	for (int i=0; i<pts.size(); i++) {  
	poly.triangulate(10.4, 1);  
	poly.setPhysics(1.0, 0.3, 0.3);  


I got stuck on a similar issue. I just noticed the post you linked to does the triangulation of the points differently, with ‘getTessellation’ rather than ‘triangulate’. Not had chance to try it yet but could that be the way of making valid triangulated polys from the font’s contours?

Cheers, sCam