Skip to content

Instantly share code, notes, and snippets.

View eykd's full-sized avatar

David Eyk eykd

View GitHub Profile
@eykd
eykd / beautiful_line_length.js
Created September 27, 2010 20:54 — forked from blaine/gist:428898
Sets the size of the body text to whatever works best for the current device. Based on code from http://blog.romeda.org/2010/06/beautiful-lines.html
var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = document.createElement('p');
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var sizer = contentElement.cloneNode();
sizer.style.cssText = 'margin: 0; padding: 0; color: transparent; background-color: transparent; position: absolute;';