From 7c067b602e9c449bb67d2743ea6f50fa54f12c20 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 22 Feb 2024 10:43:13 +0100 Subject: [PATCH 1/2] Update font generator script to work with python 3.x --- extras/generate_font.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/extras/generate_font.py b/extras/generate_font.py index de786e5..016f634 100755 --- a/extras/generate_font.py +++ b/extras/generate_font.py @@ -60,22 +60,27 @@ out = open(output, "w") -print >> out, "#include \"Font.h\"" -print >> out -print >> out, "const struct Font %s = {" % ( name ) -print >> out, " %d," % ( fontWidth ) -print >> out, " %d," % ( fontHeight ) -print >> out, " (const uint8_t*[]){" +out.write("#include \"Font.h\"\n") +out.write("\n") +out.write("const struct Font %s = {" % ( name )) +out.write("\n") +out.write(" %d," % ( fontWidth )) +out.write("\n") +out.write(" %d," % ( fontHeight )) +out.write("\n") +out.write(" (const uint8_t*[]){\n") for c in range (0, 255): if None == fontCharacters[c]: - print >> out, " NULL," + out.write(" NULL,\n") else: - print >> out, " // %s" % (fontCharacterNames[c]) - print >> out, " (const uint8_t[]){" + out.write(" // %s" % (fontCharacterNames[c])) + out.write("\n") + out.write(" (const uint8_t[]){\n") for i in range(0, fontHeight): - print >> out, " 0b%s," % ('{0:08b}'.format(fontCharacters[c][i])) - print >> out, " }," -print >> out, " }" -print >> out, "};" + out.write(" 0b%s," % ('{0:08b}'.format(fontCharacters[c][i]))) + out.write("\n") + out.write(" },\n") +out.write(" }\n") +out.write("};\n") out.close() From 8d32f4edf46d335a289c33c184480830a5695255 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 22 Feb 2024 10:45:33 +0100 Subject: [PATCH 2/2] Add minimum documentation on how to generate a font bitmap. --- README.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.adoc b/README.adoc index a77a80e..eeee79b 100644 --- a/README.adoc +++ b/README.adoc @@ -28,3 +28,10 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +== How-to generate bitmaps from the fonts == +[source,bash] +---- +cd extra +./generate_font.py 5x7.bdf Font_5x7.c Font_5x7 +----