V0.27 Command line as comment in font file.

pull/28/head
Peter Hinch 2019-09-06 09:06:23 +01:00
rodzic 1bf283b16f
commit a9bafe4663
3 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -61,7 +61,10 @@ Example usage to produce a file `myfont.py` with height of 23 pixels:
set. See below.
* -k or --charset_file Obtain the character set from a file. Typical use is
for alternative character sets such as Cyrillic: the file must contain the
character set to be included. An example file is `cyrillic`.
character set to be included. An example file is `cyrillic`. Another is
`extended` which adds unicode characters "° μ π ω ϕ θ α β γ δ λ Ω" to those
with `ord` values from 32-128. Such files will only produce useful results if
the font file includes them.
The -c option may be used to reduce the size of the font file by limiting the
character set. If the font file is frozen as bytecode this will not reduce RAM
@ -78,6 +81,10 @@ font_to_py.py FreeSans.ttf 20 freesans_cyr_20.py -k cyrillic
If a character set is specified, `--smallest` and `--largest` should not be
specified: these values are computed from the character set.
The representation of non-contiguous character sets having large gaps (such as
the `extended` set) is not very efficient. This matters little if the font is
to be frozen as bytecode. I plan to investigate ways of improving this.
Any requirement for arguments -xr will be specified in the device driver
documentation. Bit reversal is required by some display hardware.

Wyświetl plik

@ -31,7 +31,7 @@ The resultant file is usable with two varieties of display device drivers:
# Solution
This comprises three components:
This comprises three components, links to docs below:
1. [font_to_py.py](./FONT_TO_PY.md) This utility runs on a PC and converts a
font file to Python source. See below.

Wyświetl plik

@ -370,7 +370,8 @@ class Font(dict):
STR01 = """# Code generated by font-to-py.py.
# Font: {}{}
version = '0.26'
# Cmd: {}
version = '0.27'
"""
STR02 = """_mvfont = memoryview(_font)
@ -419,7 +420,8 @@ def write_data(stream, fnt, font_path, hmap, reverse, iterate):
defchar = fnt.defchar
charset = fnt.def_charset
st = '' if charset == '' else ' Char set: {}'.format(charset)
stream.write(STR01.format(os.path.split(font_path)[1], st))
cl = ' '.join(sys.argv)
stream.write(STR01.format(os.path.split(font_path)[1], st, cl))
stream.write('\n')
write_func(stream, 'height', height)
write_func(stream, 'max_width', fnt.max_width)