Last active
January 23, 2022 22:11
-
-
Save tomekzaw/ac3aa4942587869119dd926da024b6e9 to your computer and use it in GitHub Desktop.
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
# fnt2cfg.py v0.1 ~tomekzaw 2022 | |
# https://gist.github.com/tomekzaw/ac3aa4942587869119dd926da024b6e9 | |
import argparse | |
from pathlib import Path | |
def fnt2cfg(d: bytes) -> bytes: | |
d = bytearray(d) | |
for i in 2, 105, 113: | |
d[i:i+4] = d[i:i+4][::-1] | |
for i in 68, 70, 72, 83, 88, 91, 93, 99: | |
d[i:i+2] = d[i:i+2][::-1] | |
for i in range(118, d.find(b'\x00' * 8, 118) - 4, 2): | |
d[i:i+2] = d[i:i+2][::-1] | |
return bytes(d) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-i', '--input', required=True) | |
parser.add_argument('-o', '--output', required=True) | |
args = parser.parse_args() | |
if not Path(args.input).exists(): | |
raise SystemExit('Input file not found') | |
if not Path(args.input).is_file(): | |
raise SystemExit('Input path is not a file') | |
if Path(args.output).exists(): | |
raise SystemExit('Output file already exists') | |
with open(Path(args.input), 'rb') as f: | |
output = fnt2cfg(f.read()) | |
with open(Path(args.output), 'wb') as f: | |
f.write(output) | |
print('OK') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.vsoft.nl/software/utils/win/fontedit/