Created
March 9, 2020 21:47
-
-
Save tomhodgins/7a6ec32b7a47d161812b3c0f7f1a819c to your computer and use it in GitHub Desktop.
run this in your browser's console to display all font-family properties used on the site styled in that font-family
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
{ | |
const fonts = new Set() | |
document.querySelectorAll('*').forEach(tag => fonts.add(getComputedStyle(tag).fontFamily)) | |
console.log(fonts) | |
document.body.insertAdjacentHTML('beforeEnd', ` | |
<font-demo> | |
<style> | |
font-demo { | |
display: block; | |
font-size: 10pt; | |
padding: 4em; | |
background: white; | |
} | |
font-demo h1 { | |
display: block; | |
font-size: 24pt; | |
margin: 1em auto; | |
line-height: 1.2; | |
color: black; | |
} | |
${ | |
Array.from(fonts).map((font, index) => ` | |
font-demo h1:nth-of-type(${index + 1}) { | |
font-family: ${font} !important; | |
font-weight: bolder; | |
} | |
`).join('\n') | |
} | |
</style> | |
${Array.from(fonts).map(font => | |
`<h1>${font}</h1>` | |
).join('\n')} | |
</font-demo> | |
`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment