Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Last active February 19, 2016 16:09
Show Gist options
  • Save glenjamin/0a2e43cc0f880b2c56ca to your computer and use it in GitHub Desktop.
Save glenjamin/0a2e43cc0f880b2c56ca to your computer and use it in GitHub Desktop.
Get Font Styles
var getComputedStyle = require('computed-style');
var fontStyles = ['font-family', 'font-size', 'font-weight', 'font-style'];
module.exports = function getFontStyles(domElement) {
return {
element: domElement,
styles: extractFontStyles(domElement)
}
}
function extractFontStyles(domElement) {
var styles = {};
fontStyles.forEach(function(style) {
styles[style] = getComputedStyle(element, style);
});
return styles;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment