Closed Bug 1211547 Opened 10 years ago Closed 1 year ago

Firefox should respect Gnome 3/GTK3 font scale [HiDPI support]

Categories

(Core :: Widget: Gtk, defect, P2)

defect

Tracking

()

RESOLVED FIXED
131 Branch
Tracking Status
relnote-firefox --- 131+
firefox131 --- fixed

People

(Reporter: jonasthiem, Assigned: velsinki)

References

Details

(Whiteboard: tpi:+)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0 Build ID: 20151004030211 Steps to reproduce: To work on a very high DPI display, I scaled up all fonts with the gnome-tweak-tool in Gnome 3 to 1.5. This works splendidly... except that firefox entirely ignores it. As a result, all page contents, the tab titles, the URL bar, ... are still TINY and close to unusable. In an age of massively growing pixel density, this seems unacceptable. It would be nice if firefox could be fixed in the very near future to respect the font scaling as well, so the user can easily fix their DPI or font scale settings and have firefox respect them. (This should explicitly include increasing the default font size for all websites) Actual results: I changed font scale factor in gnome-tweak-tool to 1.5, firefox ignores it Expected results: When I change font scale factor in gnome-tweak-tool to 1.5, firefox respects it and scales up the entire UI *and* the default website font sizes accordingly
Status: UNCONFIRMED → NEW
Ever confirmed: true
Environment: Ubuntu 14.04 x32 Nightly 45.0a1. Able to reproduce.
Component: Untriaged → Theme
Jonas, could you test whether this is the case if you change the pref below? Steps: 1. Set gfx.font_rendering.fontconfig.fontlist.enabled to 'false' 2. Restart I'm guessing this won't help but it would be useful to know if this somehow solves the problem.
Flags: needinfo?(jonasthiem)
I wonder what gnome-tweak-tool is setting. I'm not using GNOME and so there is no X Settings daemon and "echo Xft.dpi: 144.0 | xrdb -merge" provides double-sized UI and web pages. Xft.dpi: 143.0 only increases UI font sizes. We should add a 1.5x step, but that is not the issue reported here. Putting GDK_SCALE=2 in the environment should give double sized UI and web pages even in GNOME. GDK_SCALE=1.5 gets rounded to 1 by GDK I assume.
Component: Theme → Widget: Gtk
Product: Firefox → Core
Setting gfx.font_rendering.fontconfig.fontlist.enabled to 'false' does nothing. However, I found something interesting: 1. Fonts > "Scaling factor" only scales up fonts by factors like 1.0, 1.5, ... which firefox entirely ignores (but it works for all other apps) 2. However, there is a separate actual HiDPI setting Windows > Window Scaling which only does integer factors 1, 2, ... very interestingly, this scales up the tab widget sizes and all of firefox *but again not the fonts*, so firefox has suddenly really tiny tab captions and page contents while the tab top is huge
Flags: needinfo?(jonasthiem)
(the HiDPI scaling might or might not correspond to GDK_SCALE I suppose - but anyway, the interesting point here is that again, firefox is ignoring that too in regards to the font size)
Thanks for the update, Jonas. Your experience is quite different from mine, but we have different systems. Can you check in about:config, please, that layout.css.devPixelsPerPx is at its default value of -1.0?
Let me just paste the modified preferences as listed by about:support: "modifiedPreferences": { "accessibility.typeaheadfind.flashBar": 0, "browser.cache.disk.hashstats_reported": 1, "browser.cache.disk.smart_size.first_run": false, "browser.cache.disk.smart_size.use_old_max": false, "browser.cache.disk.capacity": 358400, "browser.cache.disk.filesystem_reported": 1, "browser.cache.frecency_experiment": 4, "browser.download.importedFromSqlite": true, "browser.download.useDownloadDir": false, "browser.places.smartBookmarksVersion": 7, "browser.sessionstore.upgradeBackup.latestBuildID": "20151123030237", "browser.startup.homepage_override.mstone": "45.0a1", "browser.startup.homepage_override.buildID": "20151123030237", "browser.tabs.warnOnClose": false, "browser.tabs.crashReporting.sendReport": false, "browser.tabs.remote.autostart.2": false, "dom.ipc.processCount": 3, "dom.apps.reset-permissions": true, "dom.mozApps.used": true, "extensions.lastAppVersion": "45.0a1", "font.internaluseonly.changed": false, "gfx.crash-guard.glcontext.deviceID": "Mesa DRI Intel(R) Sandybridge Mobile ", "gfx.crash-guard.glcontext.appVersion": "43.0a1", "gfx.canvas.azure.backends": "skia", "gfx.crash-guard.glcontext.driverVersion": "3.0 Mesa 10.6.3 (git-ccef890)", "gfx.font_rendering.fontconfig.fontlist.enabled": false, "gfx.crash-guard.status.glcontext": 2, "gfx.canvas.azure.accelerated": true, "layers.enable-tiles": true, "layers.acceleration.force-enabled": true, "media.peerconnection.enabled": false, "media.getusermedia.screensharing.enabled": false, "media.gmp-manager.buildID": "20151123030237", "media.gmp-gmpopenh264.lastUpdate": 1447508098, "media.gmp-gmpopenh264.version": "1.5.1", "media.gmp-gmpopenh264.autoupdate": true, "media.gmp-gmpopenh264.abi": "x86_64-gcc3", "media.gmp-manager.lastCheck": 1448346347, "network.http.fast-fallback-to-IPv4": false, "network.cookie.prefsMigrated": true, "network.http.max-persistent-connections-per-server": 2, "network.http.pipelining": true, "network.http.max-connections": 16, "network.predictor.cleaned-up": true, "network.http.max-persistent-connections-per-proxy": 1, "places.database.lastMaintenance": 1447725592, "places.history.expiration.transient_current_max_pages": 104858, "plugin.importedState": true, "plugin.disable_full_page_plugin_for_types": "application/pdf", "print.print_plex_name": "default", "print.print_margin_top": "0.5", "print.print_paper_width": "215.90", "print.print_to_file": false, "print.print_evenpages": true, "print.print_orientation": 0, "print.print_unwriteable_margin_right": 25, "print.print_paper_height": "279.40", "print.print_unwriteable_margin_left": 25, "print.print_margin_left": "0.5", "print.print_scaling": " 1.00", "print.print_unwriteable_margin_bottom": 56, "print.print_resolution_name": "default", "print.print_duplex": 0, "print.print_margin_right": "0.5", "print.print_oddpages": true, "print.print_bgcolor": false, "print.print_colorspace": "default", "print.print_bgimages": false, "print.print_downloadfonts": false, "print.print_shrink_to_fit": true, "print.print_unwriteable_margin_top": 25, "print.print_paper_name": "na_letter", "print.print_margin_bottom": "0.5", "print.print_in_color": true, "print.print_paper_size_type": 1, "print.print_page_delay": 50, "print.print_paper_data": 0, "print.print_paper_size_unit": 1, "print.print_resolution": 600, "privacy.sanitize.timeSpan": 0, "privacy.trackingprotection.ui.enabled": true, "privacy.cpd.downloads": false, "privacy.cpd.cookies": false, "privacy.donottrackheader.value": 1, "privacy.sanitize.migrateFx3Prefs": true, "privacy.donottrackheader.enabled": true, "privacy.cpd.formdata": false, "privacy.cpd.sessions": false, "privacy.cpd.history": false, "privacy.sanitize.migrateClearSavedPwdsOnExit": true, "privacy.trackingprotection.enabled": true, "security.ssl3.ecdhe_rsa_rc4_128_sha": false, "security.ssl3.rsa_rc4_128_sha": false, "security.disable_button.openCertManager": false, "security.ssl3.rsa_rc4_128_md5": false, "security.ssl3.ecdhe_ecdsa_rc4_128_sha": false, "storage.vacuum.last.places.sqlite": 1446821745, "storage.vacuum.last.index": 1 },
There is a bug in GTK+ 3 that the font size is extracted from the PangoFontDescription without checking pango_font_description_get_size_is_absolute() [1]. That means the pixel sizes in gtk-font-name (e.g. "Sans 13px" instead of the default "Sans 10") render as point values, which is larger than expected at the default dpi of 96. It also scales the pixel sizes because it thinks they are point sizes. This differs in behavior from GTK+ 2 which usually presents pixels values at the correct size and doesn't scale them with dpi. I suspect this works because GTK+ 2 passes the PangoFontDescription intact to Pango. The expected behaviour can be demonstrated with pango-view pango-view --font="Sans 10" --dpi=143 -t "text" pango-view --font="Sans 13px" --dpi=143 -t "text" Is it possible that somehow the gtk-font-name for GTK+ 3 on your system has a pixel size? Do you know what is setting that? I'm not so keen to emulate GTK's bug in Gecko. It would be better to fix GTK+ 3. If GTK+ 3 is not going to be fixed, then any tools that set the pixel sizes are not supported by GTK+ 3. [1] https://git.gnome.org/browse/gtk+/tree/gtk/gtkcssenumvalue.c?h=3.18.5#n154
Priority: -- → P2
Whiteboard: tpi:+
Jan is working on the Gtk/HiDPI issues right now.
Assignee: nobody → jhorak
See Also: → 1464606

I think the work-around is setting layout.css.devPixelsPerPx in about:config to same value as Gnome Tweak.

This issue has been fixed for me with version 103.0
I am on Arch Linux

Severity: normal → S3

https://hg.mozilla.org/mozilla-central/rev/8fe4738543cb effectively fixed this for a couple of font scales. But there is no need to hard code a bunch of "allowed" scales anymore. GTK3 and GTK4 apps scale their fonts well for any scale factor in my experience.

Note that the official "Large Text" scaling is 1.25. I am helping change this to be more continuous though, over at GNOME Settings: https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2085. This works fine for almost all apps, except for Firefox.

I propose to just remove the hardcoded options in gfxPlatformGtk::GetFontScaleFactor(), and just stick with GetFontScaleDPI() / 96.0. Users with "Large Text" enabled will see no change, whereas users with (experimental) Text scaling other than 1.25 will see Firefox scale well too.

(In reply to Matthijs Velsink [:velsinki] from comment #12)

https://hg.mozilla.org/mozilla-central/rev/8fe4738543cb effectively fixed this for a couple of font scales. But there is no need to hard code a bunch of "allowed" scales anymore. GTK3 and GTK4 apps scale their fonts well for any scale factor in my experience.

Note that the official "Large Text" scaling is 1.25. I am helping change this to be more continuous though, over at GNOME Settings: https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2085. This works fine for almost all apps, except for Firefox.

I propose to just remove the hardcoded options in gfxPlatformGtk::GetFontScaleFactor(), and just stick with GetFontScaleDPI() / 96.0. Users with "Large Text" enabled will see no change, whereas users with (experimental) Text scaling other than 1.25 will see Firefox scale well too.

I think this would be a great solution. I use a scaling factor < 1 with 200% scaling and firefox just ignoring it is annoying. Especially given the unneeded complexity in that code path.

Feel free to take this one and work on it, patches welcomed.

(In reply to Martin Stránský [:stransky] (ni? me) from comment #14)

Feel free to take this one and work on it, patches welcomed.

You're welcome :)

Thanks, we'll look at it.

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5b171abf4dc1 Don't round font scaling for GTK. r=emilio
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 131 Branch

After this commit has landed, Firefox Nightly on my Fedora 40 (x86_64) Linux machine ignores my setting of layout.css.devPixelsPerPx to 1.7; instead, it visually appears to revert to a setting that is probably '1.0' (which is wrong on my HiDPI monitor). I found and verified it was this commit by bisection. Based on patching the source, it appears that GetFontScaleDPI() is returning 82 for me. Patching gfxPlatformGtk::GetFontScaleFactor() to return a minimum of 1 restores layout.css.devPixelsPerPx's effects to normal.

Can you file a separate bug for that, ideally with some details about your x11/Wayland/DE configuration? It seems you have a less-than-one resolution configured somewhere or so which we were ignoring before this.

Filed as bug #1916732 hopefully with enough details.

Release Note Request (optional, but appreciated)
[Why is this notable]: surprised some users - see https://bugzilla.mozilla.org/show_bug.cgi?id=1922556#c17
[Affects Firefox for Android]: no
[Suggested wording]: Improved HiDPI support: Firefox now fully respects Gnome 3/GTK3 font scaling settings for a more consistent UI experience on high-resolution displays
[Links (documentation, blog post, etc)]:

relnote-firefox: --- → ?
Version: 44 Branch → unspecified

not sure that my wording is correct

Assignee: jhorak → mvelsink

Mathew, is there anything I should do here? I have very limited rights within the Mozilla ecosystem.

The release note request sounds good to me, but it should be made clear this is only for Linux.

Flags: needinfo?(mathew.hodson)

Added to 131 release notes with slightly altered wording
"Firefox improved HiDPI support for Linux users by now fully respecting Gnome 3/GTK3 font scaling settings, creating a more consistent user interface experience on high-resolution displays"

Flags: needinfo?(mathew.hodson)

(In reply to Matthijs Velsink [:velsinki] from comment #25)

Mathew, is there anything I should do here? I have very limited rights within the Mozilla ecosystem.

I was just fixing the assignee since you mentioned you couldn't comment even though you submitted the patch.

Duplicate of this bug: 1818229
Duplicate of this bug: 1868867
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: