minipop
#1
Hi, i’m trying to get points of a string with getStringAsPoints();
like getCharacterAsPoints(); in fontShapesExample
but i can’t find a way to do this
i’m doing something like this but i’m getting a bunch of errors
String letter;
letter = "hey";
testFont.loadFont("Batang.ttf", 60, true, true, true);
testFont.getStringAsPoints(letter);
ofBeginShape();
for(int k = 0; k <(int)testFont.getOutline().size(); k++){
if( k!= 0)ofNextContour(true) ;
for(int i = 0; i < (int)testFont.getOutline()[k].size(); i++){
ofVertex(testFont.getOutline()[k].getVertices()[i].x, testFont.getOutline()[k].getVertices()[i].y);
}
}
ofEndShape( true );
a couple notes:
- when you’re writing code, compile regularly to check for errors. the first bug is that you wrote “String” instead of “string”.
- getStringAsPoints() returns a vector, but you’re not doing anything with that. you can remove that line of code.
can you try fixing that, and then posting more details about what errors you’re getting exactly?
Mauro
#3
I try to do the same thing and it works:
void testApp::draw(){
string letter = "hey";
ofTrueTypeFont testFont;
testFont.loadFont("verdana.ttf", 60, true, true, true);
ofPoint startPos;
startPos.x = 0;
startPos.y = ofGetWindowHeight() * .5;
vector<ofTTFCharacter> characters = testFont.getStringAsPoints(letter);
for(int k = 0; k < characters.size(); k++)
{
for(int j = 0; j < characters[k].getOutline().size(); j++)
{
if(j>0)
ofSetColor(255, 0, 0);
else
ofSetColor(255, 255, 255);
ofBeginShape();
for(int i = 0; i < characters[k].getOutline()[j].size(); i++)
{
ofVertex(startPos.x + characters[k].getOutline()[j][i].x, startPos.y + characters[k].getOutline()[j][i].y);
}
ofEndShape();
}
}
}
but i don’t know how i can detect if one path is inside one other. Maybe i only need to check if one point is inside other path.