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

QPainter text antialiasing for small fonts doesn't work properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.7.0
    • GUI: Font handling
    • None
    • Windows 10 Professional 64 bit build (Version 1607 Build 14393.82)
      Intel Core 2 Duo E8400
      ATI Radeon HD 3600 Series, Directx 10.1
      EIZO S2100 21" 1600x1200 screen resolution

    Description

      For all QFonts smaller than 64 pixel antialiasing doesn't work properly on Windows 10 desktop. The letter roundings got stairs or rather are pixelated. Other programs on Windows do smooth out these stairs better.

      Look at these screenshots:

      Programming languages:
      0. https://s19.postimg.org/pzbpoghsj/Qt_64_62_pixel.png
      1. https://s19.postimg.org/sldg064ur/a_s.png // Qt 5.7.0 problem shown on letters a + s
      2. https://s19.postimg.org/c16kmg0sz/Qt_5_7_0.png // QT 5.7.0
      3. https://s19.postimg.org/dhmoibt3n/Visual_C.png // Microsoft Visual C#
      4. https://s19.postimg.org/lbna3q0wj/MFC_GDI.png // Microsoft MFC C++

      Browsers:
      5. https://s19.postimg.org/y4be3ncib/Microsoft_Edge.png // Microsoft Edge
      6. https://s19.postimg.org/9p362ldlf/Internet_Explorer.png // Internet Explorer
      7. https://s19.postimg.org/ep0majj83/Google_Chrome.png // Google Chrome
      8. https://s19.postimg.org/guux51moj/Firefox.png // Firefox

      The shown programs other than Qt do fine antialiasing / smoothing on all shown font sizes. But Qt does the same good antialiasing only on fonts equal or bigger than 64 pixel. In Qt 62 pixel and smaller fonts in all letter arcs the 'stairs' (for example in the letters 'a' and 's') are clearly more visible, respectively less smoothed out (see screenshots 0, 1 and 2).

      It look looks like Qt uses grayscaling antialiasing for fonts equal or bigger than 64 pixel fonts and subpixel antialiasing (see colored borders on screenshot 0) for smaler fonts. Maybe there's a bug in Qt's subpixel antialiasing? It doesn't work as well as Firefox and Microsoft Edge subpixel antialiasing. The later ones do subpixel antialiasing on all shown font sizes in good quality (see screenshots 5 and 8).

      Qt 5.7.0 sourcecode of screenshot 2:

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>
      
      class Widget : public QWidget
      {
      public:
      	Widget();
      
      protected:
      	void paintEvent(QPaintEvent *);
      };
      
      Widget::Widget()
      {
          setWindowTitle("Qt 5.7.0 on Windows 10 64bit - Font: Adobe Source Sans Pro");
      	setAutoFillBackground(true);
      	setPalette(Qt::white);
      }
      
      void Widget::paintEvent(QPaintEvent *)
      {
      	QPainter painter(this);
          painter.setRenderHints(QPainter::TextAntialiasing, true);
      
          QFont font("Source Sans Pro");
      
          font.setPixelSize(64);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 70.0), "64 pixel: aaaa eeee ssss");
      
          font.setPixelSize(62);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 140.0), "62 pixel: aaaa eeee ssss");
      
          font.setPixelSize(54);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 215.0), "54 pixel: aaaa eeee ssss");
      
          font.setPixelSize(48);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 280.0), "48 pixel: aaaa eeee ssss");
      
          font.setPixelSize(40);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 340.0), "40 pixel: aaaaa eeee sssss");
      
          font.setPixelSize(32);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 390.0), "32 pixel: aaaa eeee ssss");
      
          font.setPixelSize(28);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 440.0), "28 pixel: aaaa eeee ssss");
      
          font.setPixelSize(24);
          painter.setFont(font);
          painter.drawText(QPointF(20.0, 485.0), "24 pixel: aaaa eeee ssss");
      }
      
      int main(int argc, char *argv[])
      {
      	QApplication app(argc, argv);
      	Widget widget;
          widget.show();
      	return app.exec();
      }
      

      HMTL code of screenshots 5-8:

      <HTML> 
      <HEAD> 
      <style>
      body { 
      	font-family: Source Sans Pro !important;
      }
      p.small {
          line-height: 1px;
      }
      </style>
      </HEAD> 
      
      <BODY>
      <br>
       <p class="small" style="font-size:28px;">Google Chrome / Windows 10 - Font: Source Sans Pro:</p>
       <p class="small" style="font-size:64px;">64 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:62px;">62 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:54px;">54 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:48px;">48 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:40px;">40 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:32px;">32 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:28px;">28 pixel: aaaa eeee ssss</p>
       <p class="small" style="font-size:24px;">24 pixel: aaaa eeee ssss</p>
      </BODY> 
      
      </HTML>
      

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            mireiner Chris
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes