Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What would be the best way to rasterize or render a font to some kind of image or array with QT
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 277 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

    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?

    J.HilkJ 1 Reply Last reply
    0
    • A AI_Messiah

      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?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @AI_Messiah
      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);
          img.fill(Qt::white);
      
          QPainter p(&img);
          p.drawText(QRect(0,0, 500,500), "HelloWorld");
      
      
          //To simply show the painted image
          QLabel l;
          l.resize(500,500);
          l.show();
          l.setPixmap(QPixmap::fromImage(img));
          return  app.exec();
      }
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved