Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/text/canvas.2d.fontStretch.condensed.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Canvas test: 2d.text.fontStretch</title>
<link rel="match" href="canvas.2d.fontStretch-ref.html">
<canvas id="c" class="output"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
var canvas = document.getElementById("c");
var ctx = canvas.getContext('2d');
// P shows as Pass for fontStretch = condensed and shows as fail for
// fontStretch = fail.
function draw() {
ctx.font = '25px test';
ctx.fontStretch = "condensed";
ctx.fillText("P", 10, 40);
}
var f = new FontFace('test', 'url(/fonts/pass.woff)');
f.stretch = "condensed";
document.fonts.add(f);
var f2 = new FontFace('test', 'url(/fonts/fail.woff)');
document.fonts.add(f2);
Promise.all([f.load(), f2.load()]).then(draw);
</script>