Chrome UI size & zoom levels in Ubuntu 16.04

27

12

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

Posted 2016-08-23T15:48:51.717

Reputation: 881

Answers

30

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.

Brandon

Posted 2016-08-23T15:48:51.717

Reputation: 881

1As 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 – 2017-02-10T15:34:31.007

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 – 2017-06-01T01:03:22.533

I can't set scale factor to 0.5 for example, however my fonts in Chromium still too big. Any other solution? – Aleksey K – 2017-07-24T03:49:24.923

3I applied this answer to my system (scaling = 0.875), but it doesn't seem to have any effect on Chrome at all. – Nur – 2017-09-05T11:05:03.450

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 – 2018-12-08T21:40:50.260

In Ubuntu 18.10, the scaling factor can be found by installing Gnome Tweaks and then in the 'Fonts'. – Apoorv Potnis – 2018-12-15T04:48:54.863

76.03 tweaking this setting in the mentioned file - zero effect. 18.04 , Mint 19.1 , you need to tweak ~/.local/share/applications/google-chrome.desktop – Aubergine – 2019-08-03T22:57:12.523

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.

MWLindenbach

Posted 2016-08-23T15:48:51.717

Reputation: 31

1Works, but also shrinks the content within the browser – Ricky Boyce – 2018-09-18T04:48:34.853

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 – 2018-09-24T15:09:05.730

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.

ciprianl

Posted 2016-08-23T15:48:51.717

Reputation: 21

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 – 2018-12-15T04:50:17.500

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.

Igor Yurko

Posted 2016-08-23T15:48:51.717

Reputation: 11

1Does this still works for you? I tried this (at 0.8 and 0.875) but it doesn't have any effect. – Nur – 2017-09-05T11:07:05.477

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 https://apps.ubuntu.com/cat/applications/gnome-tweak-tool/

– jaimedash – 2017-12-20T20:49:20.990

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.

Ben Creasy

Posted 2016-08-23T15:48:51.717

Reputation: 304

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

markackerman8-gmail.com

Posted 2016-08-23T15:48:51.717

Reputation: 101

0

OK so definitively this worked ... 2 not 200!

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

at the bottom find a line similar to "Exec=/usr/bin/google-chrome-stable --incognito" and ... comment it out, or remove it, or modify it to look like

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

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

The 2 being the scaling factor!

I hope it helps

markackerman8-gmail.com

Posted 2016-08-23T15:48:51.717

Reputation: 101