106

I am trying to find and then change the screen DPI (dots per inch) setting in 12.04 and 12.10. However, I can't seem to find any app or config file that can do this. Is there any app or conf file for this?

Note that this is for 12.04+ so the following will not work:

Moreover, they are basically changing the font size, not the actual screen DPI.

2
  • 1
    Note that this question was asked in 2012 and is old. The most notable change is that Ubuntu uses Wayland on some hardware, instead of X.
    – Flimm
    Jul 13, 2023 at 12:50
  • @Flimm Good comment. Hopefully people read it first before proceeding to bash me lol. Jul 13, 2023 at 18:23

12 Answers 12

144

This is an updated version of my previous answer which was related to Ubuntu 12.04. In 16.04 (Xenial) 3 steps are needed to set DPI correctly instead of 2.

I'll explain on the example of the system with Ubuntu 12.04 with Gnome Classic and a monitor with resolution 1680x1050. My starting settings: xdpyinfo | grep dots reported 96x96 dots , xrdb -query | grep dpi reported Xft.dpi: 96 , grep DPI /var/log/Xorg.0.log reported some weird settings NOUVEAU(0): DPI set to (90, 88).

In 16.04 the outputs of all these 3 commands were consistent and were equal to 96. Though such consensus is better than the disorder of 12.04, the reported value is hardcoded and far from the real DPI value.

Let's calculate optimal DPI for my monitor. Actual size of the screen can be found with the command xrandr | grep -w connected (convert output to centimetres) or with a long ruler by hand. In my case: X = 47.4cm ; Y = 29.6cm. Divide them by 2.54 to get the size in inches: X ~ 18.66in ; Y ~ 11.65in. Lastly divide the actual dots amount (based on your resolution) by the size in inches: X = 1680/18.66 ~ 90dpi ; Y = 1050/11.65 ~ 90dpi. So my real dpi is 90.

Be warned, the manual method of measuring may be more accurate, than the output of the command xrandr | grep -w connected because the newer versions of X server ignore the size reported by EDID and calculate the size using the screen resolution and a hardcoded value of DPI (more info here).
Another method how to find the size of the monitor is to read its EDID directly. Install read-edid package and run the command sudo get-edid | parse-edid | grep DisplaySize in the terminal. Its output will give you the actual size of your monitor in millimetres. If not - use the ruler.

Let's start fixing DPI:

1) In 12.04 run gksudo gedit, open /etc/lightdm/lightdm.conf and add a parameter under [SeatDefaults] section:

xserver-command=X -dpi 90

There's no such file in 16.04 by default, so you must create lightdm.conf manually and put it into /etc/lightdm/lightdm.conf.d/. The contents of this file are the same:

[SeatDefaults]
xserver-command=X -dpi 90

Restart your computer or restart X. Now grep DPI /var/log/Xorg.0.log will show the desired setting.

2) In my former answer I proposed to create a file in /etc/X11/Xsession.d/ containing string xrandr --dpi 90. This worked in 12.04, but in 16.04 this setting isn't persistent. In newer systems we can add the desired value on session start. Run "Startup Applications", press "Add" button, name it "Fix DPI" and set the command xrandr --dpi 90 in the field. Save the changes and re-login. Now xdpyinfo | grep dots will report 90x90 dots.

If xdpyinfo still shows 96 then add a timeout before running xrandr. Edit the command in "Startup Applications" and change it to:

bash -c "sleep 15; xrandr --dpi 90"

Reference

Step 2 is optional for 12.04 because in older systems Step 1 fixes both Xorg.0.log and xdpyinfo values.

3) In GNOME3 DPI setting is hardcoded to 96 and cannot be changed directly, but the text can be scaled instead. Calculate the desired multiplier: desired_DPI / 96 (in my case 90/96 = 0.9375). Now run the command (or use dconf if you prefer):

gsettings set org.gnome.desktop.interface text-scaling-factor 0.9375

Changes will be applied at once. xrdb -query | grep dpi will report the desired Xft.dpi: 90.

P.S. There is another method to fix DPI setting which is much more difficult and it is described in this guide. I tried it also and the result was the same (at least in 12.04).

Afterword: Only Ubuntu developers can say for certain whether values modified by Steps 1 & 2 really matter in modern Ubuntu or they are silently ignored. Only Step 3 produces the changes which are instantly noticeable. Those users who consider that certain apps may still rely on X server settings are encouraged to perform all 3 steps described above. For the rest Step 3 is sufficient - that's the sole way of customization adopted in modern Ubuntu distros.

19
  • 1
    here's a spreadsheet to save you a bit of time computing the values: docs.google.com/spreadsheet/… Dec 29, 2013 at 17:41
  • 1
  • I didnt manage to change dpi with both methods, it just forgets settings after I restart.
    – umpirsky
    Jun 11, 2014 at 5:33
  • 1
    @RaffiKhatchadourian There's schema org.gnome.desktop.interface and key scaling-factor in it. The default value is 1 and it can be only integer. It is intended for HiDPI displays. There exist some methods to obtain non-integer scaling factor using xrandr. Check this link: wiki.archlinux.org/index.php/HiDPI (that's Arch knowledgebase, haven't tested this in Ubuntu).
    – whtyger
    Apr 12, 2017 at 13:36
  • 1
    FWIW, with 18.04 I had issues with getting a bad DPI (54) value when having my TV connected on HDMI and my computer screen on DP. xrandr --dpi 110 fixed if while logged in, and restarting i3/Thunar/... seems to have fixed all the issues I was having (tiny font on the computer screen), no system restart necessary. (Not sure what happens on the low-DPI TV now...)
    – Raphael
    May 12, 2020 at 17:22
28

Starting with 14.04 we have an option that helps a bit:

Scaling Support

In the image below we can see the scaling it has at 0.75 on the fonts and title bars:

enter image description here

In the image below we can see the scaling it has at 1.38 on the fonts and title bars:

enter image description here

4
  • 3
    That worked for me in Ubuntu 14.04 (german: "Anzeigegeräte") I had to restore the default font-scaling factor to 1.0 (I set it to 2.0 berfore) and rescale the Launcher-Icon size in "All Settings"->"Darstellung"
    – rubo77
    Jun 19, 2014 at 7:54
  • 4
    Doesn't that only change the menu and title bars, including the Launcher, and NOT the total DPI?
    – John Scott
    Oct 18, 2014 at 15:39
  • 1
    @FuzzyToothpaste that is why I said "helps a bit". That bit is that, when you lower the scale, apart from changing the menu, title bar and launcher icons, the actuall size of the windows, because of the change, will be smaller. So it helps a bit if you have for example a 1280x720 resolution (like a laptop) and you want to fit the windows inside that 720. Lowering the scale to 0.8 or less will "feel" like you are using 1080 instead of 720. This of course is with Non Hi-DPI like the apple products. I guess the effect would be bigger on those type of hardware. Oct 18, 2014 at 15:51
  • Hello, sorry for my comment; I want to display the Display Setttings as on your pictures via the xserver session: is there a way to do it ?
    – user284234
    Jun 27, 2015 at 9:07
10

As far as my experience in Ubuntu goes, changing the font DPI setting changes a lot more than just the way fonts are rendered. It also applies to icons and the size of menus for example.

It's just that Xorg hints the Desktop Environment on what the physical display's DPI is. And yes, you can override this in the Xorg.conf, but it has the same effect as changing the setting in your DE. For example in Kubuntu/KDE:

enter image description here

2
  • 3
    Is there an Ubuntu (Unity) version of this font manager. Jan 26, 2013 at 23:37
  • @LuisAlvarado No, it appears this is only GNOME2 and KDE offering this... Gnome-tweak-tool should be able to do this, but it crashes my 12.10 Unity VM whenever changing the font size.
    – gertvdijk
    Jan 26, 2013 at 23:44
9

Had a similar problem, on a 2880x1620 screen. See http://ubuntuforums.org/showthread.php?t=2106549 Solved by putting

xrandr --output DP-0 --scale 0.75x0.75

into my ~/.xprofile

Instead of "DP-0", put whatever

xrandr

tells you as device name.

You can tweak the scale of course, but 0.5 somehow did not look nice on my screen.

2
  • 4
    This i only a workaround, cause you loose the real resolution. With this scaling your monitor only displays half the pixel instead of re-rendering it in the scaled resolution
    – rubo77
    Feb 12, 2014 at 0:41
  • 1
    Unfortunately the mouse does not scale at the same rate as the screen when using this :-( When scaling down as you are this is harmless as the mouse just explores empty space outside the screen but when scaling up to get a complex application to display well on smaller screens, the mouse does not reach to the edge of the screen which makes this unusable in that use case
    – marsbard
    Mar 4, 2014 at 12:41
7

While the xserver-command=X -dpi ... and xrandr --dpi ... given above may have worked very well in earlier versions of Ubuntu, in Ubuntu 13.10 (which is what I have) Unity ignores those settings and keeps the dpi fixed (as far as the X server is concerned at 96 dpi).

And the xrandr --scale ... command does scale the screen as described but scales it in such a way that makes text and icons a little bit blurry. But it works.

It appears that in Ubuntu 13.10 the best option might be not to try to change the dpi setting for the X server but instead use the unity-tweak-tool to change the default fonts used by Unity and the default font scaling factor. You can download the unity-tweak-tool from the Ubuntu Software Center. When you open the unity-tweak-tool go to the Fonts button and try changing the font scaling factor to 1.2 or 1.25 (or higher or lower) to get the fonts to appear a good size for you. On this control panel you can also change the default fonts used by Unity. Admittedly this solution doesn't scale everything on the screen, just the text, but it works really well on my laptop with its 166 dpi screen. It appears web browsers like Firefox and Chromium don't notice this setting setting but each both Firefox and Chromium allow you to set a minimum font size in their application settings to scale-up the fonts on web pages in the same way.

0
6

Install Ubuntu-Tweak http://ubuntu-tweak.com/

Open it and go to 'Tweaks > Fonts'. Then change the 'Text scaling factor'

Works great. Enjoy.

6

In Ubuntu 14.10, with a 15" laptop, 1920x1080 resolution (345mm x 145mm), with 143ppi/dpi density, I did the followings.

In /etc/X11/xorg.conf.d/xorg.conf, I added the followings:

# xdpyinfo | grep -B2 resolution
# https://wiki.archlinux.org/index.php/xorg#Display_size_and_DPI
Section "Monitor"
    Identifier             "<default monitor>"
    DisplaySize             345 195    # In millimeters
EndSection

This sets the system-wide dpi settings to the right 143dpi:

$ xdpyinfo | grep dots
resolution:    142x142 dots per inch

I also did all the above mentioned tweakings too:

  • System settings (in Unity panel) -> Displays -> Scale for menu and title bars: 1.25
  • In chromium, I start with: chromium-browser --enable_hidpi=1
  • In Firefox I set in about:config -> layout.css.devPixelsPerPx: 1.4
  • In atom.io, I commented on this issue

Pretty much I need to tweak every application, I plan to use. Also in browsers this zoom also results blurry images (icons, buttons on webpages, etc), because it gets zoomed too. I would love to set some image to 1:1 and 2:1 size with a single click or gesture.

Hope it adds some useful info as of 9th of October 2014.

2
  • I think you can fix the bluriness by scaling a multiple of 12. In yourself case set the dpi to 144 Aug 2, 2015 at 21:11
  • +1 for putting date in your post. I do that sometimes but you're reminding me I need to do it more often. (hint for everyone else). Nov 28, 2016 at 20:04
5

You can find your DPI with this command:

xrdb -query | grep dpi

You can set your DPI by creating the file ~/.Xresources with this content:

Xft.dpi: 96

Replace 96 with your desired DPI.

2
  • 1
    And dont forget to xrdrb -merge it
    – RichieHH
    Feb 12, 2021 at 23:00
  • Does this work on both X and Wayland?
    – Flimm
    Jul 13, 2023 at 12:49
3

You can scale everything with xrandr, which is probably what you're looking for. I'm not sure how it works internally, but the effect seems to be a dpi change.

To scale your resolution, first find the name of your display with xrandr:

lars:~$ xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 1600 x 1600
LVDS connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1366x768       60.0*+
   1280x768       60.0 +
   1280x720       60.0 +
   1024x768       60.0 +
   1024x600       60.0 +
   800x600        60.0 +
   800x480        60.0 +
   720x480        60.0 +
   640x480        60.0 +
DFP1 disconnected (normal left inverted right x axis y axis)
CRT1 disconnected (normal left inverted right x axis y axis)

So, in my case my laptop display is called LVDS.

Then run the following to scale your resolution:

xrandr --output LVDS --scale 0.75x0.75

The Launcher and Panel might disappear for a moment, but just hover your cursor over them and they should reappear. You might also have to resize any open windows so that they fit the smaller resolution.

1
  • 2
    This one blurs the output
    – Beernarrd
    Dec 29, 2018 at 21:16
2

As I ended up on this question looking for windows HiDPI scaling in Ubuntu Gnome, here's my addition to random suggestions, so that I'll find it when I need it again. :)

To access this dialog, open Gnome Tweaks and go to Windows section.

Gnome Tweaks - Windows

1

I am using Zorin8 (based on Ubuntu13.x).

You could scale the screen with mouse (1024/800=1.28, 768/600=1.28):

xrandr --output LVDS1 --mode 800x600 --panning 1024x768 --scale 1.28x1.28

Or only pan the screen, so you have to use the mouse to see parts that are not visible on screen:

xrandr --output LVDS1 --mode 800x600 --panning 1024x768
-2

You can't actually change the physical ppi of your monitor. The real ppi is the actual hardware ppi, however most software will assume a ppi of 72 dpi for historical reasons, though 96 dpi is not uncommon now.

You can change the resolution of the monitor, which changes the translated ppi, and you can change things like the font size.

If you install MyUnity you can change the font DPI, amongst other things.

If you had a true 1024x768 pixel (resolution) monitor and it was true 72dpi, it would be about a 17" monitor. If you set a font size of 72 then a character would be 1" high. If you set the display to 800x600 resolution then the font would be larger, while setting 1600x1200 would make the font appear smaller.

1
  • What about xorg options like "UseEDIDDpi" and "DPI"? I have read that for example the first one can disable reading the EDID from the video card in case it is read wrong and with DPI you can change DPI. This is what confuses me. Oct 8, 2012 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .