Bug 218450

Summary: [GTK] System font scaling not applied to 'font-size: XXXpt'
Product: WebKit Reporter: Milan Crha <mcrha>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: badshah400, berto, bugs-noreply, cgarcia, ews-watchlist, gustavo, kozinov, webkit-bugs, zan
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=221033
Attachments:
Description Flags
HTML test file
none
Screenshot with Chrome 100% scaling
none
Screenshot with Chrome 150% scaling
none
Screenshot with Chrome 200% scaling
none
Screenshot with Gnome Web 100% scaling
none
Screenshot with Gnome Web 150% scaling
none
Screenshot with Gnome Web 200% scaling
none
Patch zan: review+

Description Milan Crha 2020-11-02 09:38:06 PST
Upstream bug report against Evolution:
https://gitlab.gnome.org/GNOME/evolution/-/issues/1195

The user has set in the system (GNOME Tweaks) fractional font scaling (1.5 in his case) and WebKitGTK shows text inside <font size="3"></font> in a different size than the fonts out of the <font/> element, while these two should be the same. It does that when the font-size style is declared in 'pt'.

I can fix it on the Evolution side, but in case some future version of the WebKitGTK will apply the system font scaling factor to the 'pt' font-size, it might apply it twice (once by evo, once by WebKit), thus I'm asking whether you think it should be fixed on the application side or on the WebKitGTK side.

Example HTML for testing, where the "size3" and the "size normal" should be of the same size:

<html><head>
<style><!-- body { font-size:10pt; } --></style>
</head><body>
<font size="1">size1</font><br>
<font size="2">size2</font><br>
<font size="3">size3</font>size normal<br>
<font size="4">size4</font><br>
<font size="5">size5</font><br>
<font size="6">size6</font><br>
<font size="7">size7</font><br>
</body></html>
Comment 1 Thomas Stieler 2020-11-23 12:35:13 PST
Hi,

what about this issue, that affects Evolution's mail rendering.
Anyone here wanting to get more information?

Best
Thomas
Comment 2 Milan Crha 2020-12-02 02:07:49 PST
For the record, the font scaling factor is stored in GSettings, at:
org.gnome.desktop.interface text-scaling-factor

I do not see it being read in the WebKit sources.

One other thing, the pages define font sizes in points quite often, with which the application cannot do much, thus when the user wants bigger/smaller fonts, the WebKit can help with it internally. (It would be quite inefficient to traverse the whole document and apply font scaling factor for each affected element within the application.)
Comment 3 Thomas Stieler 2020-12-02 04:38:46 PST
I did some further tests and tested the effect of desktop scaling to the different forms of text size declaration.

I created a HTML table containing text with size declared via CSS in pt, px and rem. I also test the outdated font tag with both relative size ("-2" - "+4") and absolute size (1-7).

You can find the HTML in attached file mail.html.

The I opened the file in Gnome Web and Chrome, you can find screenshots for both browsers with scaling 100%, 150% and 200%.

The summary: While Chrome scales all kind of size declaration, Chrome Web scales only text with size declaration in rem and font tags with both relative and absolute size specification.

Please review the attached screenshots to reproduce my findings!
Comment 4 Thomas Stieler 2020-12-02 04:39:12 PST
Created attachment 415205 [details]
HTML test file
Comment 5 Thomas Stieler 2020-12-02 04:39:43 PST
Created attachment 415206 [details]
Screenshot with Chrome 100% scaling
Comment 6 Thomas Stieler 2020-12-02 04:39:57 PST
Created attachment 415207 [details]
Screenshot with Chrome 150% scaling
Comment 7 Thomas Stieler 2020-12-02 04:40:10 PST
Created attachment 415208 [details]
Screenshot with Chrome 200% scaling
Comment 8 Thomas Stieler 2020-12-02 04:40:30 PST
Created attachment 415209 [details]
Screenshot with Gnome Web 100% scaling
Comment 9 Thomas Stieler 2020-12-02 04:40:42 PST
Created attachment 415210 [details]
Screenshot with Gnome Web 150% scaling
Comment 10 Thomas Stieler 2020-12-02 04:40:55 PST
Created attachment 415211 [details]
Screenshot with Gnome Web 200% scaling
Comment 11 Thomas Stieler 2020-12-02 04:46:25 PST
Unfortunately I can't edit my comment:

The (fixed) summary: While Chrome scales all kind of size declarations, Gnome Web scales only text with size declaration in rem and font tags with both relative and absolute size specification.
Comment 12 Carlos Garcia Campos 2020-12-18 02:35:06 PST
WE are indeed getting and monitoring the text scale changes by GtkSettings:gtk-xft-dpi, but we are only applying it to the default font size and the calculations are not correct. I think we should always set the text scale factor as the WebPageProxy text zoom factor. That will be applied in all the cases.
Comment 13 Carlos Garcia Campos 2020-12-18 03:03:09 PST
Created attachment 416505 [details]
Patch
Comment 14 EWS Watchlist 2020-12-18 03:05:17 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 15 Carlos Garcia Campos 2021-01-11 00:44:02 PST
Committed r271354: <https://trac.webkit.org/changeset/271354>