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

Actual size in pixels different from QFont pixel size

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 4.8.6, 5.5.0
    • GUI: Font handling
    • None
    • CentOS 6.3 / gnome
    • Linux/X11

    Description

      I am using Qt 4.8.6 on CentOS 6.3 with Gnome.

      I am calling setPixelSize(13) on a QFont object. The QFont object is set on a QPainter and I am calling QPainter::DrawText in the paintEvent of a QWidget.

      When counting the pixels of the height of the text displayed on screen, I end up with 12 pixels instead of 13.

       

      Switching off anti-aliasing doesn't solve the issue.

      I also tried different pixel sizes and the actual size in pixel doesn't always match :

      pixel size : 14 ; actual size : 14 pixels

      pixel size : 13 ; actual size : 12 pixels

      pixel size : 12 ; actual size : 10 pixels

      pixel size : 11 ; actual size : 10 pixels

       

      When using a tool similar to Qt (Ilog Views/ Rogue Wave Views) and the same font and same size, the actual size on the screen matches with the pixel size.

       

      Why doesn't the actual size match with the pixel size with Qt ?

       

      Re-opening 07/11/2019 :

       

      I am using .ttf fonts. The issue happens with every .tff font i tried (including classic windows fonts like Arial). In all these fonts, the characters are smaller than the "em square".

      With setPixelSize(13), characters are also formed differently compared to setPixelSize(14). For example, the upper parts of "H" and "B" are smaller compared to the upper part with size 13. That is not the case with size 14. I added a screenshot of H and B letters with size 13.

      I tried native and raster modes with -graphicssystem option and the result is the same for both.

      Does Qt uses Freetype library to display true type fonts on Linux ? Could the issue come from Freetype library rather than Qt code itself ?

       

      Attachments

        1. HB13.bmp
          HB13.bmp
          1.0 kB
        2. Qt_pixel_size_13.jpg
          Qt_pixel_size_13.jpg
          0.9 kB
        3. Views_pixel_size_13.jpg
          Views_pixel_size_13.jpg
          0.9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            testbugqt test report
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes