Skip to content

Instantly share code, notes, and snippets.

@tarecord
Created July 14, 2020 20:10
Show Gist options
  • Save tarecord/40d210e8180dd58f5fcd4ad75bbfd564 to your computer and use it in GitHub Desktop.
Save tarecord/40d210e8180dd58f5fcd4ad75bbfd564 to your computer and use it in GitHub Desktop.
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