hironishihara / ofxTrueTypeFontUC

An extension of ofTrueTypeFont class for using UNICODE characters. Tested on OSX, iOS, and Windows.
Other
116 stars 46 forks source link

getStringMesh() and getFontTexture() #22

Open saki7 opened 8 years ago

saki7 commented 8 years ago

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).

hironishihara commented 8 years ago

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.

saki7 commented 8 years ago

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...

hironishihara commented 8 years ago

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.

saki7 commented 8 years ago

Another typography class, huh? Sounds great! Looking forward to seeing that in progress. I'll check drawStringAsShapes() and see if it works.