NEW 283310
[GTK] Changing system font-scaling factor results in larger than expected fonts (Epiphany, Geary, WebKitGtk)
https://bugs.webkit.org/show_bug.cgi?id=283310
Summary [GTK] Changing system font-scaling factor results in larger than expected fon...
serg.partizan
Reported 2024-11-18 11:39:02 PST
Created attachment 473270 [details] 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@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.
Attachments
Screenshot of incorrect behaviour (26.65 KB, image/png)
2024-11-18 11:39 PST, serg.partizan
no flags
Note You need to log in before you can comment on or make changes to this bug.