kopia lustrzana https://github.com/peterhinch/micropython-font-to-py
V0.33 Add baseline(), fix bug with name check.
rodzic
b854d8f078
commit
6e9e934939
|
@ -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
|
occupies flash memory rather than scarce RAM. Python code built into firmware
|
||||||
is known as frozen bytecode.
|
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
|
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.
|
between ordinal values of Unicode characters not in the standard ASCII set.
|
||||||
|
|
|
@ -312,6 +312,7 @@ class Font(dict):
|
||||||
self.height = int(max_ascent + max_descent)
|
self.height = int(max_ascent + max_descent)
|
||||||
st = 'Height set in {} passes. Actual height {} pixels.\nMax character width {} pixels.'
|
st = 'Height set in {} passes. Actual height {} pixels.\nMax character width {} pixels.'
|
||||||
print(st.format(npass + 1, self.height, max_width))
|
print(st.format(npass + 1, self.height, max_width))
|
||||||
|
self._max_ascent = int(max_ascent)
|
||||||
self._max_descent = int(max_descent)
|
self._max_descent = int(max_descent)
|
||||||
return max_width
|
return max_width
|
||||||
|
|
||||||
|
@ -393,7 +394,7 @@ class Font(dict):
|
||||||
STR01 = """# Code generated by font_to_py.py.
|
STR01 = """# Code generated by font_to_py.py.
|
||||||
# Font: {}{}
|
# Font: {}{}
|
||||||
# Cmd: {}
|
# 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)
|
cl = ' '.join(sys.argv)
|
||||||
stream.write(STR01.format(os.path.split(font_path)[1], st, cl))
|
stream.write(STR01.format(os.path.split(font_path)[1], st, cl))
|
||||||
write_func(stream, 'height', height)
|
write_func(stream, 'height', height)
|
||||||
|
write_func(stream, 'baseline', fnt._max_ascent)
|
||||||
write_func(stream, 'max_width', fnt.max_width)
|
write_func(stream, 'max_width', fnt.max_width)
|
||||||
write_func(stream, 'hmap', hmap)
|
write_func(stream, 'hmap', hmap)
|
||||||
write_func(stream, 'reverse', reverse)
|
write_func(stream, 'reverse', reverse)
|
||||||
|
@ -598,7 +600,7 @@ if __name__ == "__main__":
|
||||||
default = '')
|
default = '')
|
||||||
|
|
||||||
args = parser.parse_args()
|
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.')
|
quit('Font filenames must be valid Python variable names.')
|
||||||
|
|
||||||
if not os.path.isfile(args.infile):
|
if not os.path.isfile(args.infile):
|
||||||
|
|
Ładowanie…
Reference in New Issue