OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Canvas test: 2d.text.measure.width.space</title> | 2 <title>Canvas test: 2d.text.measure.width.space</title> |
3 <script src="../tests.js"></script> | 3 <script src="../tests.js"></script> |
4 <link rel="stylesheet" href="../tests.css"> | 4 <link rel="stylesheet" href="../tests.css"> |
5 <style> | 5 <style> |
6 @font-face { | 6 @font-face { |
7 font-family: CanvasTest; | 7 font-family: CanvasTest; |
8 src: url("../fonts/CanvasTest.ttf"); | 8 src: url("../fonts/CanvasTest.ttf"); |
9 } | 9 } |
10 </style> | 10 </style> |
11 <body> | 11 <body> |
12 <p id="passtext">Pass</p> | 12 <p id="passtext">Pass</p> |
13 <p id="failtext">Fail</p> | 13 <p id="failtext">Fail</p> |
14 <span style="font-family: CanvasTest; position: absolute; visibility: hidden">A<
/span> | 14 <span style="font-family: CanvasTest; position: absolute; visibility: hidden">A<
/span> |
15 <p class="output">These images should be identical:</p> | 15 <p class="output">These images should be identical:</p> |
16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (
fallback content)</p></canvas> | 16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (
fallback content)</p></canvas> |
17 | 17 |
18 <ul id="d"></ul> | 18 <ul id="d"></ul> |
19 <script> | 19 <script> |
20 _addTest(function(canvas, ctx) { | 20 _addTest(function(canvas, ctx) { |
21 | 21 |
22 deferTest(); | 22 deferTest(); |
23 setTimeout(wrapFunction(function () { | 23 setTimeout(wrapFunction(function () { |
24 ctx.font = '50px CanvasTest'; | 24 ctx.font = '50px CanvasTest'; |
25 _assertSame(ctx.measureText('A B').width, 150, "ctx.measureText('A B').width
", "150"); | 25 _assertSame(ctx.measureText('A B').width, 150, "ctx.measureText('A B').width
", "150"); |
26 _assertSame(ctx.measureText('A B').width, 150, "ctx.measureText('A B').wid
th", "150"); | 26 _assertSame(ctx.measureText('A B').width, 200, "ctx.measureText('A B').wid
th", "200"); |
27 _assertSame(ctx.measureText('A \x09\x0a\x0c\x0d \x09\x0a\x0c\x0dB').width,
150, "ctx.measureText('A \\x09\\x0a\\x0c\\x0d \\x09\\x0a\\x0c\\x0dB').width", "
150"); | 27 _assertSame(ctx.measureText('A \x09\x0a\x0c\x0d \x09\x0a\x0c\x0dB').width,
650, "ctx.measureText('A \\x09\\x0a\\x0c\\x0d \\x09\\x0a\\x0c\\x0dB').width", "
650"); |
28 _assert(ctx.measureText('A \x0b B').width >= 200, "ctx.measureText('A \\x0b
B').width >= 200"); | 28 _assert(ctx.measureText('A \x0b B').width >= 200, "ctx.measureText('A \\x0b
B').width >= 200"); |
29 | 29 |
30 _assertSame(ctx.measureText(' AB').width, 100, "ctx.measureText(' AB').width
", "100"); | 30 _assertSame(ctx.measureText(' AB').width, 150, "ctx.measureText(' AB').width
", "150"); |
31 _assertSame(ctx.measureText('AB ').width, 100, "ctx.measureText('AB ').width
", "100"); | 31 _assertSame(ctx.measureText('AB ').width, 150, "ctx.measureText('AB ').width
", "150"); |
32 }), 500); | 32 }), 500); |
33 | 33 |
34 | 34 |
35 }); | 35 }); |
36 </script> | 36 </script> |
37 | 37 |
OLD | NEW |