⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
How can i get a bitmap from a QFonf Object?
wwolff last edited by
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.
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.