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. How can i get a bitmap from a QFonf Object?
Forum Updated to NodeBB v4.3 + New Features

How can i get a bitmap from a QFonf Object?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • W Offline
    W Offline
    wwolff
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

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