Most of time, I work on a Linux box running CentOS 7 through VNC. The largest VNC screen size is 1920x1080 (16:9). It is ok when you maximize the RealVNC viewer window on an external monitor with that resolution. On my Macbook Pro, there are two black areas on top and bottom because the Retina display is 2880x1800 (16:10), and the font looks small and blurry. I have to switch VNC screen side to 1680x1050 (16:10), the font size is proper, but still blurry. How can I make VNC sharp as a native MacOS app?
First, create a larger screen on VNC as below, then you will have the same size VNC screen as Macbook Pro.
- Create a modeline using
cvt
- Create a new mode using the modeline
- Add the new mode
- Switch to the new mode
- Set screen DPI to 220, which is the DPI of Macbook Pro’s Retina Display
[bwang@bwang ~]$ cvt 2880 1800
# 2880x1800 59.97 Hz (CVT 5.18MA) hsync: 111.84 kHz; pclk: 442.00 MHz
Modeline "2880x1800_60.00" 442.00 2880 3104 3416 3952 1800 1803 1809 1865 -hsync +vsync
[bwang@bwang ~]$ xrandr --newmode "2880x1800_60.00" 442.00 2880 3104 3416 3952 1800 1803 1809 1865 -hsync +vsync
[bwang@bwang ~]$ xrandr
Screen 0: minimum 32 x 32, current 1680 x 1050, maximum 32768 x 32768
VNC-0 connected primary 1680x1050+0+0 0mm x 0mm
1920x1080 60.00 +
1920x1200 60.00
1600x1200 60.00
1680x1050 60.00*
1400x1050 60.00
1360x768 60.00
1280x1024 60.00
1280x960 60.00
1280x800 60.00
1280x720 60.00
1024x768 60.00
800x600 60.00
640x480 60.00
2880x1800_60.00 (0x29f) 442.000MHz -HSync +VSync
h: width 2880 start 3104 end 3416 total 3952 skew 0 clock 111.84KHz
v: height 1800 start 1803 end 1809 total 1865 clock 59.97Hz
[bwang@bwang ~]$ xrandr --addmode 2880x1800_60.00
xrandr: --addmode requires two arguments
Try 'xrandr --help' for more information.
[bwang@bwang ~]$ xrandr --addmode VNC-0 2880x1800_60.00
[bwang@bwang ~]$ xrandr
Screen 0: minimum 32 x 32, current 1920 x 1080, maximum 32768 x 32768
VNC-0 connected primary 1920x1080+0+0 0mm x 0mm
1920x1080 60.00*+
1920x1200 60.00
1600x1200 60.00
1680x1050 60.00
1400x1050 60.00
1360x768 60.00
1280x1024 60.00
1280x960 60.00
1280x800 60.00
1280x720 60.00
1024x768 60.00
800x600 60.00
640x480 60.00
2880x1800_60.00 59.97
[bwang@bwang ~]$ xrandr -s 2880x1800_60.00
[bwang@bwang ~]$ xrandr --dpi 220
[bwang@bwang ~]$ xdpyinfo
...
screen #0:
dimensions: 2880x1800 pixels (332x207 millimeters)
resolution: 220x221 dots per inch
depths (7): 1, 4, 8, 16, 24, 32, 24
root window id: 0x268
depth of root window: 24 planes
number of colormaps: minimum 1, maximum 1
default colormap: 0x20
default number of colormap cells: 256
preallocated pixels: black 0, white 16777215
options: backing-store WHEN MAPPED, save-unders NO
largest cursor: 2880x1800
current input event mask: 0xda0003
KeyPressMask KeyReleaseMask StructureNotifyMask
SubstructureNotifyMask SubstructureRedirectMask PropertyChangeMask
ColormapChangeMask
number of visuals: 240
default visual id: 0x21
...
The font size is too small to read. I tried several ways to make the fonts larger:
- Tweak tool -> Windows -> HiDPI -> Window Scaling, change 1 to 2. This method make the font and window larger, but it is too large to me. Another issue is the font of menu is still small.
- Run
gsettings set org.gnome.desktop.interface.scaling-factor 2
. Only integer is allowed, and make the font size larger on the menu bar, but not the font of terminal.
- Scale X window
xrandr --screen 0 --output VNC-0 --scale 2x2
. This scaling bases on bitmap, it will cause blurry. And I ran multiple times into trouble when I set to 0.5x0.5 then 1x1, the screen zoom in with only big pixels, then I have to restart VNC server.
- Set font scaling factor: Tweak Tool -> Fonts -> Scaling Factor. Changing to 1.5 works for me. This change makes the font larger everywhere: system menu and terminal, except Intellij IDEA. The font still look small, but it is super sharp.
gsettings set org.gnome.desktop.interface text-scaling-factor 1.5
If the VNC server restarts, the new screen size will be lost. Need to find a better way to set it. Of course, I can put those commands in VNC xstartup or xinitrc.
Another thing is to make it easier to switch to lower resolution.