Problem
Text is displayed imperfectly, when -webkit-background-clip: text
is used.
Screenshot
Code
body {
background: black !important;
color: white;
font-family: Roboto;
font-weight: 200;
}
span {
-webkit-background-clip: text !important;
-webkit-text-fill-color: transparent;
background: white;
}
<span>The first four words</span> are too thin.
Important
The perceived attributes should not be changed by the solution. (I.e. black background, white text, thin font etc.)
The solution should work well in other cases too. (E.g. red background, blue text, thick font etc.)
There should be no side-effects. (E.g text becoming blurry or too thick etc.)
Approach | Problem | |
---|---|---|
increase font-weight |
Makes the text blurry. | filter: custom(…) |
add -webkit-text-stroke |
Makes the text too thick. | semi-transparency |
add text-shadow |
Makes the text blurry. | multiple shadows |
increase font-size |
Should look the same. | transform: scale(0.5) |
change the font-family |
Should look the same. | src: url(Roboto.svg) |
change the background-color |
Should look the same. | rgba(0, 0, 0, 1) |
change the color |
Should look the same. | filter: saturate(0) |
-webkit-font-smoothing: antialiased |
Useless. | - |
text-rendering: optimizeLegibility |
Useless. | - |
transform: translate3d(0, 0, 0) |
Useless. | - |
bug report (find&vote, or create) | Not an instant solution. | draw attention |
Goal
To fix the -webkit-background-clip: text
, preferably by adding a simple CSS declaration.
(JavaScript or other approaches might be useable as well.)