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

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

      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.

        1. font_rendering.zip
          32 kB
        2. QMenu_4.6.0.png
          QMenu_4.6.0.png
          2 kB
        3. v-align.ui
          3 kB
        4. snapshot8.png
          snapshot8.png
          15 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes