Qt World Summit: Submit your Presentation

QT_FONT_DPI brain-dead by design?

  • This is more of a vent than a question, but if anyone understands the why of it then I'd love to be educated.

    I run a two display X11 session (not twinview, but each physical display has its own DISPLAY var). :0.0 is 96dpi and :0.1 is 48dpi (a times 4 sized display). The obviously incorrect use of QT_FONT_DPI is that it would "should" be a hint for Qt to understand the REAL dpi of the display the app is running on, but no joy.

    Let's use qt-designer as an example. When run on :0.0 (96dpi) as designer the app starts and is formatted properly. Even if I specify QT_FONT_DPI=96 designer then it's fine. Now, try to run designer on :0.1 (48dpi) and the fonts are microscopic and the windows are poorly formatted.

    Next try QT_FONT_DPI=48 designer on :0.1 and the same ugliness....but if I say QT_FONT_DPI=96 designer I get correctly sized fonts and windows are still jumbled. If I add QT_FONT_DPI=96 QT_AUTO_SCREEN_SCALE_FACTOR=0 designer then designer displays properly on :0.1

    This is extremely counter-intuitive and to me would indicate poorly documented options and/or Qt not really handling multi display with differing DPI correctly. It is beyond me why QT_FONT_DPI=96 would be required on a physical display that is 48dpi density.

    My work-round in the past has been to choose an in-between static value of 75DPI and deal with it...but work-arounds really rub me.

    Anyone have input that can add to my understanding, or confirmation that Qt DPI is buggy?

  • Lifetime Qt Champion


    Which version of Qt are you using there ?
    The support for dpi has been worked on recently.

    IIRC, there might also be issues with some screens "lying" about their capabilities which might also wreak havoc with some applications.

  • thanks for the heads-up @SGaist. I'm using the stock debain 10 release so it is Qt5.11.3 and trying to avoid manually patching system libraries, but rather keeping the relase in sync with the debian versions...and yes, i realize that isn't always practical, but hoped in the 2020s volatility of core libraries would be less of an issue than it once was.

    my X11 announces DPI based on my manual override of explicitly entering it for each monitor in xorg.conf file. My explict values are correct, but yes, monitors, cable assemblies, X11 versions...lie. A huge problem is twinview configuration of multiple monitors with different DPI.

    I did download the last Qt5.x open source release from git, so once I've made sure the build wont contaminate the existing 5.11 I will probably build it and run by explicitly using LD_LIBRARY_PATH.


  • FYI - decided that investing in two 40in 1080p monitors of the same type was the easier solution. Problem solved. LOL

Log in to reply