-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·107 lines (105 loc) · 3.48 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Font Tester</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel="stylesheet" type="text/css" href="test/fonts.css" media="screen" />
<link rel="stylesheet" type="text/css" href="test/fira.css" media="screen" />
<style>
@font-face {
font-family: 'Fallback';
src: url('test/UnicodeBMPFallback.ttf');
font-weight: normal;
font-style: normal;
}
body {
margin: 0;
height: 100vh;
}
main {
padding: 1rem;
height: 100%;
display: flex;
flex-direction: column;
grid-gap: 1rem;
box-sizing: border-box;
}
textarea {
width: -moz-available;
flex: 1;
font-synthesis: none;
}
.inputs {
display: flex;
grid-gap: 1rem;
}
#size {
flex: 1;
}
</style>
</head>
<body>
<main>
</object>
<div class="inputs">
<label for="size" id="size-label">32</label>
<input type="range" id="size" step="2" min="10" max="128"
oninput="changeSize(this.value)"
>
<input type="button" value="clear" id="clear"
onclick="clearArea()"
>
<input type="button" value="showcases" id="showcases"
onclick="showcases()"
>
<label for="toggle-fira" id="toggle-fira-label">firacode fallback</label>
<input type="checkbox" id="toggle-fira"
onclick="toggleFira(this.checked)"
>
<label for="toggle-liga" id="toggle-liga-label">ligated</label>
<input type="checkbox" id="toggle-liga" checked
onclick="toggleLiga(this.checked)"
>
<select name="fonts" id="fonts"
onchange="selectFont(this.value)"
>
<!--#include virtual="test/fonts.html" -->
</select>
</div>
<textarea id="area" ></textarea>
</main>
</body>
<script>
const area = document.querySelector("#area");
const select = document.querySelector("#fonts");
const size = document.querySelector("#size");
const fira = document.querySelector("#toggle-fira");
const liga = document.querySelector("#toggle-liga");
const fall = ", 'Fallback'";
const initialSize = 32;
let changeSize = (s) => {
document.querySelector("#size-label").innerHTML = s;
area.style.fontSize = `${s}px`;
};
let clearArea = () => area.value = "";
let showcases = () => area.value = `<!--#include virtual="test/showcases.txt" -->`;
let toggleFira = c => {
sizeBackup = size.value;
area.style.font = `${area.style.fontStyle} ${select.value} ${c ? ", 'FiraCode'" : ""} ${fall}`;
area.style.fontSize = `${sizeBackup}px`;
}
let toggleLiga = c => area.style.fontStyle = c ? "italic" : "normal";
let selectFont = f => {
sizeBackup = size.value;
area.style.font = `${area.style.fontStyle} ${f} ${fira.checked ? ", 'FiraCode'" : ""} ${fall}`;
area.style.fontSize = `${sizeBackup}px`;
}
area.style.font = select.value + fall;
changeSize(initialSize);
size.value = initialSize;
toggleLiga(true)
showcases();
</script>
</html>