Skip to content

Instantly share code, notes, and snippets.

@JosePedroDias
Created January 24, 2023 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosePedroDias/9891b060600ad6eb74735dbfde3199d7 to your computer and use it in GitHub Desktop.
Save JosePedroDias/9891b060600ad6eb74735dbfde3199d7 to your computer and use it in GitHub Desktop.
test stylesheet font face definitions

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment