How do I increase the font size for a specific application in Ubuntu 18.04 running Gnome?

Solution 1:

Create a script call ue (Unity Editor). Place within it:

#!/bin/bash
xrandr --dpi 144
unity-editor "$@"    # Or whatever the program is you want to run

Mark the script as executable using:

chmod a+x ue

Call the script using

./ue
  • Or replace ./ with the directory name if not in the current directory
  • Or leave off ./ if you have placed ue in your $PATH like ~/bin or /usr/local/bin

Adjust 144 to 192 if you want it double magnification. Smaller if you want less magnification.

Your screen may blink when script starts up but that is normal.


TL;DR

The default DPI (Dots Per Inch) is 96. When set to 100 font size increased by 4% which might not be noticeable. To confirm initial DPI use one of these commands:

$ xdpyinfo | grep dots
  resolution:    96x96 dots per inch

$ grep DPI /var/log/Xorg.0.log
[     9.555] (--) NVIDIA(0): DPI set to (43, 44); computed from "UseEdidDpi" X config
[     9.761] (==) modeset(G0): DPI set to (96, 96)

In the above script you can reset xrandr back to default DPI of 96 by adding the following line to the bottom:

xrandr --dpi 96

I've never encountered a need to do this, but you might.

Solution 2:

The following does not change only the font, but scales the entire interface:

 QT_SCALE_FACTOR=1.34 application

Possibly, one may also want to play around with the above in combination with QT_AUTO_SCREEN_SCALE_FACTOR=1 and QT_AUTO_SCREEN_SCALE_FACTOR=0.

I hope hope it can be useful, though it is not exactly what you seek.