apologies for the simpleness, i did a search but couldnt find anything to suit my needs.
i need to make a simple cube and have a letter showing on one face, the letter needs to change freely. i understand .ttf files are basically a picture with individual texture coordinates mapped out, but how can i access each individual slice and map it to a primitive surface?
I think the fastest way would be drawing your fonts into ofFbo objects (so you can change them dynamically) and use their textures (yourFBO.getTextureReference()) on your cube/mesh/whatever
i have a little addon called ofxWordPalette which let’s you specify a list of input words, it renders them to an fbo canvas, and then you can draw them and get texture coordinates for each word. Maybe not exactly what you need, but it gives a specific example of what you’d trying to do:
thank you chaps, some stuff to try there. i was hoping though to be able to load a ttf as a texture, then somehow query it for which texture coordinates based on a character. i could do it by making an array of texture coordinates then retrieving them in a readable way but i thought this sort of thing may have been done before, i thought this sort of data would be held within a ttf?
if you just want to use a char as a texture, the easiest right now as naus3a said is drawing it to an fbo and using the fbo as a texture.
Internally ofTrueTypeFont creates a texture atlas (a big texture with all the fonts) and then creates quads with vertexes and texture coordinates to draw each char in a string in the right position.
It could be useful to be able to get access to that texture atlas and the right texture coordinates for each char but that doesn’t exist yet and want be much different from drawing the char to an fbo except it will be faster
You don’t really need to access the glyph metrics for this but if you want to access them take a look at how ofTrueTypeFont works internally, you’ll need to use FreeType directly for that.
[quote=“arturo, post:7, topic:8153”]
if you just want to use a char as a texture, the easiest right now as naus3a said is drawing it to an fbo and using the fbo as a texture.
Internally ofTrueTypeFont creates a texture atlas (a big texture with all the fonts) and then creates quads with vertexes and texture coordinates to draw each char in a string in the right position.
It could be useful to be able to get access to that texture atlas and the right texture coordinates for each char but that doesn’t exist yet and want be much different from drawing the char to an fbo except it will be faster
You don’t really need to access the glyph metrics for this but if you want to access them take a look at how ofTrueTypeFont works internally, you’ll need to use FreeType directly for that.
[/quote] cool, ill give the drawing to fbo a go, cheers.
ok im having problems with the fbo, i can’t find any documentation or an example that is trying to do what im doing. i tried editing the ofbox example and just got what looked like a screenshot of what was in my web browser at the time. ive set up this empty example so i could paste it in and ask if theres anything im doing wrong.
You can just draw the FBO directly, also I think you need to call ofClear() in between ofFbo.begin() and ofFbo.end() to avoid anything else getting glommed into your fbo.
ofEnableAlphaBlending(); // make sure we can alpha blend
fbo1.allocate(bounds.width, bounds.height);
fbo1.begin();
ofClear(0, 0, 0, 0); // clear it out
ofSetColor(255);
verdana14.drawString(someText, 0, bounds.height); // this causes some stretching
fbo1.end();