Ubuntu – Font size changes after running xrandr –off

appearancedisplayfontsmonitorxrandr

I have a laptop with an external monitor and switch between both screens using xrandr --auto and xrandr --off. Sometimes when I change the screen the font size in programs is suddenly weirdly big. This doesn't affect programs that were started before. I'm using Lubuntu 16.04.

I was able to reproduce the error using this chain of commands multiple times:

xrandr --output eDP1 --off && sleep 1 && xrandr --output eDP1 --auto

The external monitor has nothing to do with this, just disabling the laptop screen (eDP1) and enabling it again suffices to get these weird font size problems.

Edit: What really was changed by xrandr --off is the screen's DPI, see here:

$ xdpyinfo | grep dots
  resolution:    96x96 dots per inch                                                                                                                                              
$ xrandr --output eDP1 --off && sleep 1 && xrandr --output eDP1 --auto 
$ xdpyinfo | grep dots
  resolution:    204x205 dots per inch

Examples

For scale: The buttons are normal-sized.
Normal VLC window in background, changed one in foreground.

vlc

GnuCash

What I tried so far

I tried to play around with Lubuntu's (untouched) font settings and can reset the fonts to normal (which should be 11) by choosing font size 6, but the fonts in already open applications (panel etc.) then change to what's really size 6. The only way to set things to normal is logging off and back in again or systemctl restart lightdm.service.

I discovered a possible workaround: At least until today the issue didn't return since I look out for having at least one monitor enabled at any time. So to change from monitor eDP1 to DP2 I do

xrandr --output DP2 --auto && xrandr --output eDP1 --off

This works for now, but of course doesn't solve the problem.

How can I reset the font size when this occurs?

Terminal command outputs

  • xrandr, external monitor (DP2) connected and enabled, laptop screen (eDP1) off

Best Answer

You can change the size of fonts for future windows opened by opening the terminal and using:

xrandr --dpi 96

For higher resolution (1920x1080) monitors try using:

xrandr --dpi 144

I use this on programs that do not implement HiDPI scaling themselves. Although it may not explain your problem it may solve it. Or it may not... YMMV.

Related Question