hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/tools/genfonts.py
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-10 15:57:52 +0200
committerhachem <im@hachem.wtf>2026-10-10 15:57:52 +0200
commit88750ed7132c08bcfb24e878c893ef7185c3c0b0 (patch)
tree6274d4918c82ee0c8c9c258ff8d9d3340b0b28e6 /tools/genfonts.py
parentcc8768d33a6ff6cc64306d01679a10c3a1847736 (diff)
chore: rewrite tools in revo
Diffstat (limited to 'tools/genfonts.py')
-rw-r--r--tools/genfonts.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/tools/genfonts.py b/tools/genfonts.py
deleted file mode 100644
index e5afb7e..0000000
--- a/tools/genfonts.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python3
-# this just turns the linxu console fonts which are C arrays into psf1 fonts
-# that i can load on disk since half of my psf1 fonts are stolen from there.
-#
-# usage: genfonts.py <font_8x16.c> <out.psf> [height]
-
-import re
-import sys
-
-
-def parse_c(path):
- text = open(path).read()
- cut = text.index("}, {")
- body = text[cut + 4 :]
- body = re.sub(r"/\*.*?\*/", "", body, flags=re.S)
- bytes_ = [int(m, 16) for m in re.findall(r"0x([0-9a-fA-F]{2})", body)]
- return bytes_
-
-def write_psf1(rows, height, out):
- count = len(rows) // height
- if count < 256:
- rows = rows + [0] * (height * (256 - count))
- count = 256
- if count not in (256, 512):
- rows = rows[: height * 256]
- count = 256
- mode = 0x00 if count == 256 else 0x01 # bit0 set => 512 glyphs
- header = bytes([0x36, 0x04, mode, height])
- with open(out, "wb") as f:
- f.write(header)
- f.write(bytes(rows[: height * count]))
-
-def main():
- src, out = sys.argv[1], sys.argv[2]
- height = int(sys.argv[3]) if len(sys.argv) > 3 else int(re.search(r"8x(\d+)", src).group(1))
- rows = parse_c(src)
- write_psf1(rows, height, out)
- print(f"{out}: psf1 8x{height}, {len(rows) // height} glyphs in")
-
-if __name__ == "__main__":
- main()