-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont.html
68 lines (64 loc) · 1.67 KB
/
font.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>ScribbleFont Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="author" content="Isaiah Odhner">
<meta name="description" content="Scribblefonts!">
<meta name="keywords" content="handwriting, font, scribble, typography">
<style>
.glyph {
stroke: rgba(25,20,55,0.5);
stroke-width: 1px;
fill: none;
}
</style>
</head>
<body>
<div style="position: fixed; pointer-events: none; top: 30%; left: 0; right: 0; text-align: center; font-size: 50px; text-transform: uppercase; color: red; transform: rotate(15deg); opacity: 0.5; font-family: sans-serif;">This doesn't work</div>
<div id="main">
<svg id="text" width="700" height="700"></svg>
</div>
<script src="font.js"></script>
<script>
var font;
function drawText(text) {
var path = Path;
var svg = document.getElementById("text");
path.x = 40;
path.y = 40;
path.fromText(text,font);
path.scale(0.3);
path.translate(500,500);
//path.wobble(1);
path.toSVG(svg);
}
function fontLoaded() {
drawText("Hello, world!");
}
try {
font = JSON.parse(localStorage.font);
fontLoaded();
} catch(e) {
try {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.responseText) {
font = JSON.parse(xhr.responseText);
fontLoaded();
}
}
xhr.open('GET', 'font.json', true);
xhr.send();
} catch(e) {
alert(
"(Failed to load font from local storage and then)\n"
+"Failed to load font.json with error:\n"
+e
);
}
}
</script>
</body>
</html>