How can i get a bitmap from a QFonf Object?
-
Hi!
I´m developing a little OpenGL render for text, and i want draw my textured quads using a Font Bitmap for every letter in my text.
Anyone know , how can i get from a character it´s respective font image?
This is important to me since i can them create a little character table , or dinamically draw texts in a game panel or something like that.
Any help will be much appreciated.
Kind Regards.
-
Most fonts are vector fonts so there is no image to get.
To create one you can use a QPixmap and a QPainter. Go in a loop and "draw":http://qt-project.org/doc/qt-5/qpainter.html#drawText-4 each letter to a rectangle in the pixmap.
This method is best for monospace fonts, because otherwise you'll have to store somewhere widths of the glyphs and calculating letter position in the pixmap will be harder. If you go with monospace remember to set alignment of the text to center when drawing or you will get kerning issues.