32

I've been using Ubuntu 16.04 with dual 4k displays for about 3-4 months now, but all of a sudden today, the zoom level & UI size seems off in Chrome.

The dual-display screenshot has 3 windows (from left to right): Visual Studio Code, Chromium, and Chrome.

As you can see, Chrome and Chromium are arriving at different conclusions for what scale things ought to be.

a screenshot wherein Visual Studio Code, Chrome, and Chromium indicate the zoom problem

Since Visual Studio Code is built on the Electron Platform, it's effectively an instance of Chrome, so that's why I included it here for comparison. The left pane w/ the file list is normally about 60% of the size in this screen shot.

For both Chrome and VS Code, zooming out 2-levels gets it roughly to where it's been all along.

So, Question: How do I fix this so that I don't have to zoom in/out in Chrome?

Also:

  • in Display settings in Ubuntu remain the same--both displays @ 3840x2160 res and a 1.5x scale factor for 'menu and title bars'.

  • My system is an i5 6600K w/ GTX 960 using the NVIDIA binary driver, v 361.45.18

  • the Menu font in all windows appears slightly larger than usual

Brandon
  • 1,259

8 Answers8

43

I figured this out, thanks in part to the Angel who wrote this.

tl;dr: do this:

  1. Go to your Settings -> Displays
  2. Note what the value of the slider is at "Scale for menu and title bars" (mine was 1.5)
  3. Open a terminal
  4. sudo gedit /usr/share/applications/google-chrome.desktop
  5. Find this line (at approx 108):

Exec=/usr/bin/google-chrome-stable %U

  1. Change it to this (where n is the value you noted in step #2):

Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=n %U

  1. Save/close, relaunch Chrome.

Unfortunately this doesn't seem to work with VS Code, but that's less of an issue, as you can simply zoom out (View Menu -> Zoom Out), and it affects the entire UI.

Explanation: Ubuntu applies a system-wide scaling factor to the UI in hi-DPI monitors. Chrome thinks it's so special, so it ignores that and does its own thing.

The link above recommends changing to a 1 scaling factor, but this is the equivalent of 0 scaling (not OK for hi-dpi).

By mirroring the system scale factor, you bring Chrome in-line w/ everything else.

Brandon
  • 1,259
5

I managed to get Chrome to auto-scale to the same scale I'm using in gnome desktop by doing the following:

I created a bash script at /usr/bin/chrome-scaled:

#!/bin/bash
text_scale=$(gsettings get org.gnome.desktop.interface text-scaling-factor)
/usr/bin/google-chrome-stable --high-dpi-support=1 --force-device-scale-factor=$text_scale %U

And then I created a new desktop shortcut at /user/share/applications/chrome-scaled.desktop:

[Desktop Entry]
Version=1.0
Name=Google Chrome
GenericName=Web Browser
Comment=Access the Internet
Exec=/usr/bin/chrome-scaled
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
X-Ayatana-Desktop-Shortcuts=NewWindow;NewIncognito
Name[en_CA]=Chrome Scaled

Then I opened the shortcut and locked it to my launcher. Now, whatever scale you're using in gnome will also be used in Chrome.

You could also potentially avoid creating the new .desktop file and just edit the google-chrome.desktop file instead.

4

The problem still persists when using Google Chrome under Ubuntu 18.04. I didn't want to touch the system-wide desktop file (which I believe may get overridden by a Chrome update), so I've edited the Chrome launcher using the Alacarte menu editor, adding the --force-device-scale-factor=n as Brandon has instructed. It worked, but only for launching Chrome from the overview. When launching it from the dock, the scale factor override was disregarded, and all the fonts were again small. To fix it, I've edited the ~/.local/share/applications/google-chrome.desktop (created probably by Alacarte), inserting --force-device-scale-factor=n in every line after Exec=/usr/bin/google-chrome-stable - there are three such lines in the desktop file, and Alacarte only altered the first, but not those for "New Window" and "New Incognito Window". Now the font dpi override works even when launching Chrome from the dock, and I haven't had to alter files as root.

2

Try adding:

Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=0.8 %U

in chrome.desktop file and fonts in tabs and menu look nice.

kenorb
  • 26,615
2

For chromium and ubuntu:

Edit /etc/chromium-browser/default:

CHROMIUM_FLAGS="--force-device-scale-factor=n --high-dpi-support=1"
0

Running 18.04, I had the same experience reported by @nur in comments: --force-device-scale-factor was ignored. In my case I was using Chromium.

I wanted to update the Chromium scaling (too small). I discovered nur's post a month later at https://askubuntu.com/a/963997/457417 where they reported on a solution:

  1. If you have Chromium installed (in my case, the apt package via the Ubuntu Software Center), uninstall it and remove the config folder from ~/.config/chromium
  2. set a systemwide scaling, either thru the GUI or in my case with the terminal (gsettings set org.gnome.desktop.interface text-scaling-factor 1.2) https://askubuntu.com/a/1041423/457417
  3. reinstall Chromium - again, the apt package via Ubuntu Software Center

This answer is a bit off from the question, but I think it could help someone using more recent Ubuntu defaults.

0

I did what was said above and it worked what was not clear was ...

When I opened the file using this terminal command:

$ sudo gedit /usr/share/applications/google-chrome.desktop

the only line that looked similar was at the very bottom: and showed this:

Exec=/usr/bin/google-chrome-stable --incognito

So I commented the line out, ... and added the line with a 200 value

So it looks like this

Commented out by Mark Exec=/usr/bin/google-chrome-stable --incognito

Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=200 %U

0

OK so definitively this works, as mentioned in the accepted answer.

$ sudo gedit /usr/share/applications/google-chrome.desktop

At about line 108, find Exec=/usr/bin/google-chrome-stable %U

Change it to:

Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=n %U

n being the numerical decimal scaling factor. Typically between 1.0 - 2.0.

ZygD
  • 2,577