Important: Please read the Qt Code of Conduct -

What would be the best way to rasterize or render a font to some kind of image or array with QT

  • So what I want to do is to be able to write text to something that I can feed into OpenGL and then do transformations on. The thing is that I don't want to do this with OpenGL because I want to interact with it which would make messy code. I don't want to make sprite sheets because there could be limitations to this. Size and number of fonts and that I would like to be able to load them from byte arrays. I have looked for information on this stuff and only found 2 places that explain this stuff and both of them aren't very clear. Do you have to sell your soul to learn this?

  • Moderators

    the simplest way is probably to use a QPainter on an QImage

    int main(int argc, char *argv[])
        QApplication app(argc, argv);
        QImage img(500,500, QImage::Format_RGB32);
        QPainter p(&img);
        p.drawText(QRect(0,0, 500,500), "HelloWorld");
        //To simply show the painted image
        QLabel l;
        return  app.exec();

Log in to reply