@csw wrote:
I am loading a font and getting the polyline outline of a character. I’m then getting the bounding box of the polyline and drawing the same character at the bounding box position (bottom left). For some reason there is a small gap in the x axis before the character is drawn, but the bounding box is draw at the correct position.
Can anyone explain to me why this is happening?
Thanks!
ofTrueTypeFont font; vector <ofPolyline> polylines; //-------------------------------------------------------------- void ofApp::setup(){ font.load("verdana.ttf", 150, true, true, true, 0.3, 0); ofTTFCharacter ttfChar = font.getCharacterAsPoints('a'); polylines = ttfChar.getOutline(); } //-------------------------------------------------------------- void ofApp::draw(){ ofNoFill(); ofPushMatrix(); ofTranslate(100, 500); ofRectangle r = polylines[0].getBoundingBox(); //this is drawn in the correct place ofSetColor(255,0,0); ofDrawRectangle(r); //this is drawn in the correct place ofSetColor(0, 255, 255); font.drawString("a", 0, 0); //this is drawn in the wrong place ofSetColor(255,0,255); font.drawString("a", r.getBottomLeft().x, r.getBottomLeft().y); ofPopMatrix(); }
Posts: 1
Participants: 1