Created
May 21, 2022 07:56
-
-
Save snehalbaghel/26f76d3ba12e897250d372bd1ff27c5e to your computer and use it in GitHub Desktop.
List al available fonts in a document
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
// Credits: https://stackoverflow.com/a/62399430/4988995 | |
function listFonts() { | |
let { fonts } = document; | |
const it = fonts.entries(); | |
let arr = []; | |
let done = false; | |
while (!done) { | |
const font = it.next(); | |
if (!font.done) { | |
arr.push(font.value[0]); | |
} else { | |
done = font.done; | |
} | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment