Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created July 11, 2022 21:41
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 nolanlawson/7270a4e13a805897ac6719dd337259e6 to your computer and use it in GitHub Desktop.
Save nolanlawson/7270a4e13a805897ac6719dd337259e6 to your computer and use it in GitHub Desktop.
Test @font-face in shadow DOM
<!doctype html>
<html>
<head>
<title>Test @font-face in shadow DOM</title>
</head>
<body>
<h1>Test @font-face in shadow DOM</h1>
<div></div>
<script>
document.querySelector('div')
.attachShadow({ mode: 'open' })
.innerHTML = `
<style>
@font-face {
font-family: Custom;
src:
local("Courier New"),
local("CourierNew"),
local("Courier");
}
.custom {
font-family: Custom;
}
</style>
<div class="custom">
I should be Courier
</div>
`
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment