What kind of font does ofDrawBitmapString use?


#1

Hey

For I project I want to use the build in font from ofDrawBitmapString, but make it bigger. It seems like you cannot change its size, so I was wondering if anybody knows what the font is called so I can load it as an ofTrueTypeFont?

Best
Andreas


#2

i don’t think you can find that font as a ttf or similar since it’s just a bitmap font that we load as an image and that originally comes from glut.

you can always scale the font using ofScale before drawing or directly use ofBitmapFont to get a mesh for a text and then scale the vertices just by multiplying them.

i’d say that this is is pretty convoluted though and would make your code hard to understand so probably the easiest would be to look for a similar font, if you look for bitmap font there’s several similar types


#3

hi arturo,

i am using the example you posted in Get mesh from ofDrawBitmapString? since using oftruetypefont compromises the framerate of my project. i’d like to scale the mesh to create a smaller font. using ofscale and oftranslate degrades the render of the text for some reason. i am scaling the vertices as suggested above, but see no change in the render.

//.h
ofBitmapFont font;
ofVboMesh textMesh;
ofRectangle bBox;

//.setup
bBox = font.getBoundingBox(somestring, 0, 0);
textMesh = font.getMesh(somestring, x + (delta - bBox.width) * .5)) , (y + delta) - ((dlta - bBox.height) * .5))); 
//centering the bounding box in shape of size(delta, delta);
for(int i = 0; i < textMesh.getVertices().size(); i ++){
    textMesh.getVertex(i) * .5; //is this the proper method to scale the mesh?
}

// draw
font.getTexture().bind();   
//    ofTranslate((x + ((size - bBox.width) * .5)), ((y + size) - ((size - bBox.height) * .5)));  
//    ofScale(.7, .7);
//    this method scales, but the bounding box does not translate to the center of my shape
textMesh.draw();
font.getTexture().unbind();

thanks,
01


#4

a trutype font has subpixel antialiasing so scaling it will look bad, you can’t just scale it by scaling the mesh, instead load several fonts each with a different size and use the size you need when drawing