Skip to content

Instantly share code, notes, and snippets.

@davidhellsing
Created January 10, 2012 13:51
Show Gist options
  • Save davidhellsing/1589183 to your computer and use it in GitHub Desktop.
Save davidhellsing/1589183 to your computer and use it in GitHub Desktop.
Test if browser supports fractional values of letter spacing
/* Test if the browser supports decimal letterspacing for fine kerning (f.ex 0.5px)
* At the moment (january 2012), at least webkit (chrome & safari) does not render decimal pixels correctly
* https://bugs.webkit.org/show_bug.cgi?id=20606
* Using this method, you can at least provide an alternative kerning for those browsers
*/
var letterspacing = (function(d) {
var test = d.createElement('div'),
ret = true;
test.style.letterSpacing = '.5px';
d.body.appendChild(test);
if (d.defaultView && d.defaultView.getComputedStyle) {
if (d.defaultView.getComputedStyle( test, null ).letterSpacing == 'normal') {
ret = false;
}
}
d.body.removeChild(test);
test = null;
return ret;
}(window.document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment