Bug 357688 - DPI is always reported to 96 on High Res Display
Summary: DPI is always reported to 96 on High Res Display
Status: REPORTED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_fonts (show other bugs)
Version: 5.5.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-08 08:54 UTC by Kai-Uwe Behrmann
Modified: 2022-06-14 16:45 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai-Uwe Behrmann 2016-01-08 08:54:19 UTC
The plasma 5 systemsettings fontsettings panel has a checkbox for forcing a DPI value for fonts and a accompanying DPI value field. So far so good.

On a MacBook-pro with retina display this field is always set to 96 DPI, which is wrong. This setting forces me to adjust the value manually to 192 doubling the size to obtain a reasonable desktop. The correct physical DPI value is 227.

After some research for other non Qt based applications, I found that 96 is always reported by Xinerama on this machine, with all other values like size and so on computed to match 96 DPI. However XRandR reports the size in millimeter correctly. Based on this information and the desktops pixel size, the DPI can be computed correctly.

Reproducible: Always

Steps to Reproduce:
1. install KDE Plasma 5 on MacBookPro Retina
2. see the too small desktop windows rendering
3. go to systemsettings -> font settings -> force DPI box

Actual Results:  
see 96 DPI in the fonts force DPI value box

Expected Results:  
see the xrandr reported DPI value in the fonts force DPI value box

// Here some code showing the correct DPI values by using the XRandR API.
// Hope this helps.
// cc -Wall -g -pedantic XRandRfl.cxx -o XRandRfl -lX11 `pkg-config --libs xrandr`
#include <X11/extensions/Xrandr.h>
#include <stdio.h>

int main(int argc, char ** argv)
{
  Display * display = XOpenDisplay(":0.0");
  int screen = DefaultScreen( display );
  Window w = RootWindow(display, screen);
  XRRScreenResources * res = XRRGetScreenResources(display, w);
  for(int i=0; i < res->noutput; ++i)
  {
    XRROutputInfo * output_info = XRRGetOutputInfo( display, res, res->outputs[i]);
    if(output_info->crtc)
    {
      XRRCrtcInfo * crtc_info = XRRGetCrtcInfo( display, res,
                                                output_info->crtc );
      unsigned int pixel_width = crtc_info->width,
                   pixel_height = crtc_info->height;
      float xdpi = pixel_width * 25.4f / (float)output_info->mm_width,
            ydpi = pixel_height * 25.4f / (float)output_info->mm_height;
      printf( "[%d] %upx x %upx  Dimensions: %limm x %limm  DPI: %.02f x %.02f\n",
              i, pixel_width, pixel_height,
              output_info->mm_width, output_info->mm_height,
              xdpi, ydpi );
    }
    XRRFreeOutputInfo( output_info );
  }
  XRRFreeScreenResources(res);
  XCloseDisplay( display );

  return 0;
}
Comment 1 Kai-Uwe Behrmann 2016-01-08 09:38:51 UTC
The offending line is here:
https://quickgit.kde.org/?p=plasma-desktop.git&a=blob&h=07297bb660e4fd16059978f3b0e539d377542de0&hb=6367245d25d521d498d1b0734f88d287e17e69b1&f=kcms%2Ffonts%2Ffonts.cpp line:710

#if HAVE_X11
    checkboxForceDpi->setChecked(false);
    spinboxDpi->setValue(96);
#endif
Comment 2 Kai Uwe Broulik 2016-01-08 10:05:12 UTC
Well, that's just the default value, if you don't set one, isn't it? Also, scaling through that KCM isn't recommended. Try the "Scale Display" option in Display settings instead.
Comment 3 Kai-Uwe Behrmann 2016-01-08 10:36:13 UTC
Where does this default of 96 DPI come from? Why not 72 DPI why not assume actual display resolution of 192 or 300dpi? 

"Scale Display" in the display section does not affect font renderings - unfortunately. It would be cool if it allows scaling with one setting. Instead now (5.4.3) users are forced to do three settings to adapt the desktop scaling:
* set "Force fonts DPI:" and assign a proper DPI value
* set "Scale Display" scale factor - not dpi: sig
* set tool bar height outside of systemsettings again in a different unit - pixels
Comment 4 Kai Uwe Broulik 2016-01-08 11:43:04 UTC
Because 96dpi is the de-facto dpi standard for most "normal resolution" desktop monitors.

The screen scaling settings also change Xft dpi, the same settings the force fonts dpi influences.
Comment 5 Kai Uwe Broulik 2016-01-08 11:44:14 UTC
Also, what do you mean by tool bar height?
Comment 6 Kai-Uwe Behrmann 2016-01-08 12:47:31 UTC
"Kontrollleiste" is it called in KDE/german. Dock in OS X. "Taskleiste" in Windows/german.
Comment 7 Kai-Uwe Behrmann 2016-01-08 12:50:16 UTC
(In reply to Kai Uwe Broulik from comment #4)
> The screen scaling settings also change Xft dpi, the same settings the force
> fonts dpi influences.

Oh, that's then perhaps newer than the code I could test. Would be great.
Comment 8 Kai Uwe Broulik 2016-01-08 12:59:23 UTC
Ah panel. The panel was recently fixed to take dpi into account
Comment 9 Kai-Uwe Behrmann 2016-01-08 14:27:45 UTC
(In reply to Kai-Uwe Behrmann from comment #7)
> (In reply to Kai Uwe Broulik from comment #4)
> > The screen scaling settings also change Xft dpi, the same settings the force
> > fonts dpi influences.
> 
> Oh, that's then perhaps newer than the code I could test. Would be great.

The screen scaling of kscreen does not handle any font, just window and icon sizes.
I tested with kscreen 5.5.2 in KF-5.17.