Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<link rel="author" title="Vitor Roriz" href="https://github.com/vitorroriz">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#target {
font-family: serif, sans-serif, cursive, fantasy, monospace, system-ui, emoji, math, fangsong, ui-serif, ui-sans-serif, ui-monospace, ui-rounded, 'Ahem';
}
p {
font-size: 22px;
}
#ahem {
font-family: 'Ahem';
}
.box {
display: inline-block;
}
</style>
</head>
<body>
"If a given character is a Private-Use Area Unicode codepoint, user agents must only match font families named in the font-family list that are not generic families. If none of the families named in the font-family list contain a glyph for that codepoint, user agents must display some form of missing glyph symbol for that character rather than attempting installed font fallback for that codepoint." - <a href="https://drafts.csswg.org/css-fonts-4/#char-handling-issues">css-fonts-4</a>
<h3>The first line should render as the second. This means that no generic font was used during fallback and the first non generic font was used. </h3>
<p id="target"><span class="box">&#xF000;</span><span class="box">&#xF001;</span><span class="box">&#xF002;</span></p>
<p id="ahem"><span class="box">&#xF000;</span><span class="box">&#xF001;</span><span class="box">&#xF002;</span></p>
<script>
promise_setup(_ => Promise.all([...document.fonts].map(f => f.load())));
const target = document.getElementById("target");
const ahem = document.getElementById("ahem");
for (let i = 0; i < target.children.length; i++) {
promise_test(async t => {
let targetBox = target.children[i].getBoundingClientRect();
let ahemBox = ahem.children[i].getBoundingClientRect();
assert_equals(targetBox.width, ahemBox.width);
}, `PUA character U+F00${i} is rendered with a non-generic font.`);
}
</script>
</body>
</html>