-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
221 lines (211 loc) · 9.54 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Font To Bitmap Converter</title>
<meta name="description" content="Tool for converting fonts into bitmap fonts"/>
<meta name="keywords" content="bitmap, bitmap font, font to bitmap, ttf bitmap, woff bitmap"/>
<script defer type="module" src="/src/main.js"></script>
<style>
body {
background: #1D3557 !important;
font-size: 13px;
overflow: hidden;
-webkit-font-smoothing: antialiased;
}
#preview {
border: 5px solid #222C42;
color: #fff;
border-radius: 10px;
padding: 15px;
-webkit-font-smoothing: none;
}
input[type=number], input[type=text] {
max-height: 60px !important;
}
body.downloading {
background: transparent;
}
body.downloading #preview {
border: 0 !important;
padding: 0 !important;
}
[x-cloak] {
display: none !important;
}
</style>
<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body draggable="false" style="user-select: none;" x-data="converter">
<div x-html="css"></div>
<div class="container bg-grey mt-3" x-cloak>
<div class="row">
<div class="col" style="color: #fff; margin-bottom: 3px; font-size: 13px;">
<b>Upload:</b>
<div class="form-check form-check-inline ms-1">
<input x-model="inputType" class="form-check-input" type="radio" name="inputType_fontUrl" id="inputType_fontUrl" value="fontUrl" checked>
<label class="form-check-label" for="inputType_fontUrl">
From URL
</label>
</div>
<div class="form-check form-check-inline">
<input x-model="inputType" class="form-check-input" type="radio" name="inputType_file" id="inputType_file" value="file">
<label class="form-check-label" for="inputType_file">
From File
</label>
</div>
</div>
</div>
<div x-show="inputType==='file'" class="row">
<div class="col">
<div class="mb-3">
<input class="form-control" x-on:change="onFile($event)" type="file" id="file">
</div>
</div>
</div>
<div x-show="inputType==='fontUrl'" class="row">
<div class="col">
<div class="form-floating mb-3">
<input type="text" x-model.debounce.100ms="fontUrl" list="fontsList"
onclick="this.focus();this.select()"
class="form-control form-control-sm border-0" id="font">
<label for="font">Font URL</label>
</div>
<datalist id="fontsList">
<template x-for="font in fontsList">
<option x-text="`${font.name}`" :value="font.url"></option>
</template>
</datalist>
</div>
<div class="col" x-show="uniqueFonts().length > 1">
<div class="form-floating">
<select class="form-select" id="floatingSelect" x-model="fontIndex">
<template x-for="(f, index) in uniqueFonts">
<option x-text="`${f.name} [${f.style}] [${f.weight}]`" :value="index"
style="text-transform: capitalize;"></option>
</template>
</select>
<label for="floatingSelect">Font variant</label>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-floating mb-3">
<input type="number" x-model="perRow" class="form-control form-control-sm border-0" id="perRow">
<label for="perRow">Per row</label>
</div>
</div>
<div class="col">
<div class="form-floating mb-3">
<input type="number" x-model="gridWidth" class="form-control form-control-sm border-0" id="gridWidth">
<label for="gridWidth">Grid width</label>
</div>
</div>
<div class="col">
<div class="form-floating mb-3">
<input type="number" x-model="gridHeight" class="form-control form-control-sm border-0" id="gridHeight">
<label for="gridHeight">Grid height</label>
</div>
</div>
<div class="col">
<div class="form-floating mb-3">
<input type="number" x-model="fontSize" class="form-control form-control-sm border-0" id="fontSize">
<label for="fontSize">Font size</label>
</div>
</div>
</div>
<div class="form-floating mb-3">
<textarea x-model="characters" class="form-control form-control-sm border-0" id="characters"
style="height: 71px;"></textarea>
<label for="characters">Characters</label>
</div>
<div class="card p-2 px-3 border-0">
<div class="">
<div class="float-start">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.shadow" type="checkbox" role="switch"
id="shadow">
<label class="form-check-label" for="shadow">Shadow</label>
</div>
</div>
<div class="float-start ms-3">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.antialiasing" type="checkbox" role="switch"
id="antialiasing">
<label class="form-check-label" for="antialiasing">Antialiasing</label>
</div>
</div>
<div class="float-start ms-3" x-show="options.antialiasing">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.subpixel" type="checkbox" role="switch"
id="subpixel">
<label class="form-check-label" for="subpixel">Subpixel AA</label>
</div>
</div>
<div class="float-start ms-3">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.italic" type="checkbox" role="switch"
id="italic">
<label class="form-check-label" for="italic">Italic</label>
</div>
</div>
<div class="float-start ms-3">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.centered" type="checkbox" role="switch"
id="centered">
<label class="form-check-label" for="centered">Centered</label>
</div>
</div>
<div class="float-start ms-3">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.showGrid" type="checkbox" role="switch"
id="showGrid">
<label class="form-check-label" for="showGrid">Show grid</label>
</div>
</div>
<div class="float-start ms-3">
<div class="form-check form-switch form-control-sm">
<input class="form-check-input" x-model="options.removeDuplicates" type="checkbox" role="switch"
id="removeDuplicates">
<label class="form-check-label" for="removeDuplicates">Remove duplicates</label>
</div>
</div>
</div>
</div>
<div class="text-center mt-3">
<button class="btn btn-success" style="font-weight: 800;" @click="download()">DOWNLOAD BITMAP FONT</button>
<div class="dropdown" style="display: inline-block;" >
<button class="btn btn-success dropdown-toggle" style="height: 38px;" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
Export
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item" @click="exportCode('construct')">Construct 3</a></li>
<li><a class="dropdown-item" @click="exportCode('kaboom')">KaboomJS</a></li>
</ul>
</div>
</div>
<div style="margin-top: 15px; display: flex; justify-content: center;">
<div x-show="loading" class="text-white">
<div class="spinner-border text-light" role="status">
<span class="sr-only"></span>
</div>
</div>
<div x-show="!loading">
<template x-if="font() && !error">
<div x-html="html"
:style="`font-family: '${font()?.name}'; font-weight: ${font()?.weight}; font-style: ${font()?.style};`"></div>
</template>
<template x-if="error">
<div class="alert alert-danger mb-0">
Failed to fetch a font from provided URL.
</div>
</template>
</div>
</div>
</div>
<script src="//cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script defer src="/google-fonts.js"></script>
</body>
</html>