[Webkit-unassigned] [Bug 283310] New: [GTK] Changing system font-scaling factor results in larger than expected fonts (Epiphany, Geary, WebKitGtk)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Nov 18 11:39:02 PST 2024


https://bugs.webkit.org/show_bug.cgi?id=283310

            Bug ID: 283310
           Summary: [GTK] Changing system font-scaling factor results in
                    larger than expected fonts (Epiphany, Geary,
                    WebKitGtk)
           Product: WebKit
           Version: WebKit Local Build
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKitGTK
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: serg.partizan at gmail.com
                CC: bugs-noreply at webkitgtk.org, gwhitneycom5 at pobox.com

Created attachment 473270

  --> https://bugs.webkit.org/attachment.cgi?id=473270&action=review

Screenshot of incorrect behaviour

I was on a quest to fix font scaling in Geary, and it led me here.

I'm using `text-scaling-factor` 1.3 in Gnome, and I noticed that my fonts in Geary are slightly larger than usual. It's fine for an email client, but I also checked Epiphany, and the difference there is quite noticeable.

I started digging, and found that Epiphany uses `webkit_settings_font_size_to_pixels()` to set the default font size. Documentation says it's converting to pixels based on screen DPI.

However, it looks like `default-font-size` does not expect a value based on current DPI; it expects "px" as in CSS, without DPI scaling. This leads to larger fonts.

I'm not sure when this started to happen, but this PR is probably related: https://github.com/WebKit/WebKit/pull/28691
And this issue: https://bugs.webkit.org/show_bug.cgi?id=250138

I attempted to fix this in Epiphany: https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1675 but it would probably be better fixed here.

If `webkit_settings_font_size_to_pixels()` is expected to be used for setting `default-font-size`, then they should use compatible units. My expectation is that this should be "px", as in CSS, because when "default-font-size" is "16px", it should be the same as "16px" in CSS.

Another way is to leave `webkit_settings_font_size_to_pixels()` as DPI-dependent pixels, but change `default-font-size` to also be DPI-dependent. But it think this is pretty unexpected.

This is happening with the following versions:

* epiphany 47.2-1
* webkit2gtk-4.1 2.46.3-1 (used in Geary)
* webkitgtk-6.0 2.46.3-1 (used in Epiphany)

I'm using this page for testing: https://jsbin.com/vemalijalo/1

Expected result: Fonts should be the same size.
Actual result: Fonts are different

If I replace `webkit_settings_font_size_to_pixels` with custom implementation that does `points * 96/72 in Epiphany, it works as expected.


I was advised to ask gwhitneycom5 at pobox.com for additional feedback on this.
I can implement a PR after we decide on the way forward, but I'd also be happy to leave the work to the professionals, I expect this to be one-line change and probably would be faster this way.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20241118/5730be11/attachment.htm>


More information about the webkit-unassigned mailing list