Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find a list of font families within CSS, SCSS or SASS
// var content = document.querySelector('.my-css-file');
content.match(/font-family:\s[\'|\"](.*)[\'|\"]/g).map(function(string){
var font = string.split(": ");
return font[1].slice(1, -1);
}).filter((v, i, a) => a.indexOf(v) === i)
// returns reduced array of unique font families: ['Times New Roman', 'Source Sans Pro', ... ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment