Skip to content

Commit 7c067b6

Browse files
committed
Update font generator script to work with python 3.x
1 parent 72388e2 commit 7c067b6

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

extras/generate_font.py

+18-13
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,27 @@
6060

6161
out = open(output, "w")
6262

63-
print >> out, "#include \"Font.h\""
64-
print >> out
65-
print >> out, "const struct Font %s = {" % ( name )
66-
print >> out, " %d," % ( fontWidth )
67-
print >> out, " %d," % ( fontHeight )
68-
print >> out, " (const uint8_t*[]){"
63+
out.write("#include \"Font.h\"\n")
64+
out.write("\n")
65+
out.write("const struct Font %s = {" % ( name ))
66+
out.write("\n")
67+
out.write(" %d," % ( fontWidth ))
68+
out.write("\n")
69+
out.write(" %d," % ( fontHeight ))
70+
out.write("\n")
71+
out.write(" (const uint8_t*[]){\n")
6972
for c in range (0, 255):
7073
if None == fontCharacters[c]:
71-
print >> out, " NULL,"
74+
out.write(" NULL,\n")
7275
else:
73-
print >> out, " // %s" % (fontCharacterNames[c])
74-
print >> out, " (const uint8_t[]){"
76+
out.write(" // %s" % (fontCharacterNames[c]))
77+
out.write("\n")
78+
out.write(" (const uint8_t[]){\n")
7579
for i in range(0, fontHeight):
76-
print >> out, " 0b%s," % ('{0:08b}'.format(fontCharacters[c][i]))
77-
print >> out, " },"
78-
print >> out, " }"
79-
print >> out, "};"
80+
out.write(" 0b%s," % ('{0:08b}'.format(fontCharacters[c][i])))
81+
out.write("\n")
82+
out.write(" },\n")
83+
out.write(" }\n")
84+
out.write("};\n")
8085

8186
out.close()

0 commit comments

Comments
 (0)