Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10507

QFontMetrics gives incorrect space between font characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • Some future release
    • 4.7.0
    • GUI: Font handling
    • None
    • Qt Versions: 4.6.2, 4.7.0beta1
      Platforms: Windows 7 64 bit, Linux x86-64
      Compilers: MSVC 2008, GCC 4.4.1

    Description

      At least two routines affected: QFontMetrics[F]::width(const QString &) and QPainter::drawText().

      According to Qt documentation of QFontMetrics::width(QChar):
      "Returns the logical width of character ch in pixels. This is a distance appropriate for drawing a subsequent character after ch."

      This means that drawing solid string should give the same result as drawing sequential set of string character and translating offset to QFontMetrics::width(QChar).
      This is wrong for some fonts.

      In my example Qt shrinks distance between drawn characters.
      I used QFont("Arial", 60, QFont::Bold) and got different results.
      This means that it is impossible for example to obtain actual position (in pixels) of character in string on screen.

      Please see the example how to reproduce the problem.

      The results also added into archive named: wrongImage.png, rightImage.png and wordpadImage.png
      wordpadImage.png was created in the standard Window WordPad application with the same font passed (Bold Arial size 60).
      WordPad also proves that font rendering in Qt is incorrect, QFontMetrics::width(const QString &) is incorrect too, but QFontMetrics::width(QChar) is correct.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            dendy Daniel Levin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes