-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bqio
committed
Apr 13, 2022
0 parents
commit 3c8a2cb
Showing
5 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/env | ||
*.spritefont | ||
/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from dxtkfont import Dxtkfont | ||
from prettytable import PrettyTable | ||
from os import path | ||
from sys import argv, exit | ||
|
||
if len(argv) < 2 or len(argv) > 2: | ||
print("Use: dump.py <spritefont_file>") | ||
exit() | ||
|
||
try: | ||
f = Dxtkfont.from_file(argv[1]) | ||
t = PrettyTable(['Char', 'Hex', 'Left', 'Top', 'Right', 'Bottom', 'X Offset', 'Y Offset', 'X Advance']) | ||
for glyph in f.glyphs: | ||
t.add_row([chr(glyph.char), hex(glyph.char), glyph.left, glyph.top, glyph.right, glyph.bottom, glyph.x_offset, glyph.y_offset, glyph.x_advance]) | ||
|
||
with open('{}.txt'.format(path.basename(argv[1]).split(".")[0]), "w", encoding="utf-8") as f: | ||
f.write(t.get_string()) | ||
print("Done") | ||
except: | ||
print("Invalid spritefont") | ||
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | ||
|
||
from pkg_resources import parse_version | ||
import kaitaistruct | ||
from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO | ||
|
||
|
||
if parse_version(kaitaistruct.__version__) < parse_version('0.9'): | ||
raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) | ||
|
||
class Dxtkfont(KaitaiStruct): | ||
def __init__(self, _io, _parent=None, _root=None): | ||
self._io = _io | ||
self._parent = _parent | ||
self._root = _root if _root else self | ||
self._read() | ||
|
||
def _read(self): | ||
self.magic = (self._io.read_bytes(8)).decode(u"utf8") | ||
self.glyphs_count = self._io.read_u4le() | ||
self.glyphs = [None] * (self.glyphs_count) | ||
for i in range(self.glyphs_count): | ||
self.glyphs[i] = Dxtkfont.Glyph(self._io, self, self._root) | ||
|
||
self.line_spacing = self._io.read_f4le() | ||
|
||
class Glyph(KaitaiStruct): | ||
def __init__(self, _io, _parent=None, _root=None): | ||
self._io = _io | ||
self._parent = _parent | ||
self._root = _root if _root else self | ||
self._read() | ||
|
||
def _read(self): | ||
self.char = self._io.read_u4le() | ||
self.left = self._io.read_u4le() | ||
self.top = self._io.read_u4le() | ||
self.right = self._io.read_u4le() | ||
self.bottom = self._io.read_u4le() | ||
self.x_offset = self._io.read_f4le() | ||
self.y_offset = self._io.read_f4le() | ||
self.x_advance = self._io.read_f4le() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
+------+------+------+-----+-------+--------+----------+----------+-----------+ | ||
| Char | Hex | Left | Top | Right | Bottom | X Offset | Y Offset | X Advance | | ||
+------+------+------+-----+-------+--------+----------+----------+-----------+ | ||
| | 0x20 | 507 | 1 | 508 | 2 | 63.0 | 188.0 | -38.0 | | ||
| ! | 0x21 | 482 | 1 | 493 | 71 | 18.0 | 21.0 | -12.0 | | ||
| " | 0x22 | 354 | 181 | 376 | 201 | 16.0 | 22.0 | -14.0 | | ||
| # | 0x23 | 415 | 368 | 472 | 434 | 15.0 | 24.0 | -16.0 | | ||
| $ | 0x24 | 238 | 1 | 279 | 83 | 16.0 | 14.0 | -14.0 | | ||
| % | 0x25 | 418 | 1 | 480 | 76 | 15.0 | 17.0 | -16.0 | | ||
| & | 0x26 | 315 | 369 | 366 | 433 | 16.0 | 26.0 | -15.0 | | ||
| ' | 0x27 | 484 | 155 | 493 | 175 | 16.0 | 22.0 | -13.0 | | ||
| ( | 0x28 | 314 | 1 | 328 | 81 | 18.0 | 20.0 | -14.0 | | ||
| ) | 0x29 | 330 | 1 | 344 | 81 | 16.0 | 20.0 | -12.0 | | ||
| * | 0x2a | 36 | 478 | 70 | 511 | 15.0 | 18.0 | -16.0 | | ||
| + | 0x2b | 458 | 436 | 500 | 480 | 15.0 | 38.0 | -16.0 | | ||
| , | 0x2c | 354 | 156 | 367 | 179 | 16.0 | 78.0 | -14.0 | | ||
| - | 0x2d | 174 | 478 | 211 | 487 | 16.0 | 56.0 | -14.0 | | ||
| . | 0x2e | 222 | 146 | 232 | 158 | 16.0 | 78.0 | -13.0 | | ||
| / | 0x2f | 1 | 1 | 43 | 88 | 15.0 | 12.0 | -15.0 | | ||
| 0 | 0x30 | 45 | 88 | 86 | 160 | 18.0 | 21.0 | -12.0 | | ||
| 1 | 0x31 | 383 | 79 | 416 | 149 | 15.0 | 20.0 | -15.0 | | ||
| 2 | 0x32 | 340 | 299 | 377 | 367 | 15.0 | 22.0 | -15.0 | | ||
| 3 | 0x33 | 137 | 161 | 171 | 231 | 15.0 | 21.0 | -11.0 | | ||
| 4 | 0x34 | 447 | 228 | 486 | 297 | 15.0 | 23.0 | -14.0 | | ||
| 5 | 0x35 | 200 | 234 | 238 | 302 | 15.0 | 24.0 | -13.0 | | ||
| 6 | 0x36 | 126 | 233 | 161 | 302 | 18.0 | 23.0 | -11.0 | | ||
| 7 | 0x37 | 259 | 162 | 297 | 232 | 14.0 | 21.0 | -16.0 | | ||
| 8 | 0x38 | 1 | 90 | 41 | 161 | 18.0 | 20.0 | -12.0 | | ||
| 9 | 0x39 | 163 | 233 | 198 | 302 | 17.0 | 23.0 | -11.0 | | ||
| : | 0x3a | 496 | 132 | 506 | 179 | 16.0 | 43.0 | -13.0 | | ||
| ; | 0x3b | 222 | 86 | 235 | 144 | 16.0 | 43.0 | -14.0 | | ||
| < | 0x3c | 210 | 372 | 266 | 424 | 15.0 | 38.0 | -16.0 | | ||
| = | 0x3d | 252 | 476 | 305 | 509 | 16.0 | 41.0 | -14.0 | | ||
| > | 0x3e | 1 | 373 | 57 | 425 | 15.0 | 38.0 | -16.0 | | ||
| ? | 0x3f | 173 | 304 | 208 | 371 | 15.0 | 23.0 | -15.0 | | ||
| @ | 0x40 | 346 | 1 | 416 | 77 | 16.0 | 18.0 | -13.0 | | ||
| A | 0x41 | 354 | 228 | 403 | 297 | 15.0 | 23.0 | -15.0 | | ||
| B | 0x42 | 175 | 160 | 214 | 231 | 18.0 | 19.0 | -12.0 | | ||
| C | 0x43 | 436 | 155 | 482 | 226 | 18.0 | 23.0 | -15.0 | | ||
| D | 0x44 | 280 | 300 | 324 | 367 | 18.0 | 23.0 | -12.0 | | ||
| E | 0x45 | 240 | 234 | 278 | 302 | 18.0 | 23.0 | -13.0 | | ||
| F | 0x46 | 133 | 304 | 171 | 371 | 18.0 | 23.0 | -14.0 | | ||
| G | 0x47 | 88 | 161 | 135 | 231 | 18.0 | 23.0 | -12.0 | | ||
| H | 0x48 | 87 | 233 | 124 | 302 | 18.0 | 23.0 | -11.0 | | ||
| I | 0x49 | 1 | 235 | 29 | 301 | 16.0 | 24.0 | -13.0 | | ||
| J | 0x4a | 1 | 163 | 33 | 233 | 15.0 | 23.0 | -12.0 | | ||
| K | 0x4b | 299 | 229 | 338 | 298 | 18.0 | 22.0 | -15.0 | | ||
| L | 0x4c | 46 | 304 | 88 | 371 | 18.0 | 24.0 | -16.0 | | ||
| M | 0x4d | 415 | 299 | 482 | 366 | 15.0 | 24.0 | -15.0 | | ||
| N | 0x4e | 35 | 234 | 80 | 302 | 18.0 | 24.0 | -12.0 | | ||
| O | 0x4f | 43 | 162 | 85 | 232 | 18.0 | 21.0 | -11.0 | | ||
| P | 0x50 | 216 | 162 | 257 | 232 | 18.0 | 23.0 | -11.0 | | ||
| Q | 0x51 | 94 | 1 | 137 | 85 | 18.0 | 21.0 | -12.0 | | ||
| R | 0x52 | 175 | 86 | 220 | 158 | 18.0 | 23.0 | -15.0 | | ||
| S | 0x53 | 312 | 156 | 352 | 227 | 16.0 | 19.0 | -14.0 | | ||
| T | 0x54 | 405 | 228 | 445 | 297 | 15.0 | 22.0 | -15.0 | | ||
| U | 0x55 | 94 | 87 | 137 | 159 | 18.0 | 21.0 | -12.0 | | ||
| V | 0x56 | 274 | 369 | 313 | 435 | 15.0 | 24.0 | -15.0 | | ||
| W | 0x57 | 210 | 304 | 272 | 370 | 15.0 | 24.0 | -15.0 | | ||
| X | 0x58 | 383 | 155 | 434 | 226 | 15.0 | 21.0 | -15.0 | | ||
| Y | 0x59 | 1 | 304 | 44 | 371 | 13.0 | 23.0 | -18.0 | | ||
| Z | 0x5a | 90 | 304 | 131 | 371 | 15.0 | 23.0 | -16.0 | | ||
| [ | 0x5b | 139 | 1 | 162 | 84 | 18.0 | 15.0 | -16.0 | | ||
| \ | 0x5c | 45 | 1 | 92 | 86 | 15.0 | 14.0 | -15.0 | | ||
| ] | 0x5d | 214 | 1 | 236 | 84 | 15.0 | 15.0 | -12.0 | | ||
| ^ | 0x5e | 252 | 437 | 294 | 474 | 15.0 | 23.0 | -16.0 | | ||
| _ | 0x5f | 120 | 478 | 172 | 487 | 15.0 | 81.0 | -16.0 | | ||
| ` | 0x60 | 484 | 181 | 500 | 198 | 29.0 | 19.0 | 0.0 | | ||
| a | 0x61 | 96 | 373 | 129 | 425 | 16.0 | 40.0 | -12.0 | | ||
| b | 0x62 | 459 | 78 | 494 | 153 | 18.0 | 18.0 | -12.0 | | ||
| c | 0x63 | 1 | 427 | 34 | 477 | 18.0 | 42.0 | -15.0 | | ||
| d | 0x64 | 275 | 85 | 310 | 159 | 18.0 | 18.0 | -12.0 | | ||
| e | 0x65 | 36 | 427 | 75 | 476 | 18.0 | 41.0 | -16.0 | | ||
| f | 0x66 | 314 | 83 | 344 | 153 | 16.0 | 23.0 | -16.0 | | ||
| g | 0x67 | 139 | 86 | 173 | 159 | 18.0 | 41.0 | -12.0 | | ||
| h | 0x68 | 474 | 368 | 508 | 434 | 18.0 | 24.0 | -12.0 | | ||
| i | 0x69 | 495 | 1 | 505 | 65 | 18.0 | 26.0 | -12.0 | | ||
| j | 0x6a | 281 | 1 | 301 | 83 | 7.0 | 26.0 | -12.0 | | ||
| k | 0x6b | 379 | 299 | 413 | 367 | 18.0 | 23.0 | -15.0 | | ||
| l | 0x6c | 496 | 67 | 505 | 130 | 18.0 | 27.0 | -11.0 | | ||
| m | 0x6d | 131 | 426 | 177 | 476 | 18.0 | 41.0 | -11.0 | | ||
| n | 0x6e | 77 | 427 | 109 | 476 | 18.0 | 41.0 | -12.0 | | ||
| o | 0x6f | 59 | 373 | 94 | 425 | 18.0 | 41.0 | -11.0 | | ||
| p | 0x70 | 346 | 79 | 381 | 154 | 18.0 | 41.0 | -12.0 | | ||
| q | 0x71 | 238 | 85 | 273 | 160 | 18.0 | 41.0 | -12.0 | | ||
| r | 0x72 | 368 | 434 | 399 | 483 | 18.0 | 42.0 | -15.0 | | ||
| s | 0x73 | 172 | 373 | 205 | 424 | 16.0 | 40.0 | -14.0 | | ||
| t | 0x74 | 368 | 369 | 402 | 432 | 15.0 | 28.0 | -15.0 | | ||
| u | 0x75 | 179 | 426 | 214 | 476 | 18.0 | 41.0 | -12.0 | | ||
| v | 0x76 | 315 | 435 | 350 | 483 | 15.0 | 42.0 | -16.0 | | ||
| w | 0x77 | 401 | 436 | 456 | 484 | 15.0 | 42.0 | -16.0 | | ||
| x | 0x78 | 216 | 426 | 250 | 476 | 15.0 | 42.0 | -16.0 | | ||
| y | 0x79 | 418 | 78 | 457 | 153 | 16.0 | 42.0 | -15.0 | | ||
| z | 0x7a | 131 | 373 | 170 | 424 | 15.0 | 40.0 | -16.0 | | ||
| { | 0x7b | 164 | 1 | 187 | 84 | 16.0 | 16.0 | -15.0 | | ||
| | | 0x7c | 303 | 1 | 312 | 83 | 18.0 | 17.0 | -11.0 | | ||
| } | 0x7d | 189 | 1 | 212 | 84 | 15.0 | 16.0 | -14.0 | | ||
| ~ | 0x7e | 72 | 478 | 118 | 492 | 16.0 | 50.0 | -14.0 | | ||
+------+------+------+-----+-------+--------+----------+----------+-----------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
kaitaistruct | ||
prettytable |