Skip to content

Instantly share code, notes, and snippets.

@mgrandrath
Created December 7, 2014 11:40
Show Gist options
  • Save mgrandrath/f9afff6adb4d64cb7fa7 to your computer and use it in GitHub Desktop.
Save mgrandrath/f9afff6adb4d64cb7fa7 to your computer and use it in GitHub Desktop.
Collect font information from all ElementNodes
function walk(f, node) {
f(node);
node = node.firstChild;
while (node) {
walk(f, node);
node = node.nextSibling;
}
}
function parseNode(node) {
if (node.nodeType !== Node.ELEMENT_NODE) { return }
var style = window.getComputedStyle(node);
var fontFamily = style.getPropertyValue("font-family");
var fontWeight = style.getPropertyValue("font-weight");
console.log(node.tagName, fontFamily, fontWeight);
}
walk(parseNode, document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment