Hallo,
When I’m drawing text using ofTrueTypeFont::drawString(), special characters like ä,Þ… are rendered correctly. When I’m using the getFontTexture function to render the same string, it isn’t working.
Here a demonstration code for illustration:
void testApp::setup(){
ofBackground(0, 0, 0);
ofSetFrameRate(1);
ofSetVerticalSync(true);
font.loadFont("univer.ttf", 70, true, true, false);
test_1 = "norÞ";
test_2 = "hällo";
mesh_1 = font.getStringMesh(test_1, 0, 0);
mesh_2 = font.getStringMesh(test_2, 0, 0);
txt_vertices_1 = mesh_1.getVertices();
txt_vertices_2 = mesh_2.getVertices();
}
void testApp::draw(){
ofSetColor(255);
font.drawString(test_1, 100, 100);
font.drawString(test_2, 100, 200);
mesh_1.clearColors();
mesh_2.clearColors();
for(int i=0; i<mesh_1.getVertices().size(); i++){
mesh_1.setVertex(i, txt_vertices_1[i]+ofVec3f(100, 300, 0));
mesh_1.addColor(ofFloatColor(1,0,0));
}
ofSetColor(0, 255, 0);
for(int i=0; i<mesh_2.getVertices().size(); i++){
mesh_2.setVertex(i, txt_vertices_2[i]+ofVec3f(100, 400, 0));
mesh_2.addColor(ofFloatColor(0,1,0));
}
collector.clear();
font.getFontTexture().bind();
collector.append(mesh_1);
collector.append(mesh_2);
collector.draw();
font.getFontTexture().unbind();
}
This is how my render looks like: screenshot
It seems like getFontTexture() is working with another charset or another encoding than the drawString() is using. Any ideas how I could fix this?
thanks for help,
wun