-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.ctml
189 lines (181 loc) · 8.29 KB
/
index.ctml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>PromptFont - A Font for Button Prompts</title>
<meta name="description" content="This is a font with special glyphs to display button prompts in games and applications with special input devices.">
<meta property="og:type" content="website">
<meta property="og:title" content="PromptFont - A Font for Button Prompts">
<meta property="og:description" content="This is a font with special glyphs to display button prompts in games and applications with special input devices.">
<meta property="og:image" content="https://shinmera.github.io/promptfont/preview.png" />
<meta property="og:image:alt" content="PromptFont Preview">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<link rel="stylesheet" href="index.css">
</head>
<body>
<header>
<h1>
PromptFont
<a class="button" href="https://github.com/Shinmera/promptfont/">GitHub</a>
<a class="button" href="https://shinmera.itch.io/promptfont">Itch.io</a>
<a class="button" href="https://github.com/Shinmera/promptfont/releases/latest/download/promptfont.zip">Download</a>
</h1>
<p>This is a font designed for button prompts in games. It includes the base alphabet, as well as icons for modifier and control keys, and gamepad buttons. All the icons included in the font are custom made and available under the same <a href="LICENSE.txt">SIL Open Font Licence</a>. Included trademarks however of course still belong to their respective owners.</p>
<p>The downloadable package includes the font in TTF and OTF format, the glyphs rendered to sprite atlases, this index for easy searching, a CSS file for HTML/JS projects, a JSON file listing all of the glyphs along with convenient names and tagging, and source files for C, C++, C#, Python, Lua, Lisp, Rust, and GDScript that define the glyphs as easy to use code constants.</p>
<p>If you use this font in your project please leave an attribution notice in your credits like this:
<blockquote>PromptFont by Yukari "Shinmera" Hafner, available at https://shinmera.com/promptfont</blockquote>
</p>
</header>
<main>
<input class="compose" placeholder="Compose..." spellcheck="false">
<input class="search" type="search" placeholder="Search..." spellcheck="false" autofocus>
<c:splice iterate="sections">
<section class="glyphsection" lquery="(attr :id name)">
<h2 lquery="(text name)"></h2>
<c:splice iterate="glyphs">
<div class="glyph" title="Click to view" lquery='(data :character character :category category :tags tags :code code :codepoint codepoint :name name :code-name code-name :tags (promptfont-compiler::join tags))'>
<i lquery='(html character)'>!</i>
<code lquery='(text code)'>U+0021</code>
<span lquery="(text name)">!</span>
</div>
</c:splice>
</section>
</c:splice>
</main>
<footer>
Please consider supporting the continued development of this Font by supporting me on Patreon:
<a href="https://patreon.com/shinmera">
<img alt="Patreon" src="https://filebox.tymoon.eu//file/TWpjeU9RPT0=" />
</a>
</footer>
<div id="popup" class="hidden">
<div class="box">
<nav>
<i class="copy" title="Copy glyph" data-text="character">!</i>
<code class="copy" title="Copy unicode" data-text="code">U+0021</code>
<h2 class="copy" title="Copy name" data-text="name">Exclamation mark</h2>
<span class="compose" title="Add to compose box">Compose</span>
</nav>
<div class="preview black"><i data-text="character">!</i></div>
<div class="preview white"><i data-text="character">!</i></div>
<div class="info">
<div class="row">
<label>Category:</label>
<span data-text="category">ascii</span>
</div>
<div class="row">
<label>Name:</label>
<span data-text="name" class="copy" title="Copy name">!</span>
</div>
<div class="row">
<label>Code Name:</label>
<code data-text="codeName" class="copy" title="Copy code name">exclamation</code>
</div>
<div class="row">
<label>Glyph:</label>
<span data-text="character" class="copy" title="Copy glyph">!</span>
</div>
<div class="row">
<label>Unicode:</label>
<code data-text="code" class="copy" title="Copy unicode">U+0021</code>
</div>
<div class="row">
<label>Codepoint:</label>
<span data-text="codepoint" class="copy" title="Copy codepoint">33</span>
</div>
<div class="row">
<label>Tags:</label>
<span data-text="tags">ascii</span>
</div>
</div>
</div>
</div>
<script type="text/javascript">
let notice = null;
let clearNotice = ()=>{
if(notice){
clearTimeout(notice.timeout);
document.body.removeChild(notice.element);
notice = null;
}
}
let showNotice = (html)=>{
clearNotice();
notice = {};
notice.element = document.createElement("div");
notice.element.setAttribute("class", "notice");
notice.element.innerHTML = html;
document.body.appendChild(notice.element);
notice.timeout = setTimeout(clearNotice, 2000);
};
let copyToClipboard = (string)=>{
navigator.clipboard.writeText(string).then(
()=>showNotice("<i>"+string+"</i> copied to clipboard!"),
()=>showNotice("Failed to copy to clipboard."));
};
let match = (query, el)=>{
query = query.trim().toLowerCase();
if(query === "") return true;
let inner = el.innerText.toLowerCase();
for(let k in el.dataset){
inner += " "+k+":"+el.dataset[k].toLowerCase();
}
for(let part of query.split(/ +/)){
if(!inner.includes(part))
return false;
}
return true;
};
let compose = (glyph)=>{
document.querySelector("input.compose").value += glyph.dataset["character"];
};
let popup = document.querySelector("#popup");
popup.glyph = null;
popup.addEventListener("click", ()=>popup.classList.add("hidden"));
popup.querySelector(".box").addEventListener("click", (ev)=>ev.stopPropagation());
let hidePopup = ()=>popup.classList.add("hidden");
let showPopup = (glyph)=>{
popup.glyph = glyph;
for(let el of popup.querySelectorAll("[data-text]"))
el.innerText = glyph.dataset[el.dataset.text];
popup.classList.remove("hidden");
};
for(let el of popup.querySelectorAll(".copy")){
el.addEventListener("click", ()=>{
copyToClipboard(el.innerText);
});
}
for(let el of popup.querySelectorAll(".compose")){
el.addEventListener("click", ()=>{
compose(popup.glyph);
hidePopup();
});
}
for(let el of document.querySelectorAll(".glyph")){
el.addEventListener("click", (ev)=>{
if(ev.ctrlKey) compose(el);
else showPopup(el)
});
}
let search = document.querySelector("input[type=search]");
search.addEventListener("input", (ev)=>{
let query = search.value;
for(let glyph of document.querySelectorAll(".glyph")){
if(match(query, glyph))
glyph.classList.remove("hidden");
else
glyph.classList.add("hidden");
}
for(let section of document.querySelectorAll(".glyphsection")){
if(section.querySelector(".glyph:not(.hidden)") !== null)
section.classList.remove("hidden");
else
section.classList.add("hidden");
}
});
</script>
</body>
</html>