[Interest] Achieving resolution independent font sizes with Qt

Nikos Chantziaras realnc at gmail.com
Sat Jun 8 02:34:38 CEST 2013

On 07/06/13 18:29, Andreas Pakulat wrote:
> Hi
> On Fri, Jun 7, 2013 at 3:57 PM, Nikos Chantziaras <realnc at gmail.com
> <mailto:realnc at gmail.com>> wrote:
>     Is there an approach I can take to make the font sizes in applications
>     independent of the current resolution?
>     [...]
> This has nothing to do with Qt itself really, your problem is that the
> display server does not calculate the DPI value based on resolution and
> monitor size, but rather is set to the same value no matter what
> resolution is being used. You can see the current DPI of your X server
> using xpdyinfo (look for resolution:). If that value does not change
> when you change your resolution it explains why the fonts with the same
> point-size suddenly get rendered bigger. You need to find out who sets
> this fixed dpi value and let the X server figure out the right value
> based on your monitors size and the wanted resolution. This will only
> work if your monitor advertizes its sized via the so-called EDID
> information. If that fails you can still help X via its configuration
> file and tell it the dimensions of your monitor.
> The fontconfig library may also play a role here as it has its own
> setting for DPI and fontconfig is afaik being used by Qt these days to
> render the fonts.

Indeed, the value reported by xdpyinfo stays constant when I change 
resolution.  According to the X.Org log, the value is based on the 
monitor's EDID and set at 95x96.

I suppose there's nothing I can do about that then if this doesn't work 
on a user's system.  On Windows 7 though it seems to be working correctly.

More information about the Interest mailing list