SCons: Ensure with statement where applicable

This commit is contained in:
Thaddeus Crews
2024-03-10 12:09:48 -05:00
parent 0ace0a1292
commit fb299d0fb1
21 changed files with 1649 additions and 1699 deletions

View File

@ -13,29 +13,26 @@ from platform_methods import subprocess_main
def make_fonts_header(target, source, env):
dst = target[0]
g = open(dst, "w", encoding="utf-8", newline="\n")
with open(dst, "w", encoding="utf-8", newline="\n") as g:
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _DEFAULT_FONTS_H\n")
g.write("#define _DEFAULT_FONTS_H\n")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _DEFAULT_FONTS_H\n")
g.write("#define _DEFAULT_FONTS_H\n")
# Saving uncompressed, since FreeType will reference from memory pointer.
for i in range(len(source)):
with open(source[i], "rb") as f:
buf = f.read()
# Saving uncompressed, since FreeType will reference from memory pointer.
for i in range(len(source)):
with open(source[i], "rb") as f:
buf = f.read()
name = os.path.splitext(os.path.basename(source[i]))[0]
name = os.path.splitext(os.path.basename(source[i]))[0]
g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
g.write("static const unsigned char _font_" + name + "[] = {\n")
for j in range(len(buf)):
g.write("\t" + str(buf[j]) + ",\n")
g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
g.write("static const unsigned char _font_" + name + "[] = {\n")
for j in range(len(buf)):
g.write("\t" + str(buf[j]) + ",\n")
g.write("};\n")
g.write("};\n")
g.write("#endif")
g.close()
g.write("#endif")
if __name__ == "__main__":