OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charcode="utf-16"> |
| 5 <script src="../../resources/js-test.js"></script> |
| 6 <style> |
| 7 |
| 8 span { |
| 9 padding : 0px; |
| 10 font-size : 12px; |
| 11 font-family : Arial; |
| 12 display : inline; |
| 13 } |
| 14 |
| 15 </style> |
| 16 </head> |
| 17 <body> |
| 18 <div><span>a b c</span></div> |
| 19 <div><canvas></canvas></div> |
| 20 <script> |
| 21 |
| 22 var canvas = document.querySelector("canvas"); |
| 23 var context = canvas.getContext("2d"); |
| 24 var span = document.querySelector("span"); |
| 25 |
| 26 var abc = 'a' + '\u3000' + 'b' + '\u3000' + 'c'; |
| 27 context.font = "12px Arial"; |
| 28 context.fillText(abc, 0, 20); |
| 29 |
| 30 spanWidth = span.offsetWidth; |
| 31 canvasWidth = context.measureText(abc).width; |
| 32 shouldBeTrue("spanWidth == canvasWidth"); |
| 33 |
| 34 </script> |
| 35 </body> |
| 36 </html> |
OLD | NEW |