Arbitrary resolution scaling in ubuntu
This is more a reference for myself to save me the web search next time I need it.
I currently use a laptop with a 14" screen and a 2560x1440 resolution. I installed Ubuntu Gnome on it and was disappointed in the out of the box HiDPI support because it's limited to integer factors: 1, 2, 3 etc... No scaling was really too small on 14" and 2x looks a bit too big.
After looking online, I eventually found a solution: render with 2x scaling at a higher resolution then scale back to the native resolution of my screen. This is surprisingly easy to do, only one command is needed:
xrandr --output eDP1 --scale-from 3840x2160 --panning 3840x2160
This works great for a physical resolution of 2560x1440. If your resolution is different, you'll have to do some math or trial and error. Just make sure you keep the same aspect ratio or things will look skewed.
To keep the resolution scaling after reboot, add the command to the Ubuntu Startup Applications screen.