Created
December 7, 2014 11:40
-
-
Save mgrandrath/f9afff6adb4d64cb7fa7 to your computer and use it in GitHub Desktop.
Collect font information from all ElementNodes
This file contains hidden or 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
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