-
Notifications
You must be signed in to change notification settings - Fork 0
/
fillText.html
43 lines (32 loc) · 1.11 KB
/
fillText.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head><title>fillText</title>
<style type='text/css'>
@font-face {
font-family: Scriptina;
src: url(fonts/Scriptina/Scriptina.eot?#iefix ) format('embedded-opentype'),
url(fonts/Scriptina/Scriptina.woff ) format('woff' ),
url(fonts/Scriptina/Scriptina.ttf ) format('truetype' ),
url(fonts/Scriptina/Scriptina.svg#Scriptina) format('svg');
font-weight: normal;
font-style : normal;
}
</style>
<script type="text/javascript">
function init() { try {
let canvas = document.getElementById('canvas');
let ctx = canvas.getContext('2d');
// Choose the font:
ctx.font='50px Scriptina';
ctx.fillStyle='#fe7622';
// Write the text using the font
ctx.fillText("Hello world", 80, 110);
} catch(e) {alert (e)} }
</script>
</head>
<body onload='init();'>
<canvas id ='canvas'
width='400' height='180'
style ='width:400px;height:180;border:solid 1px black;margin-left:-200px;margin-top:-90px;left:50%;position:fixed;top:50%' ></canvas>
</body>
</html>