Files
sousa-gecko/testing/web-platform/tests/css/css-font-loading/fontface-from-arraybuffer.html
T
Simon Wülker e703364dae Bug 2023436 [wpt PR 58504] - script: Support constructing FontFaces from ArrayBuffers, a=testonly
Automatic update from web-platform-tests
Add web platform tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

--

wpt-commits: 2bc44bce1de2819331d77d2f5993d6dc22b77e14
wpt-pr: 58504
2026-03-23 08:18:55 +00:00

34 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>Constructing a FontFace from an ArrayBuffer should be equivalent to loading the same data from an URL</title>
<link rel="help" href="https://drafts.csswg.org/css-font-loading/#font-face-constructor">
<link rel="author" title="Simon Wülker" href="simon.wuelker@arcor.de">
<link rel=match href=fontface-from-arraybuffer-ref.html>
<link rel="help" href="https://github.com/servo/servo/issues/39657">
<script src="/common/reftest-wait.js"></script>
</head>
<body>
<canvas id="canvas" width="500px" height="500px"></canvas>
<script>
fetch("/fonts/Ahem.ttf")
.then(res => res.arrayBuffer())
.then(arrayBuffer => {
const ahem_font = new FontFace(
"FontFamily AhemTest",
arrayBuffer,
);
document.fonts.add(ahem_font);
ahem_font.load().then(
() => {
const ctx = canvas.getContext("2d");
ctx.font = '36px "FontFamily AhemTest"';
ctx.fillText("Ahem font loaded", 20, 50);
takeScreenshot();
}
);
});
</script>
</body>
</html>