Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<link rel="match" href="2d.text.shape.fillGlyphRun-direction-change.tentative-expected.html">
<title>Canvas test: 2d.text.shape.fillGlyphRun-direction-change.tentative</title>
<h1>2d.text.shape.fillGlyphRun-direction-change.tentative</h1>
<p class="desc">Test that fillGlyphRun() and fillGlyphRuns() render with the direction used when the text was shaped, even if the direction set on the context has changed since.</p>
<canvas id="canvas" width="500" height="200">
<p class="fallback">FAIL (fallback content)</p>
</canvas>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext('2d');
ctx.font = '30px serif';
ctx.textAlign = 'left';
ctx.direction = 'rtl';
// Brackets next to the paragraph edges take the paragraph direction, and
// are mirrored in RTL.
const texts = ['ab (', 'א (b)', 'Test ☺️ א World'];
const shaped = texts.map((text) => ctx.shapeText(text));
ctx.direction = 'ltr';
for (let i = 0; i < shaped.length; ++i) {
const y = 40 + i * 60;
for (const cluster of shaped[i].glyphClusters()) {
ctx.fillGlyphRun(cluster, 10, y);
}
ctx.fillGlyphRuns(shaped[i].glyphRuns(), 260, y);
}
</script>