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

When aligning vertically centered text to the pixel grid, round down rather than up to retain old look and feel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.1
    • 4.6.0
    • GUI: Font handling
    • None
    • MS Windows
    • 1de8a5bc428a53158028f5a71319d88538c19c54

    Description

      Try the following code in Qt 4.5 and Qt 4.6 on Windows XP:

              QPainter p(this);
      
              QRect rect(3, 2, 940, 16);
              p.setPen(Qt::red);
              p.drawRect(rect);
      
              p.setPen(Qt::black);
              p.drawText(rect, Qt::AlignCenter, "qÁ");
      

      The font has an odd-numbered height, while the rectangle has an even-numbered height, so the y-position of the text has to be rounded. In Qt 4.5 a bug caused the font height to be reported a pixel higher than what was actually true, thus giving us the effect of rounding the y-position up. When this bug was fixed in Qt 4.6, the text would move one pixel down as we now use the correct font height and round .5 numbers up.

      We can go back to the old look and feel by rounding .5 numbers down in the text drawing code rather than up. This makes sense for text that has a heavy descent and light weight ascent, like most latin text, it's consistent with how old versions of Qt did it, and it's consistent with native look and feel.

      Attachments

        1. font_rendering.zip
          32 kB
          John Melas
        2. QMenu_4.6.0.png
          2 kB
          John Melas
        3. snapshot8.png
          15 kB
          Christoph Feck
        4. v-align.ui
          3 kB
          Christoph Feck

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              jmelas John Melas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes