Discussion:
Current state of DPI settings under X
Vladimir Kudrya
2017-07-25 18:15:31 UTC
Permalink
Hi all!

I would like to know the current 'proper' way of setting DPI in X (if
there is any).
I see conflicting information on the topic, and different applications
seem to have different source of this setting. I currently counted 3 of
them:
- fontconfig
- xrdb
- randr

Different versions of gtk2 seem to either demand or ignore dpi setting
in xrdb.
And there is also this recent change that gives xdpyinfo the ability to
state different DPI for different outputs simultaneously:
https://lists.x.org/archives/xorg-devel/2017-April/053430.html

Is there any DE- and toolkit-agnostic approach for letting applications
know the proper DPI and/or notifying them that DPI has changed?
Thiago Macieira
2017-07-25 21:15:54 UTC
Permalink
Post by Vladimir Kudrya
Is there any DE- and toolkit-agnostic approach for letting applications
know the proper DPI and/or notifying them that DPI has changed?
I think the current consensus is "that's hopeless, use Wayland instead".

Each toolkit will behave differently, in addition to the settings you've
found. They'll each have their own environment variables or dynamic settings
that configure the scaling that may be necessary.

And in my experience, there is no good solution when you have displays with
significantly different DPI connected at the same time.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
Allan Sandfeld Jensen
2017-07-25 22:31:44 UTC
Permalink
Post by Vladimir Kudrya
Hi all!
I would like to know the current 'proper' way of setting DPI in X (if
there is any).
I see conflicting information on the topic, and different applications
seem to have different source of this setting. I currently counted 3 of
- fontconfig
- xrdb
- randr
Different versions of gtk2 seem to either demand or ignore dpi setting
in xrdb.
And there is also this recent change that gives xdpyinfo the ability to
https://lists.x.org/archives/xorg-devel/2017-April/053430.html
Is there any DE- and toolkit-agnostic approach for letting applications
know the proper DPI and/or notifying them that DPI has changed?
Yes, the official X11 DPI value you call xrandr in your list. And fixing
toolkits that ignore, or even worse; override the value. The other values can
be set or calculated based on the physical data, but only X11 has the physical
data of the screen.

'Allan
Thomas U. Grüttmüller
2017-08-29 00:21:40 UTC
Permalink
Post by Vladimir Kudrya
I would like to know the current 'proper' way of setting DPI in X
startx -- -dpi 120

Be aware though, that many programs expect a screen with 96 dpi, so
setting the value to anything other than 96 might break their design.
Some fonts might look ugly, too.

Personally, I also don’t see a point. I have a 120 dpi screen, but I
prefer to stick with a 96 dpi setting because it looks better and I
don’t waste screen space. If I write programs, I define all sizes in
pixels to avoid all that crap in the first place.

Greetings,
Thomas
Thiago Macieira
2017-08-30 00:40:40 UTC
Permalink
Post by Thomas U. Grüttmüller
Post by Vladimir Kudrya
I would like to know the current 'proper' way of setting DPI in X
startx -- -dpi 120
Be aware though, that many programs expect a screen with 96 dpi, so
setting the value to anything other than 96 might break their design.
Some fonts might look ugly, too.
From experience, most modern applications and not-too-ancient applications
react just fine to the change in DPI. All modern toolkits provide ways to avoid
hardcoding pixel positions and most applications on X have dealt with varying
DPI or font sizes at some point or another.

I'm currently running at 216 DPI and I don't have any application misbehaving,
not even the ones that don't support scaling up icons, margins, etc.
Post by Thomas U. Grüttmüller
Personally, I also don’t see a point. I have a 120 dpi screen, but I
prefer to stick with a 96 dpi setting because it looks better and I
don’t waste screen space. If I write programs, I define all sizes in
pixels to avoid all that crap in the first place.
I do. If I run at 96 DPI, I can't read anything. I'd have to at least double
the font sizes, which for well-behaving applications is an equivalent change
to doubling the font DPI.

But unlike the change in DPI, not all applications will use 18pt, 20pt or
bigger fonts. There are modern applications that hardcode font sizes in
points.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
Keith Packard
2017-08-30 14:54:04 UTC
Permalink
Post by Thiago Macieira
I'm currently running at 216 DPI and I don't have any application misbehaving,
not even the ones that don't support scaling up icons, margins, etc.
I've left my X setting at 96 but run the 'fonts' configuration at
150 and have firefox set to double its layout. I could try fussing with
settings more, but nothing seems weird at this point.
--
-keith
Vladimir Kudrya
2017-08-30 16:13:00 UTC
Permalink
I was happy with 96 DPI everywhere until I bought new laptop that
jam-packed 1920x1080 into 13.3" screen.

Jumping between 24" and 13.3" displays 2-3 times a day suddenly became a
pain.

Getting back to ways of configuring DPI: After some more digging I found
that fontconfig falls back to xrdb, so this simplifies the setup down to
two locations: xrandr+xrdb (as long as DPI is unset in fontconfig).

Scriptable and hookable anyway, still a mess, but a bit more clear.
Post by Keith Packard
Post by Thiago Macieira
I'm currently running at 216 DPI and I don't have any application misbehaving,
not even the ones that don't support scaling up icons, margins, etc.
I've left my X setting at 96 but run the 'fonts' configuration at
150 and have firefox set to double its layout. I could try fussing with
settings more, but nothing seems weird at this point.
Loading...