24

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

27

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:

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.

  • 1
    As noted by Angel in the linked article above this is now fixed in Chrome however a very related issue is the issue I am having. Is there anyway to get Chrome to refresh the scaling after you make a change without having to restart Chrome? – joesk Feb 10 '17 at 15:34
  • I'm on Ubuntu 16.04 as well using Google Chrome Beta. This answer worked with a tweak of replacing every google-chrome instance with google-chrome-beta. Cheers. – Keith OYS Jun 1 '17 at 1:03
  • I can't set scale factor to 0.5 for example, however my fonts in Chromium still too big. Any other solution? – Aleksey K Jul 24 '17 at 3:49
  • 3
    I applied this answer to my system (scaling = 0.875), but it doesn't seem to have any effect on Chrome at all. – Nur Sep 5 '17 at 11:05
  • If your using a launcher, make sure to up date it there as well. It worked for both chrome stable, and beta 71.0.35 – MeowMeow Dec 8 '18 at 21:40
3

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.

  • 1
    Works, but also shrinks the content within the browser – Ricky Boyce Sep 18 '18 at 4:48
  • I also had to edit the Exec for the Actions for it to work, otherwise it would just use the default hidpi settings and ignore the edited Exec order. – Alfredo Hernández Sep 24 '18 at 15:09
2

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.

  • After doing the changes you mentioned, the effects took place after I logged out and then logged in again. I also removed Google Chrome from favorites and then added it again. – Apoorv Potnis Dec 15 '18 at 4:50
0

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.

  • 1
    Does this still works for you? I tried this (at 0.8 and 0.875) but it doesn't have any effect. – Nur Sep 5 '17 at 11:07
  • seems like it uses the system scaling now, per the accepted answer. I am using gnome tweak tool to modify that and it affects chrome too apps.ubuntu.com/cat/applications/gnome-tweak-tool – jaimedash Dec 20 '17 at 20:49
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.