Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How can i get a bitmap from a QFonf Object?

    General and Desktop
    2
    2
    782
    Loading More Posts
    • 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
      wwolff last edited by

      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 Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        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 Reply Quote 0
        • First post
          Last post