| <!DOCTYPE html> |
| <html> |
| <head> |
| <style> |
| @font-face { |
| font-family: "WebFont"; |
| src: url("resources/Ahem-sbix.ttf") format("truetype"); |
| } |
| </style> |
| </head> |
| <body> |
| <div>This test makes sure that sbix fonts are drawn in the right place in canvas. |
| The test passes if this text you're reading right now is the only thing on the page.</div> |
| <canvas id="canvas" width="775" height="525" style="width: 775px; height: 525px;"></canvas> |
| <script> |
| let font = "200px 'WebFont'"; |
| document.fonts.load(font).then(function() { |
| let canvas = document.getElementById("canvas"); |
| let context = canvas.getContext("2d"); |
| context.font = font; |
| context.fillText("A\u7EB5B", 200, 200); |
| context.fillStyle = "white"; |
| context.fillRect(200, 200 - 160, 152, 160); |
| context.fillRect(440, 200 - 160, 40, 200); |
| context.fillRect(600, 200 - 152, 160, 152); |
| }); |
| </script> |
| </body> |
| </html> |