WebKit: Blurry text with css scale + translate3d

CssWebkitScaleBlurryTranslate3d

Css Problem Overview


I'm seeing an issue where Chrome and other WebKit browsers massively blur any css-scaled content that also has translate3d applied.

Here's a JS Fiddle: http://jsfiddle.net/5f6Wg/. (View in Chrome.)

.test {
  -webkit-transform: translate3d(0px, 100px, 0px);
}

.testInner
{
  /*-webkit-transform: scale(1.2);*/
  -webkit-transform: scale3d(1.2, 1.2, 1);
  text-align: center;
}

<div class="test">
  <div class="testInner">
    This is blurry in Chrome/WebKit when translate3d and scale or scale3d are applied.
  </div>
</div>

Are there any known workarounds for this? I get that in the simple example above, I could simply use translate rather than translate3d - the point here is to strip the code down to the bare essentials.

Css Solutions


Solution 1 - Css

Webkit treats 3d transformed elements as textures instead of vectors in order to provide hardware 3d acceleration. The only solution to this would be to increase the size of the text and downscaling the element, in essence creating a higher res texture.

See here: http://jsfiddle.net/SfKKv/

Note that antialiasing is still underpar (stems are lost) so I'm beefing up the text with a bit of text shadow.

Solution 2 - Css

I found that using:

-webkit-perspective: 1000;

on the container of your font or icon set kept things crisp for me after experiment with the issue on Android nexus 4.2 for sometime.

Solution 3 - Css

> A css filter effect is a graphical operation that allows to manipulate the appearance of any HTML element. Since Chromium 19 these filters are GPU accelerates to make them super fast.

CSS3 introduces a bunch of standard filter effects, one of them is the blur fitler:

-webkit-filter: blur(radius);

> The ‘radius’ parameter affects how many pixels on the screen blend into each other, so a larger value will create more blur. Zero of course leaves the image unchanged.

Set the radius to 0 will force browser to use GPU calculation and force it to keep your html element unchanged. It's like applying an "hard edges" effects.

So the best solution for me in order to fix this blurry effect was to add this simple line of code:

-webkit-filter: blur(0);

There is also a known bug that only affects retina screens. (See here: https://stackoverflow.com/questions/20377990/why-doesnt-blur0-remove-all-text-blur-in-webkit-chrome-on-retina-screens). So in order to make it works also for retina, I recommend to add this second line:

-webkit-transform: translateZ(0);

Solution 4 - Css

Try this

 ...{
zoom:2;
-webkit-transform: scale(0.5);
transform: scale(0.5);
}

Or for a more exact approach you can call a javascript function to recalculate the transformation matrix by removing the decimal values of the matrix. see: https://stackoverflow.com/a/42256897/1834212

Solution 5 - Css

I came across this issue when using the isotope plugin (http://isotope.metafizzy.co/index.html) in combination with the zoom plugin (http://janne.aukia.com/zoomooz/). I built a jquery plugin to handle my case. I threw it up in a github repo in case anybody could benefit from it. - https://github.com/charleshimmer/jquery-hirestext.

Solution 6 - Css

I used javascript to move the text 1px top and then with 100ms after, back 1px down. It's almost unperceptive and solved the problem completely cross-browser.

Solution 7 - Css

body {
-webkit-font-smoothing: subpixel-antialiased;
}

or I think you could put that on a specific element, but I was having problems with one element affecting the whole site.

I think it is a problem with custom font-face fonts.

Solution 8 - Css

> Webkit treats 3d transformed elements as textures instead of vectors > in order to provide hardware 3d acceleration.

This has nothing to do with it. You'll notice that your aliasing problem can be fixed with the addition of duration and direction information (e.g. 0.3 linear). Your having a mare trying to render everything at runtime:

Same for the above ^

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionphilView Question on Stackoverflow
Solution 1 - CssmethodofactionView Answer on Stackoverflow
Solution 2 - CsshallodomView Answer on Stackoverflow
Solution 3 - CssmaoosiView Answer on Stackoverflow
Solution 4 - CssMiguelView Answer on Stackoverflow
Solution 5 - CsschucklesView Answer on Stackoverflow
Solution 6 - CssMixtelfView Answer on Stackoverflow
Solution 7 - CssplaceboaddictView Answer on Stackoverflow
Solution 8 - CssTomView Answer on Stackoverflow