Skip to content

Commit 18b189f

Browse files
committed
preliminary external raster font reader
1 parent e645c24 commit 18b189f

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

source_code_gen/Bm437_IBM_CGA.FON

3.95 KB
Binary file not shown.

source_code_gen/loadfont.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from os import path
2+
def plot8bitpatternastext(
3+
bitpattern: list[int],
4+
onechar: str,
5+
zerochar: str):
6+
"""Outputs the bits of a list
7+
of bytes to console
8+
9+
Args:
10+
bitpattern: list of bytes
11+
onechar : char to display
12+
if bit is 1
13+
zerochar : char to display
14+
if bit is 0
15+
16+
Returns:
17+
console output
18+
"""
19+
s = ""
20+
for bits in bitpattern:
21+
mask = 128
22+
while mask > 0:
23+
s += onechar if mask & bits > 0 else zerochar
24+
mask >>= 1
25+
s += '\n'
26+
return s
27+
28+
def getcharbmp(filename: str, ch: str):
29+
a = ""
30+
with open(filename, 'rb') as f:
31+
f.seek(1626 + 8 * ord(ch))
32+
a = f.read(8)
33+
return a
34+
35+
def main():
36+
scriptdir = path.dirname(__file__)
37+
filename = scriptdir + "/Bm437_IBM_CGA.FON"
38+
ch = ">"
39+
a = getcharbmp(filename, ch)
40+
print(a)
41+
print(plot8bitpatternastext(a,"*"," "))
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)