Skip to content

Commit 1322aa5

Browse files
authored
Merge pull request #42 from arduino-libraries/upgrade-script
Update font generator script to work with python 3.x
2 parents 72388e2 + 8d32f4e commit 1322aa5

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

README.adoc

+7
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ Lesser General Public License for more details.
2828
You should have received a copy of the GNU Lesser General Public
2929
License along with this library; if not, write to the Free Software
3030
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31+
32+
== How-to generate bitmaps from the fonts ==
33+
[source,bash]
34+
----
35+
cd extra
36+
./generate_font.py 5x7.bdf Font_5x7.c Font_5x7
37+
----

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)