Skip to content

Instantly share code, notes, and snippets.

View bramstein's full-sized avatar

Bram Stein bramstein

View GitHub Profile
var wordSpacing = [2.333, -0.333, 1, 0.7, -0.25, 0.083].map(function (v) {
return [v, 15 + Math.round(Math.random() * 4)];
});
function truncate(x) {
if (x > 0 && x < 0.1) {
return 0;
}
if (x < 0 && x > -0.1) {
return 0;
@bramstein
bramstein / subpixel-word-spacing-detect.js
Last active September 5, 2015 07:34
Detect sub-pixel word- and letter-spacing.
var subpixelWordSpacing = false;
if (document.defaultView && document.defaultView.getComputedStyle) {
// Store the original word spacing on the document element
var originalWordSpacing = document.defaultView.getComputedStyle(document.documentElement, null).wordSpacing;
// Set the word-spacing to half a pixel
document.documentElement.style.wordSpacing = '0.5px';
// This will return either 0px or 1px if sub-pixel word-spacing is not supported, otherwise