-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch 5 - Add testcases for emHeights and fontBoundingBox where the f…
…ont's typographic ascent+descent does not equal the em size. Depends on D184608 Differential Revision: https://phabricator.services.mozilla.com/D184609 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1841692 gecko-commit: 90b19e0d07e5d2cd137f135b860f0357df90e338 gecko-reviewers: gfx-reviewers, lsalzman
- Loading branch information
1 parent
bb87427
commit 29bc632
Showing
18 changed files
with
516 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
45 changes: 45 additions & 0 deletions
45
html/canvas/element/text/2d.text.measure.emHeights-low-ascent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.text.measure.emHeights-low-ascent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> | ||
<style> | ||
@font-face { | ||
font-family: CanvasTest-ascent256; | ||
src: url("/fonts/CanvasTest-ascent256.ttf"); | ||
} | ||
</style> | ||
<body class="show_output"> | ||
|
||
<h1>2d.text.measure.emHeights-low-ascent</h1> | ||
<p class="desc">Testing emHeights with reduced ascent metric</p> | ||
|
||
|
||
<span style="font-family: CanvasTest-ascent256; position: absolute; visibility: hidden">A</span> | ||
<p class="output">Actual output:</p> | ||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = document.getElementById('c'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 20, "ctx.measureText('A').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 20, "ctx.measureText('A').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 20, "ctx.measureText('ABCD').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 20, "ctx.measureText('ABCD').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
|
||
}, "Testing emHeights with reduced ascent metric"); | ||
</script> | ||
|
45 changes: 45 additions & 0 deletions
45
html/canvas/element/text/2d.text.measure.emHeights-zero-descent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.text.measure.emHeights-zero-descent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> | ||
<style> | ||
@font-face { | ||
font-family: CanvasTest-descent0; | ||
src: url("/fonts/CanvasTest-descent0.ttf"); | ||
} | ||
</style> | ||
<body class="show_output"> | ||
|
||
<h1>2d.text.measure.emHeights-zero-descent</h1> | ||
<p class="desc">Testing emHeights with zero descent metric</p> | ||
|
||
|
||
<span style="font-family: CanvasTest-descent0; position: absolute; visibility: hidden">A</span> | ||
<p class="output">Actual output:</p> | ||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = document.getElementById('c'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-descent0'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 0, "ctx.measureText('A').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 0, "ctx.measureText('ABCD').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
|
||
}, "Testing emHeights with zero descent metric"); | ||
</script> | ||
|
43 changes: 43 additions & 0 deletions
43
html/canvas/element/text/2d.text.measure.fontBoundingBox-reduced-ascent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.text.measure.fontBoundingBox-reduced-ascent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> | ||
<style> | ||
@font-face { | ||
font-family: CanvasTest-ascent256; | ||
src: url("/fonts/CanvasTest-ascent256.ttf"); | ||
} | ||
</style> | ||
<body class="show_output"> | ||
|
||
<h1>2d.text.measure.fontBoundingBox-reduced-ascent</h1> | ||
<p class="desc">Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric</p> | ||
|
||
|
||
<span style="font-family: CanvasTest-ascent256; position: absolute; visibility: hidden">A</span> | ||
<p class="output">Actual output:</p> | ||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = document.getElementById('c'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').fontBoundingBoxAscent, 10, "ctx.measureText('A').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10"); | ||
|
||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 10, "ctx.measureText('ABCD').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10"); | ||
|
||
}, "Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric"); | ||
</script> | ||
|
43 changes: 43 additions & 0 deletions
43
html/canvas/element/text/2d.text.measure.fontBoundingBox-zero-descent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>Canvas test: 2d.text.measure.fontBoundingBox-zero-descent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> | ||
<style> | ||
@font-face { | ||
font-family: CanvasTest-descent0; | ||
src: url("/fonts/CanvasTest-descent0.ttf"); | ||
} | ||
</style> | ||
<body class="show_output"> | ||
|
||
<h1>2d.text.measure.fontBoundingBox-zero-descent</h1> | ||
<p class="desc">Testing fontBoundingBox for OffscreenCanvas with zero descent metric</p> | ||
|
||
|
||
<span style="font-family: CanvasTest-descent0; position: absolute; visibility: hidden">A</span> | ||
<p class="output">Actual output:</p> | ||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = document.getElementById('c'); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-descent0'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').fontBoundingBoxAscent, 30, "ctx.measureText('A').fontBoundingBoxAscent", "30"); | ||
_assertSame(ctx.measureText('A').fontBoundingBoxDescent, 0, "ctx.measureText('A').fontBoundingBoxDescent", "0"); | ||
|
||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 30, "ctx.measureText('ABCD').fontBoundingBoxAscent", "30"); | ||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 0, "ctx.measureText('ABCD').fontBoundingBoxDescent", "0"); | ||
|
||
}, "Testing fontBoundingBox for OffscreenCanvas with zero descent metric"); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>OffscreenCanvas test: 2d.text.measure.emHeights-low-ascent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
|
||
<h1>2d.text.measure.emHeights-low-ascent</h1> | ||
<p class="desc">Testing emHeights with reduced ascent metric</p> | ||
|
||
|
||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-ascent256", "url('/fonts/CanvasTest-ascent256.ttf')"); | ||
f.load(); | ||
document.fonts.add(f); | ||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 20, "ctx.measureText('A').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 20, "ctx.measureText('A').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 20, "ctx.measureText('ABCD').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 20, "ctx.measureText('ABCD').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
|
||
}, "Testing emHeights with reduced ascent metric"); | ||
</script> |
30 changes: 30 additions & 0 deletions
30
html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. | ||
// OffscreenCanvas test in a worker:2d.text.measure.emHeights-low-ascent | ||
// Description:Testing emHeights with reduced ascent metric | ||
// Note: | ||
|
||
importScripts("/resources/testharness.js"); | ||
importScripts("/html/canvas/resources/canvas-tests.js"); | ||
|
||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-ascent256", "url('/fonts/CanvasTest-ascent256.ttf')"); | ||
f.load(); | ||
self.fonts.add(f); | ||
await self.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 20, "ctx.measureText('A').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 20, "ctx.measureText('A').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 20, "ctx.measureText('ABCD').emHeightAscent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 20, "ctx.measureText('ABCD').emHeightDescent", "20"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
t.done(); | ||
}, "Testing emHeights with reduced ascent metric"); | ||
done(); |
34 changes: 34 additions & 0 deletions
34
html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>OffscreenCanvas test: 2d.text.measure.emHeights-zero-descent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
|
||
<h1>2d.text.measure.emHeights-zero-descent</h1> | ||
<p class="desc">Testing emHeights with zero descent metric</p> | ||
|
||
|
||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-descent0", "url('/fonts/CanvasTest-descent0.ttf')"); | ||
f.load(); | ||
document.fonts.add(f); | ||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-descent0'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 0, "ctx.measureText('A').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 0, "ctx.measureText('ABCD').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
|
||
}, "Testing emHeights with zero descent metric"); | ||
</script> |
30 changes: 30 additions & 0 deletions
30
html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. | ||
// OffscreenCanvas test in a worker:2d.text.measure.emHeights-zero-descent | ||
// Description:Testing emHeights with zero descent metric | ||
// Note: | ||
|
||
importScripts("/resources/testharness.js"); | ||
importScripts("/html/canvas/resources/canvas-tests.js"); | ||
|
||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-descent0", "url('/fonts/CanvasTest-descent0.ttf')"); | ||
f.load(); | ||
self.fonts.add(f); | ||
await self.fonts.ready; | ||
ctx.font = '40px CanvasTest-descent0'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('A').emHeightDescent, 0, "ctx.measureText('A').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40"); | ||
|
||
_assertSame(ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightAscent", "40"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent, 0, "ctx.measureText('ABCD').emHeightDescent", "0"); | ||
_assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40"); | ||
t.done(); | ||
}, "Testing emHeights with zero descent metric"); | ||
done(); |
32 changes: 32 additions & 0 deletions
32
html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<title>OffscreenCanvas test: 2d.text.measure.fontBoundingBox-reduced-ascent</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/html/canvas/resources/canvas-tests.js"></script> | ||
|
||
<h1>2d.text.measure.fontBoundingBox-reduced-ascent</h1> | ||
<p class="desc">Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric</p> | ||
|
||
|
||
<script> | ||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-ascent256", "url('/fonts/CanvasTest-ascent256.ttf')"); | ||
f.load(); | ||
document.fonts.add(f); | ||
await document.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').fontBoundingBoxAscent, 10, "ctx.measureText('A').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10"); | ||
|
||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 10, "ctx.measureText('ABCD').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10"); | ||
|
||
}, "Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric"); | ||
</script> |
28 changes: 28 additions & 0 deletions
28
html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. | ||
// OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox-reduced-ascent | ||
// Description:Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric | ||
// Note: | ||
|
||
importScripts("/resources/testharness.js"); | ||
importScripts("/html/canvas/resources/canvas-tests.js"); | ||
|
||
promise_test(async t => { | ||
|
||
var canvas = new OffscreenCanvas(100, 50); | ||
var ctx = canvas.getContext('2d'); | ||
|
||
var f = new FontFace("CanvasTest-ascent256", "url('/fonts/CanvasTest-ascent256.ttf')"); | ||
f.load(); | ||
self.fonts.add(f); | ||
await self.fonts.ready; | ||
ctx.font = '40px CanvasTest-ascent256'; | ||
ctx.direction = 'ltr'; | ||
ctx.align = 'left' | ||
_assertSame(ctx.measureText('A').fontBoundingBoxAscent, 10, "ctx.measureText('A').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10"); | ||
|
||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 10, "ctx.measureText('ABCD').fontBoundingBoxAscent", "10"); | ||
_assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10"); | ||
t.done(); | ||
}, "Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric"); | ||
done(); |
Oops, something went wrong.