UI and fonts are too big with right(native for display) DPI settings

And here is photos of 72pt and 36pt Hack font when I set 183DPI and 100% scaling:


They are bigger than they should be.

Try setting the DPI and subpixel hinting to match the physical display specs. It’s likely that the monitor is a more common DPI like 192 which is what MacBook Retina and other similar displays use. This is also 2x the most common & default Xorg DPI of 96 (2 x 96 = 192).

Maybe try setting rgba (subpixel layout) to rgb (const 1), scale to 1, default lcdfilter 1, and dpi to 192.0:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="rgba" mode="assign" binding="strong">
      <int>1</int>
    </edit>
    <edit name="lcdfilter" mode="assign" binding="strong">
      <int>1</int>
    </edit>
    <edit name="scale" mode="assign" binding="strong">
      <double>1.0</double>
    </edit>
    <edit name="dpi" mode="assign" binding="strong">
      <double>192.0</double>
    </edit>
  </match>
</fontconfig>

Also in “System Settings -> Display Configuration” make sure to set scaling to 100%. For Xorg, also match the screen & font DPI settings to 192. Sometimes for Xorg/X11, setting DPI is easier said than done, but maybe this doc helps

Last thing is that lcdfilter can give different results based on the display & your personal preferences. This page has demos of lcdfilter values, and should work for your RGB subpixel layout display. The lcdfilter that works best for your display should have the least noticeable color banding. Smoother edges are more preferable for the font characters with curved edges. The idea behind this setting is that it works alongside subpixel layout to reduce color fringing and approximate smooth curves on the grid-based pixelated display.

Out of interest, did you try this approach?

There are different scale related settings in Wayland than exist in X11.

If the 192 DPI with scaling factor set to 1:1 (or 100%) doesn’t result in proper sizing for your display… based on the above specs, the DPI.lv website calculates 182 DPI for 2560x1440 & 16.1-inch display.

The general rule is that DPI settings should match the physical display specs such that a 1:1 scaling factor will result in fonts being the proper size. If DPI is set to higher values, the fonts will look smaller at 100% (a.k.a 1:1) scaling. If DPI is set to smaller values, the fonts will look larger at 100% scaling factor.

Anytime scaling factor is set above 100%, everything gets multiplied by that value. So for example with 150% (1.5:1), the fonts, window sizes, and everything else gets magnified 150%.

Ideally you want to work at 1:1 scaling and get things rendering at the proper size. Then if fonts are still too small to read, adjust the default system UI font size larger in pt values, and increase scaling factor until it looks how you prefer.

EDIT: Again, make sure to double-check that Xorg DPI settings are also matching fontconfig. X11 is known to try defaulting to 96 DPI. Also to complicate things… there is a separate Xorg font DPI setting (Xft.dpi), and finally, setting DPI for X11 in general is buggy and doesn’t always “take” the first time.

Check all of the following:

# INXI display DPI settings (for Xorg it will show DPI for both Screen & Monitor)
# Output should have both:
#  Screen-1: [...]   s-dpi: <YOUR PHYSICAL DISPLAY DPI>   [...]
#  Monitor-1: [...]  dpi: <YOUR PHYSICAL DISPLAY DPI>  [...]
sudo inxi --graphics  --admin  --filter --no-host --width
# Xorg DPI setting
# Output should match DPI
xdpyinfo | grep -B2 resolution
# Xorg also has a separate font DPI setting...
# Output should have:  Xft.dpi: <YOUR PHYSICAL DISPLAY DPI>
xrdb -query |grep dpi
# DPI settings logged by Xorg ideally should also match...
# yet, these may be miscalculated by display drivers at startup and may be set manually later in an xsession or other startup script
# Still, it's good to check what Xorg & GPU drivers think the DPI is...
grep DPI /var/log/Xorg.0.log

EDIT2: A few things to note about your display:

  • The laptop’s specs show that this is a “QHD” display (16.1" diagonal, QHD, native resolution: 2560x1440)
  • The 2560x1440 resolution itself is probably going to make things seem tiny when rendered at proper DPI.
    • Once the DPI settings match the physical characteristics of this display, the pt sizes of rendered fonts should be correct relative to everything else (widgets, buttons, windows, etc…)

    • Scaling factor then can be increased to your preference, but note that this will magnify everything including the fonts with their relative sizing when compared to widgets, windows, etc…

    • Some people over on Reddit had this to say:

      If you go 4k, 32in is the smallest to use it at 100%. For laptops, 4k at 14 or 15in works well at 200%.

  • A general strategy for tuning these settings:
    • Start with 1:1 scaling factor (100% scale)
    • Match DPI settings to the physical display specs
    • If fonts look too small, increase default System UI font size in pt units until things look good relative to one another, and are more readable.
    • If things still appear too small, increase the scaling factor above 100%
      • Just be aware: As soon as scaling factor is touched, font sizing in pt will not match pixel-perfect to physical display pixels.

EDIT3: Another final place to set DPI settings is in xorg.conf files (e.g. drop-in files under /etc/X11/xorg.conf.d). Some guidance for doing this here. Generally Xorg is a mess and you might try @soundofthunder’s advice to get a Wayland session working even if only to sanity-check yourself and avoid pulling your hair out trying to configure X11.

1 Like

This is what I am trying to do, but this renders everything to big.
My physical DPI is 183.

I measured it by the ruler :grinning: :straight_ruler:

If you look up the hardware reports 355x200mm (13.98x7.87") screen size,
what means the same 183 DPI.

192 - will make everything even bigger (also, it seems that GTK applications(Firefox precisely), after some threshold (somewhere after DPI144) will use 192 DPI, what makes its UI and web pages gigantic.

Basically, I want to use screen native DPI and cannot understand why everything renders so big.

Also, can someone point me where and how I can change Gdk/UnscaledDPI
How to calculate it?
I tried to change ~/.config/xsettingsd/xsettingsd.conf
But it gets rewritten after reboot. Current settings:

Gdk/UnscaledDPI 98304
Gdk/WindowScalingFactor 1
I created ~/.config/fontconfig/conf.d/16-HDPI.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
<!-- Generated by Font Manager. Do NOT edit this file. -->
<fontconfig>
 <match target="pattern">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
  <edit mode="assign" name="autohint">
   <bool>false</bool>
  </edit>
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
  <edit mode="assign" name="hintstyle">
   <const>hintmedium</const>
  </edit>
  <edit binding="strong" mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
  <edit binding="strong" mode="assign" name="lcdfilter">
   <const>lcdlight</const>
  </edit>
  <edit binding="strong" mode="assign" name="dpi">
   <double>183.0</double>
  </edit>
 </match>
 </fontconfig>
I created /etc/X11/xorg.conf.d/50-display-size.conf
# DPI monitor configuration

Section "Monitor"
    Identifier             "<default monitor>"
    DisplaySize             356 200
EndSection
I created ~/.Xresources
Xft.dpi: 183
Xft.autohint: 0
Xft.lcdfilter:  lcdlight
Xft.hintstyle:  hintmedium
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
xdpyinfo | grep -B 2 resolution
screen #0:
  dimensions:    2560x1440 pixels (356x200 millimeters)
  resolution:    183x183 dots per inch
xrdb -query
Xcursor.size:   24
Xcursor.theme:  breeze_cursors
Xft.antialias:  1
Xft.autohint:   0
Xft.dpi:        183
Xft.hinting:    1
Xft.hintstyle:  hintmedium
Xft.lcdfilter:  lcdlight
Xft.rgba:       rgb
printenv - redacted unrelated stuff
COLORFGBG=15;0
COLORTERM=truecolor
DESKTOP_SESSION=plasma
DISPLAY=:0
GTK_MODULES=canberra-gtk-module
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
QT_SCREEN_SCALE_FACTORS=eDP=1;DisplayPort-0=1;DP-1-0=1;DP-1-1=1;HDMI-1-0=1;
XCURSOR_SIZE=24
XCURSOR_THEME=breeze_cursors
XDG_CURRENT_DESKTOP=KDE
XDG_SESSION_TYPE=x11
XDG_VTNR=2
SHLVL=1

Scale factor in KDE settings is 100%

But they DON’T. They are to big.

But can someone with 96DPI screen help me to compare physical font size?
For example, this is photo with ruler of Kate editor with Hack font in 72pt size:

Photo

I tried Wayland. Result in general the same. 150% scaling gives good result. But anything close to physical monitor DPI - gives everything gigantic in size.
In system scale and (x11 app will scale on their own) modes result roughly the same (except blurriness of some apps in system scale mode).

Your settings look good as far as I can tell. :thinking: :person_shrugging:

Although, Xorg is known to be a hassle when configuring things for HiDPI displays. Also, it seems that KDE devs are working on HiDPI support recently. Finally, this thread talks about the need (or not) for xsettingsd with KDE Plasma >= 5.27

This page says to calculate Gdk/UnscaledDPI by multiplying the DPI by 1024. For your example of 98304, it looks like it’s still set to 96: 98304 / 1024 = 96.

Maybe try setting it to: 187392 ? (183*1024 = 187392)

Disclaimer: I’ve never had to change this setting, so “take this with a grain of salt” / “your mileage may vary”, etc…

Again, maybe this thread about xsettingsd might be helpful?

Unfortunately, I currently only have a non-standard HTPC display that’s basically a low-DPI (36) HDMI TV.

I’m currently also using Wayland + Sway, so I’ve had a much better DPI-aware & fractional scaling experience overall when compared to Xorg / X11. It seems that getting Xorg to respect HiDPI & scaling properly is complicated and messy.

Thank you for info.
Indeed when I revert all to KDE screen scale mechanism, that sets dpi to 144, Gdk/UnscaledDPI automatically sets to 147456 (144*1024).
This is works great for me.
But I want to dig to the core, why my native DPI wont work… I will try to spawn my question in other places, maybe something will catch up.

It seems we can go round in circles indefinitely. 100% is 100%. 150% will always give you grief, when used as a starting point, irrespective of your ongoing calculations. I wish you luck.

1 Like

Hope it helps! After I re-read through the blog post that I sent earlier, “HiDPI Linux Hassles”, I noticed something that lines up with your reported observations above. This section specifically:

If your DPI is high enough and your display has enough pixels, it seems to be common for programs and toolkits to automatically engage a scaling mode. This example from Fedora’s Anaconda seems to be typical; it doubles things if, well, let me quote from the comment:

Check if this monitor is high DPI, using heuristics from gnome-settings-dpi. If the monitor has a height >= 1200 pixels and a resolution > 192 dpi in both x and y directions, apply a scaling factor of 2 so that anaconda isn’t all tiny[.]

Now my life gets awkward. The honest DPI setting for the Dell P2715Q is 163 DPI, which is under the 192 DPI that will trigger automatic scaling. However, the Dell definitely needs scaling; unscaled UI elements are far too small. One option is to lie about the display DPI; however, this distorts all font sizing, including in programs and toolkits that don’t expose any good way of adjusting the font size by hand (at least, not outside of their desktop environment).

(This heuristic is also not guaranteed to work in all toolkits and for all programs.)

So, it seems that your display with native DPI of 183 falls into the same category (height >= 1200px, but DPI < 192), as that user’s display (the Dell P2715Q). In this case, the auto-scaling factor heuristic mentioned for anaconda would not apply because your display’s native DPI is less than the “HiDPI” heuristic threshold of 192:

  • ( height >= 1200px ) == ( 1440px >= 1200px ) == true
  • ( DPI > 192 ) == ( 183dpi > 192dpi ) == false

It’s unclear whether this heuristic is applied across all GTK apps, and no mention of KDE nor QT is made, other than the user saying that QT automatic scaling doesn’t seem to work for them.

The suggested workaround for GTK is to try fiddling with GDK*_SCALE environment variables to try and forcibly address the UI widget + font scaling issues. This isn’t ideal, and seems like quite a hack, but maybe it’s one of the only ways to force applications to scale properly given the mess that is HiDPI in Xorg. However, it’s not that inconsistent with the general theme of hackiness & historical baggage that comes along with Xorg. :man_shrugging: … but I digress…

This part of the article mentions a set of environment variables to set for GTK apps, and also mentions the “fonts too big” problem that you may have experienced above.

Fortunately there are often ways to manually tell things to scale their UI up, as covered in the Arch Wiki entry on HiDPI. What you want to do depends on the toolkit, and it also depends on whether various magic bits of the toolkit work right (the QT automatic scaling doesn’t seem to work for me, for example). Another gotcha is how this interacts with the DPI settings, as illustrated by GDK 3. If you want ordinary, non-toolkit applications that use XFT fonts to scale their fonts correctly, you must set the X DPI to a suitable high value (whether honest or otherwise). This will also scale fonts in GDK 3 applications, but it won’t scale GDK 3 UI elements (unless your DPI is above the magic threshold). If you want to explicitly scale GDK 3 UI elements, you must force scaling:

export GDK_SCALE=2

However, this scales everything in GDK 3 applications, including their fonts, which are already properly scaled because of the X DPI; the result is a decent sized UI but giant fonts. In order to return fonts back to where they started, you must tell GDK 3 to un-scale the text again:

export GDK_DPI_SCALE=0.5

(Fiddling with XSettings might work around this.)

I haven’t had to resort to trying this out, because I don’t have a HiDPI monitor and also now use Wayland + Sway. So, I can’t provide any endorsement or further guidance on whether this will work or not.


EDIT: Some further info regarding KDE + HiDPI

While I’d suggest starting with 100% scaling first, if only to get the relative sizing of fonts + UI elements properly tuned for your display’s DPI… That’s only the first step when dealing with High DPI displays.

For HiDPI, expect that at 100% scaling things should look small at first before you adjust font size + scaling.

It’s been recommended by most HiDPI users, and at least one prominent KDE developer to use a scaling factor of 2 (200%). That last link also shows how to use the “Force Fonts DPI” setting in KDE circa July 2016 (probably it was on Plasma version 5.7 or 5.8). Things have probably changed since then, as a lot of development was done for HiDPI support from 5.4 and up. Here’s another KDE user who suggests 200% scaling for the HiDPI Retina display (220 DPI for Retina MacBook). They also suggest setting the environment variable:

PLASMA_USE_QT_SCALING=1

Yet, beware of the effects of this when using multiple displays with different resolutions & DPIs

One last thing: If you’re using any non-integer scaling ratio (e.g. 1.5:1 = 150%, 1.75:1 = 175%), also be aware that you may see issues with blurriness on X11 (and even Xwayland). This is called “fractional scaling”, and involves oversampling & scaling down. On Wayland, the fractional-scale-v1 protocol landed in staging, so depending on client support the experience with fractional scaling factors will be much better.

Hope this helps!

1 Like

It was for this very reason I suggested experimenting with Wayland due to there being two distinct scaling modes as opposed X11. I’m uncertain of results from that as the OP failed to elaborate much beyond ‘it didn’t work’.

1 Like

Under Wayland, “system(Wayland) scaling” produced bad result of some applications being blurred(like Firefox) with similar gigantic look. And UI and fonts in other applications being to big the same as with X11.
X11 scaling option under Wayland session make everything the same as in X11 session.
So basically no change regardless of chosen options.

Unfortunate. Still, there must be a solution; it’s just a question of discovery.

Just curious if while firefox is running you could check the output of:

xlsclients

(If it’s not installed, you can install this tool via: xorg-xlsclients package)
If firefox is shown in the output, it’s running under Xwayland. If not, it’s running as native Wayland session and yet we’re experiencing some issue with fractional scaling. :thinking:

EDIT: If it turns out that firefox is still running under Xwayland, then try: export MOZ_ENABLE_WAYLAND=1 ; firefox

I recall this was an artifact of one of the modes; probably some kind of compromise is inevitable.

Under Wayland session a set scale factor to 100% and only increase DPI in font settings, this produce somehow bearable results but still strange, font sizes the sames as in X11, and looks like they are bigger than they should be.

I manage to run Firefox natively on Wayland with Wayland scaling.
Results the same as with X11.

If I use (144 < DPI < 167) Firefox scales normally and gracefully sizes increases for each additional DPI point (and Display DPI detector - find out DPI of your monitor shows DPI = 144). When I set (167 < DPI) everything snaps to gigantic sizes and web DPI detector shows 192DPI

Here is screenshots of 167DPI and 168DPI settings.

Screenshots

If I don’t touch DPI settings in Appearance->Font section, and use Scaling settings at 190% in Display section instead, Firefox acts the same way. But other UI get broken as well.

For example, there is screenshot of KDE Settings Window, it wont get any smaller

Yes, however the OP seems insistent on their 150%. :slightly_smiling_face:

I do not understand what you are trying to say… I just mentioned 150% in Screen settings as a regime that looks Okeish.

I think I am pretty precisely document which settings under which conditions produce the relevant results. I am not trying different DPI settings with scale different from 100%.
When I touching scale settings, I let KDE to set DPI in X11 mode, and in Wayland mode as well (in Wayland DPI checkbox in Font settings must be not checked in order to scaling work properly, while in X11 mode KDE check it up and sets DPI it thinks right).

Increasing fonts sizes with wrong DPI have no use for me at all. I know how to make UI looks good. I want to use right DPI. The goal is to set DPI to 183 and keep UI sizes from exploding.

I was responding to a previous post. I’m hopeful that you’ll find a resolution soon though. In an ideal world, this really shouldn’t be as difficult.

1 Like

Hello UI seller, I going to set native DPI, and I need your strongest scaling :grinning: :grinning:

1 Like

Those results are quite interesting :thinking:

It seems that Firefox may be using its own heuristic based on DPI and displaying differently based on DPI > 167 as you’re observing.

In the article, “HiDPIMyXSettings”, the author notes having to adjust an about:config setting to get Firefox’s fonts to appear at a preferable size. Maybe adjusting this setting could help? (Author suggests: layout.css.devPixelsPerPx = 1.7)

The final setting I make is in Firefox. As mentioned in passing in this entry, I manually set the about:config setting layout.css.devPixelsPerPx to 1.7, which is down from what would be the default of ‘2’ based on my overall settings. I found that if I left Firefox alone with these other settings, its font sizes looked too big to me. A devPixelsPerPx setting of 1.7 is about right for what the Arch Wiki Firefox Tweaks page suggests should be correct here, and it looks good to me which is what I care about most.

Following the linked ArchWiki section: Firefox/Tweaks: Configure the DPI value, and using DPI 183: 183/96 = 1.90625
So for your DPI, maybe try: 1.9