-
Notifications
You must be signed in to change notification settings - Fork 2
/
BMFont.ts
372 lines (366 loc) · 7.31 KB
/
BMFont.ts
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/**
* This interface defines BMFont.
*
* @interface BMFont
*/
interface BMFont {
/**
* The array to store `BMFontChar`.
*
* @type {string[]}
* @memberof BMFont
*/
pages: string[]
chars: BMFontChar[]
/**
* The value to store `BMFontInfo`.
*
* @type {BMFontInfo}
* @memberof BMFont
*/
info: BMFontInfo
/**
* The value to store `BMFontCommon`.
*
* @type {BMFontCommon}
* @memberof BMFont
*/
common: BMFontCommon
/**
* The value to store `BMFontDistanceField`.
*
* @type {BMFontDistanceField}
* @memberof BMFont
*/
distanceField: BMFontDistanceField
/**
* The array to store `BMFontKern`.
*
* @type {BMFontKern[]}
* @memberof BMFont
*/
kernings: BMFontKern[]
}
/**
* This interface defines BMFontChar.
*
* @interface BMFontChar
*/
interface BMFontChar {
/**
* The character id.
*
* @type {number}
* @memberof BMFontChar
*/
id: number
/**
* The character index.
*
* @type {number}
* @memberof BMFontChar
*/
index: number
/**
* The character string.
*
* @type {string}
* @memberof BMFontChar
*/
char: string
/**
* The width of the character image in the texture.
*
* @type {number}
* @memberof BMFontChar
*/
width: number
/**
* The height of the character image in the texture.
*
* @type {number}
* @memberof BMFontChar
*/
height: number
/**
* How much the current position should be offset when copying the image from the texture to the screen.
*
* @type {number}
* @memberof BMFontChar
*/
xoffset: number
/**
* How much the current position should be offset when copying the image from the texture to the screen.
*
* @type {number}
* @memberof BMFontChar
*/
yoffset: number
/**
* How much the current position should be advanced after drawing the character.
*
* @type {number}
* @memberof BMFontChar
*/
xadvance: number
/**
* The texture channel where the character image is found (1 = blue, 2 = green, 4 = red, 8 = alpha, 15 = all
* channels).
*
* @type {number}
* @memberof BMFontChar
*/
chnl: number
/**
* The left position of the character image in the texture.
*
* @type {number}
* @memberof BMFontChar
*/
x: number
/**
* The top position of the character image in the texture.
*
* @type {number}
* @memberof BMFontChar
*/
y: number
/**
* The number of texture pages included in the font.
*
* @type {number}
* @memberof BMFontChar
*/
page: number
}
/**
* This interface defines BMFontInfo.
*
* @interface BMFontInfo
*/
interface BMFontInfo {
/**
* This is the name of the true type font.
*
* @type {string}
* @memberof BMFontInfo
*/
face: string
/**
* The size of the true type font.
*
* @type {number}
* @memberof BMFontInfo
*/
size: number
/**
* The font is bold.
*
* @type {number}
* @memberof BMFontInfo
*/
bold: number
/**
* The font is italic.
*
* @type {string[]}
* @memberof BMFontInfo
*/
italic: number
/**
* The name of the OEM charset used (when not unicode).
*
* @type {string[]}
* @memberof BMFontInfo
*/
charset: string[]
/**
* Set to 1 if it is the unicode charset.
*
* @type {number}
* @memberof BMFontInfo
*/
unicode: number
/**
* The font height stretch in percentage. 100% means no stretch.
*
* @type {number}
* @memberof BMFontInfo
*/
stretchH: number
/**
* Set to 1 if smoothing was turned on.
*
* @type {number}
* @memberof BMFontInfo
*/
smooth: number
/**
* The supersampling level used. 1 means no supersampling was used.
*
* @type {number}
* @memberof BMFontInfo
*/
aa: number
/**
* The padding for each character (up, right, down, left).
*
* @type {number[]}
* @memberof BMFontInfo
*/
padding: number[]
/**
* The spacing for each character (horizontal, vertical).
*
* @type {number[]}
* @memberof BMFontInfo
*/
spacing: number[]
/**
* The fixed font height.
*
* @type {number}
* @memberof BMFontInfo
*/
fixedHeight: number
/**
* The outline thickness for the characters.
*
* @type {number}
* @memberof BMFontInfo
*/
outline: number
}
/**
* This interface defines BMFontCommon.
*
* @interface BMFontCommon
*/
interface BMFontCommon {
/**
* This is the distance in pixels between each line of text.
*
* @type {number}
* @memberof BMFontCommon
*/
lineHeight: number
/**
* The number of pixels from the absolute top of the line to the base of the characters.
*
* @type {number}
* @memberof BMFontCommon
*/
base: number
/**
* The width of the texture, normally used to scale the x pos of the character image.
*
* @type {number}
* @memberof BMFontCommon
*/
scaleW: number
/**
* The height of the texture, normally used to scale the y pos of the character image.
*
* @type {number}
* @memberof BMFontCommon
*/
scaleH: number
/**
* The number of texture pages included in the font.
*
* @type {number}
* @memberof BMFontCommon
*/
pages: number
/**
* Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case
* alphaChnl describes what is stored in each channel.
*
* @type {number}
* @memberof BMFontCommon
*/
packed: number
/**
* Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the
* outline, 3 if its set to zero, and 4 if its set to one.
*
* @type {number}
* @memberof BMFontCommon
*/
alphaChnl: number
/**
* Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the
* outline, 3 if its set to zero, and 4 if its set to one.
*
* @type {number}
* @memberof BMFontCommon
*/
redChnl: number
/**
* Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the
* outline, 3 if its set to zero, and 4 if its set to one.
*
* @type {number}
* @memberof BMFontCommon
*/
greenChnl: number
/**
* Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the
* outline, 3 if its set to zero, and 4 if its set to one.
*
* @type {number}
* @memberof BMFontCommon
*/
blueChnl: number
}
/**
* This interface defines BMFontDistanceField.
*
* @interface BMFontDistanceField
*/
interface BMFontDistanceField {
/**
* Unused value.
*
* @type {string}
* @memberof BMFontDistanceField
*/
fieldType: string
/**
* Unused value.
*
* @type {number}
* @memberof BMFontDistanceField
*/
distanceRange: number
}
/**
* This interface defines BMFontKern.
*
* @interface BMFontKern
*/
interface BMFontKern {
/**
* The first character id.
*
* @type {number}
* @memberof BMFontKern
*/
first: number
/**
* The second character id.
*
* @type {number}
* @memberof BMFontKern
*/
second: number
/**
* How much the x position should be adjusted when drawing the second character immediately following the
* first.
*
* @type {number}
* @memberof BMFontKern
*/
amount: number
}
export { BMFont, BMFontChar, BMFontCommon, BMFontDistanceField, BMFontInfo, BMFontKern }