Skip to content

Instantly share code, notes, and snippets.

@unohee
Last active May 3, 2016 02:42
Show Gist options
  • Save unohee/779ca2292f801b965a8c5b56bc50149b to your computer and use it in GitHub Desktop.
Save unohee/779ca2292f801b965a8c5b56bc50149b to your computer and use it in GitHub Desktop.
#include "ofMain.h"
class ofxMeshFont2D :public ofTrueTypeFont{
public:
void loadFont(string file, int size){
ofTrueTypeFont::load(file, size,true,true,true);
}
void createNewString(string input){
letterPaths = getStringAsPoints(input);
bbox = getStringBoundingBox(input, 0, 0);
for(int i=0; i<letterPaths.size(); i++)
{
ofMesh front = letterPaths[i].getTessellation();
typeFaceMesh.push_back( front );
}
}
void drawAsMesh(){
ofPushMatrix();
ofTranslate(position);
ofTranslate(0, bbox.height/2.0);
for(int i=0; i<typeFaceMesh.size(); i++)
{
typeFaceMesh[i].draw();
typeFaceMesh[i].clear();
}
ofPopMatrix();
}
vector<ofMesh>typeFaceMesh;
ofRectangle bbox;
ofVec3f position;
protected:
vector<ofTTFCharacter> letterPaths;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment