Bug 187090 - Too thin font rendering if opacity < 1 on 1x resolution display
Summary: Too thin font rendering if opacity < 1 on 1x resolution display
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 11
Hardware: Mac macOS 10.13
: P2 Minor
Assignee: Myles C. Maxfield
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-27 01:32 PDT by HerrSiering
Modified: 2022-07-15 13:29 PDT (History)
4 users (show)

See Also:


Attachments
Left: Safari, right: Chrome (25.02 KB, image/png)
2018-06-27 01:32 PDT, HerrSiering
no flags Details
Zoomed in differences in rendering (445.30 KB, image/png)
2018-07-02 04:54 PDT, HerrSiering
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description HerrSiering 2018-06-27 01:32:14 PDT
Created attachment 343702 [details]
Left: Safari, right: Chrome

I found a rather strange rendering issue for fonts under certain conditions.

The basic setup is as follows: I animate the opacity of a link (white color) on hover. It has 0.75 opacity and an opacity of 1 on hover. The font is Fira Sans. Changing to a different font, e.g. -apple-system, does not change the behaviour, though.

The rendering in Safari macOS (Version 11.1.1 (13605.2.8)) is very thin compared to other browsers. This is happening on 1x resolution displays, on retina displays the font display is fine.

My guess at what is happening here:

My understanding is that Safari uses -webkit-font-smoothing: subpixel-antialiased as the default for rendering fonts. Which works great as long as you don't run the setup described above – opacity > 1, 1x resolution display. Then, some pixels are not rendered as font but rather as background, which results in a font display that rather reminds me of back-in-the-day IE6 font rendering than an optimized font.

Which would explain why this issue does not show up with higher pixel density. There are simply enough pixels present to warrant a good font display.

Using text-rendering: optimizelegibility; did not fix this. I also tried using -webkit-font-smoothing: antialiased – but that changes the font rendering in Chrome (Version 67.0.3396.87 (Official Build) (64-bit), but I guess that doesn't matter) to a too thick font display on macOS, unfortunately.

I was not able to find any further information anywhere on solving this, though I can't imagine no one else ran into this problem so far. Strange…
Comment 1 HerrSiering 2018-06-27 01:38:00 PDT
I also recreated the issue in a Codepen: https://codepen.io/HerrBertling/pen/eKPgqx
Comment 2 Simon Fraser (smfr) 2018-06-27 10:14:10 PDT
We can't easily do font smoothing when we render into the temporary buffer that is needed for opacity.
Comment 3 HerrSiering 2018-06-28 06:05:06 PDT
I don't know a lot about what is going on in the browser's engine on such a deep level, but I guess that is Safari (architecture) specific? The font is rendering fine in Chrome with the same setup.
Comment 4 HerrSiering 2018-07-02 04:54:23 PDT
Created attachment 344095 [details]
Zoomed in differences in rendering

My lovely colleague Silke provided a handy overview of what is happening both in Chrome and Safari :)

Also, thanks for the answer, Simon! My question from the other comment was not aimed at "Hey, the others are able to solve this, why not you?" – which I noticed could be read that way. Sorry for that. What I meant was: I'd like to understand what exactly is going wrong here and how this could be fixed.

Looking at Silke's screenshot, we assume that Chrome magically applies a different font smoothing for the lower opacity case somehow?
Comment 5 Myles C. Maxfield 2018-07-09 22:41:24 PDT
(In reply to HerrSiering from comment #4)
> Created attachment 344095 [details]
> Zoomed in differences in rendering
> 
> My lovely colleague Silke provided a handy overview of what is happening
> both in Chrome and Safari :)
> 
> Also, thanks for the answer, Simon! My question from the other comment was
> not aimed at "Hey, the others are able to solve this, why not you?" – which
> I noticed could be read that way. Sorry for that. What I meant was: I'd like
> to understand what exactly is going wrong here and how this could be fixed.
> 
> Looking at Silke's screenshot, we assume that Chrome magically applies a
> different font smoothing for the lower opacity case somehow?

Which specific operating system are you testing on? The details of text antialiasing changed in macOS Mojave.
Comment 6 Simon Fraser (smfr) 2018-07-10 11:02:23 PDT
opacity things never got smoothing.
Comment 7 HerrSiering 2018-07-16 01:44:57 PDT
Hey Myles, the behaviour is observable in macOS 10.13.5 – my gut feeling says it was like this in earlier versions as well. Not able to test that, though.
Comment 8 Brent Fulgham 2022-07-15 13:29:04 PDT
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.