Skip to content

Commit 6c682f8

Browse files
committed
fontsrc: update unifont and univga scripts to python3
1 parent 55a5eed commit 6c682f8

4 files changed

Lines changed: 18 additions & 211 deletions

File tree

fontsrc/font_tools.py

Lines changed: 0 additions & 171 deletions
This file was deleted.

fontsrc/romshow.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

fontsrc/unifont/build.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
2+
23
import tarfile
4+
from io import TextIOWrapper
35

46
unifont = 'unifont-8.0.01.tar.gz'
57
loc = 'unifont-8.0.01/font/plane00/'
@@ -13,8 +15,7 @@
1315
with open('header.txt') as g:
1416
f.write(g.read())
1517
for name in hexfiles:
16-
z = unizip.extractfile(name)
17-
f.write(z.read())
18-
z.close()
18+
with TextIOWrapper(unizip.extractfile(name)) as z:
19+
f.write(z.read())
1920

2021

fontsrc/univga/build.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22

33
import os
44
import string
55
import tarfile
6+
from io import TextIOWrapper
7+
8+
import monobit
69

710
bdf_name = 'uni_vga/u_vga16.bdf'
811
unizip = 'uni-vga.tgz'
912

10-
infile = tarfile.open(unizip, 'r:gz').extractfile(bdf_name)
11-
1213
header = 'header.txt'
1314
hex_name = 'univga_16.hex'
14-
with open(hex_name, 'w') as outfile:
15-
with open(header, 'r') as h:
16-
for line in h:
17-
outfile.write(line)
1815

19-
for line in infile:
20-
if not line:
21-
continue
22-
if line[:8] == 'ENCODING':
23-
outfile.write('\n%04X:' % int(line[8:]))
24-
if len(line) == 3 and line[0] in string.hexdigits and line[1] in string.hexdigits and line[2] == '\n':
25-
outfile.write(line[:2])
26-
outfile.write('\n')
27-
infile.close()
16+
with tarfile.open(unizip, 'r:gz').extractfile(bdf_name) as infile:
17+
uni_vga = monobit.load(TextIOWrapper(infile), format='bdf')
18+
with open(hex_name, 'w') as outfile:
19+
with open(header, 'r') as h:
20+
for line in h:
21+
outfile.write(line)
22+
outfile.write('\n')
23+
uni_vga.save(outfile, format='hex')
24+

0 commit comments

Comments
 (0)