Created
January 10, 2012 13:51
-
-
Save davidhellsing/1589183 to your computer and use it in GitHub Desktop.
Test if browser supports fractional values of letter spacing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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