-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-jcfont.html
78 lines (74 loc) · 3.01 KB
/
test-jcfont.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
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en-au">
<head>
<link href="css/bootstrap.css" rel="stylesheet"/>
<title>JCFont Test</title>
</head>
<body>
<script src="js/bootstrap.bundle.js"></script>
<script src="js/loader.js"></script>
Example to show the creating an image in a ImageData buffer<br>
<button type="button" class="btn btn-danger" id="init-g">Initilise GLOBAL</button>
<button type="button" class="btn btn-secondary" id="font-load">Load small fixed</button>
<button type="button" class="btn btn-secondary" id="font-loads8">Load Serif 8</button>
<button type="button" class="btn btn-secondary" id="font-loads11">Load Serif 11</button>
<button type="button" class="btn btn-secondary" id="font-smfont">Load Small Font</button>
<button type="button" class="btn btn-secondary" id="font-run" hidden>Display</button>
<br>
<canvas id="myCanvas" width="640" height="640" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<div id="font-output" class="text-monospace"></div>
<script>
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
let imgData = ctx.createImageData(640, 480);
let ftest;
preloadImages(preImages);
document.addEventListener('DOMContentLoaded', function () {
let loadf = document.getElementById('font-loads8');
loadf.addEventListener("click", () => {
ftest = new CWSYSTEM.CWFont("assets/fonts/serif8.jcf");
if (ftest != null) {
document.getElementById("font-run").hidden = false;
}
});
let loadf8 = document.getElementById('font-loads11');
loadf8.addEventListener("click", () => {
ftest = new CWSYSTEM.CWFont("assets/fonts/serif11.jcf");
if (ftest != null) {
document.getElementById("font-run").hidden = false;
}
});
let loadf11 = document.getElementById('font-load');
loadf11.addEventListener("click", () => {
ftest = new CWSYSTEM.CWFont("assets/fonts/jcsmallfixed.jcf");
if (ftest != null) {
document.getElementById("font-run").hidden = false;
}
});
let loadsf = document.getElementById('font-smfont');
loadsf.addEventListener("click", () => {
ftest = new CWSYSTEM.CWFont("assets/fonts/smallfont.jcf");
if (ftest != null) {
document.getElementById("font-run").hidden = false;
}
});
let ing = false;
let ig = document.getElementById('init-g');
ig.addEventListener("click", () => {
if (!ing) {
CWSYSTEM.Global.initialize();
}
});
let processf = document.getElementById('font-run');
processf.addEventListener("click", () => {
ftest.fontTest("a b c 1 2 8")
});
ctx.putImageData(imgData, 0, 0);
let nImage = preImages.get("assets/images/dsectorTitle.jpg");
ctx.drawImage(nImage, 0, 0, 640, 480);
});
</script>
</body>
</html>