This is supposed to be served next to a fonts.css file defining one or more font-families, ex:
@font-face {
font-family: "American Captain";
src: url("./American-Captain.woff") format("woff");
}
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>font tester</title> | |
<style> | |
body { | |
font-size: 2em; | |
} | |
</style> | |
<link rel="stylesheet" href="fonts.css"> | |
</head> | |
<body> | |
<script> | |
const created = new Set(); | |
function step() { | |
for (let f of document.fonts.values()) { | |
//console.log(f); | |
const k = `${f.family}/${f.style}/${f.weight}`; | |
if (created.has(k)) continue; | |
const el = document.createElement('div'); | |
el.style = `font-family:${f.family}`; | |
el.appendChild(document.createTextNode(`The quick brown fox 123 (${k})`)); | |
document.body.appendChild(el); | |
created.add(k); | |
} | |
} | |
setInterval(step, 100); | |
</script> | |
</body> | |
</html> |