From 6e9e9349391af2094e8e7cde7044e47898641f2d Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Thu, 17 Oct 2019 07:32:27 +0100 Subject: [PATCH] V0.33 Add baseline(), fix bug with name check. --- FONT_TO_PY.md | 8 ++++++-- font_to_py.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/FONT_TO_PY.md b/FONT_TO_PY.md index 17b56ab..8887f3a 100644 --- a/FONT_TO_PY.md +++ b/FONT_TO_PY.md @@ -9,9 +9,13 @@ targets: the font file may be incorporated into a firmware build such that it occupies flash memory rather than scarce RAM. Python code built into firmware is known as frozen bytecode. -## V0.32 notes +## Recent revisions -21 Sept 2019 +17 Oct 2019 V0.33 With thanks to Stephen Irons (@ironss). + 1. Fix bug where input rather than output filename was checked. + 2. Add `baseline()` to ouput file returning the maximum descent. + +21 Sept 2019 V0.22 1. Reduced output file size for sparse fonts. These result from large gaps between ordinal values of Unicode characters not in the standard ASCII set. diff --git a/font_to_py.py b/font_to_py.py index 752eb32..163d183 100755 --- a/font_to_py.py +++ b/font_to_py.py @@ -312,6 +312,7 @@ class Font(dict): self.height = int(max_ascent + max_descent) st = 'Height set in {} passes. Actual height {} pixels.\nMax character width {} pixels.' print(st.format(npass + 1, self.height, max_width)) + self._max_ascent = int(max_ascent) self._max_descent = int(max_descent) return max_width @@ -393,7 +394,7 @@ class Font(dict): STR01 = """# Code generated by font_to_py.py. # Font: {}{} # Cmd: {} -version = '0.32' +version = '0.33' """ @@ -478,6 +479,7 @@ def write_data(stream, fnt, font_path, hmap, reverse, iterate, charset): cl = ' '.join(sys.argv) stream.write(STR01.format(os.path.split(font_path)[1], st, cl)) write_func(stream, 'height', height) + write_func(stream, 'baseline', fnt._max_ascent) write_func(stream, 'max_width', fnt.max_width) write_func(stream, 'hmap', hmap) write_func(stream, 'reverse', reverse) @@ -598,7 +600,7 @@ if __name__ == "__main__": default = '') args = parser.parse_args() - if not args.infile[0].isalpha(): + if not args.outfile[0].isalpha(): quit('Font filenames must be valid Python variable names.') if not os.path.isfile(args.infile):