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

Qt5 applications do not accept floating point values from Xft.dpi

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.6.3, 5.8, 5.9.1
    • Fix Version/s: 5.14.1, 5.15.0 Alpha
    • Component/s: GUI: Font handling
    • Labels:
      None
    • Environment:
      Linux Mint 18, Cinnamon Edition.
    • Commits:
      b2e3a5502afc0398cb8a732c366253e72a64b744 (qt/qtbase/5.14)

      Description

      Some Linux desktop environments, such as Cinnamon or Gnome 3, set font DPI by using a floating point scaling factor, such as 1.2, from within their graphical Settings tools.  The Typically, the scaling factor is applied to the monitor's default (such as 96 DPI), and the result is applied to Xft.dpi.  The Xft.dpi value thus also is a floating point value, for example, 115.19921875.  Qt apps seem to like nicely rounded integer values only, and will default to using a 96 DPI for fonts (or the monitor default) if a floating point value is set for Xft.dpi.  Below are steps to replicate this in Cinnamon.  These steps also prove that Qt apps will correctly accept an integer value from Xft.dpi.

      1. Set DPI to 1.2 in Cinnamon Settings Manager.
      2. From a terminal, query the DPI value set for Xft.dpi by Settings Manager.  It will be 115.19921875 on a typical FHD screen.

      $ xrdb - query | grep dpi

      3. Launch a Qt application, and note that its font is a smaller size than the GTK applications.

      4. Create a file named ~/.Xresources.  Populate it as follows:

      Xft.dpi: 115

      5. Run the following command in a terminal from your home directory to laod the new Xft.dpi value.

      $ xrdb .Xresources

      6. Query the DPI value again.  Note that it is an integer value (115).

      $ xrdb -query | grep dpi

      7. Launch the Qt application again.  It's font size will now be the same size as any GTK app.

      Qt should ideally be fixed to read the Xft.dpi value as a floating point, and round and cast the value internally to an integer.

      Note that desktop environments such as Mate or Xfce do not have this issue with Qt applications, since their Settings Managers always set an integer value for Xft.dpi (such as 115) rather than using a floating point scaling factor like Cinnamon or Gnome 3 do.

      You can also use the above steps to set Xft.dpi in .Xresources to be a floating point value, such as 115.8325.  This will likewise prove that Qt rejects the Xft.dpi setting if it is a floating point value.

        Attachments

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

          Activity

            People

            Assignee:
            esabraha Eskil Abrahamsen Blomfeldt
            Reporter:
            wereturtle wereturtle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes