getStringMesh() and getFontTexture()
saki7 opened this issue · comments
ofTrueTypeFont
provides these two functions for caching string in draw phase:
ofTrueTypeFont font;
// load fonts...
ofVboMesh mesh;
void update()
{
if (needs_update) {
std::string const str = some_updated_string();
mesh = font.getStringMesh(str, 0, 0);
}
}
void draw()
{
font.getFontTexture().bind();
mesh.draw();
font.getFontTexture().unbind();
}
So is there any way to provide this in ofxTrueTypeFontUC
?
I know it's a bit tricky since the texture in ofxTrueTypeFontUC
is divided into each chars, but in ofTrueTypeFont
, is not (which is concatenated, I think).
ofTrueTypeFont
has a atlas texture texAtlas
and loads all ASCII chars at once in load()
.
While on the other hand, ofxTrueTypeFontUC
cannot load all chars in advance.
So, ofxTrueTypeFontUC
allocates a texture to each char called.
Large scale modification will be needed to provide getStringMesh()
, I think.
I'm afraid it is.
I have my project drawing widgets around 1 to 100 and the FPS will drop from 90~ to 30~ due to the drawString()
. Caching a string mesh would be a very nice feature...
I think so, too. But there is no plan to provide the caching mesh feature to ofxTrueTypeFontUC
in the near future. (I'm thinking that I want to make another typography class...)
By the way, in ofxTrueTypeFontUC
,drawStringAsShapes()
is more faster than drawString()
in some cases. For your information.
Another typography class, huh? Sounds great! Looking forward to seeing that in progress.
I'll check drawStringAsShapes()
and see if it works.