kopia lustrzana https://github.com/peterhinch/micropython-font-to-py
font_to_py.py Update docs.
rodzic
2c3b1f5327
commit
5e3872117c
|
@ -63,7 +63,7 @@ bytecode this will not reduce RAM usage but it will conserve flash. An example
|
||||||
usage for a digital clock font:
|
usage for a digital clock font:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
font_to_py.py Arial.ttf 20 arial_clock.py -c 1234567890:
|
$ font_to_py.py Arial.ttf 20 arial_clock.py -c 1234567890:
|
||||||
```
|
```
|
||||||
If a character set is specified, `--smallest` and `--largest` should not be
|
If a character set is specified, `--smallest` and `--largest` should not be
|
||||||
specified: these values are computed from the charcater set.
|
specified: these values are computed from the charcater set.
|
||||||
|
|
|
@ -69,14 +69,14 @@ has the following outline definition (in practice the bytes objects are large):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Code generated by font-to-py.py.
|
# Code generated by font-to-py.py.
|
||||||
# Font: FreeSerif.ttf
|
# Font: Arial.ttf
|
||||||
version = '0.2'
|
version = '0.25'
|
||||||
|
|
||||||
def height():
|
def height():
|
||||||
return 21
|
return 20
|
||||||
|
|
||||||
def max_width():
|
def max_width():
|
||||||
return 22
|
return 20
|
||||||
|
|
||||||
def hmap():
|
def hmap():
|
||||||
return False
|
return False
|
||||||
|
@ -94,15 +94,14 @@ def max_ch():
|
||||||
return 126
|
return 126
|
||||||
|
|
||||||
_font =\
|
_font =\
|
||||||
b'\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\
|
b'\x0b\x00\x18\x00\x00\x1c\x00\x00\x0e\x00\x00\x06\xce\x00\x06\xcf'\
|
||||||
b'\x00\x00\x00\x00\x08\x00\xfe\xc7\x00\x7e\xc0\x00\x00\x00\x00\x00'\
|
b'\x00\x86\x03\x00\xce\x01\x00\xfc\x00\x00\x38\x00\x00\x00\x00\x00'\
|
||||||
|
|
||||||
_index =\
|
_index =\
|
||||||
b'\x00\x00\x14\x00\x2e\x00\x4b\x00\x71\x00\x97\x00\xd2\x00\x0a\x01'\
|
b'\x00\x00\x23\x00\x23\x00\x37\x00\x37\x00\x4b\x00\x4b\x00\x62\x00'\
|
||||||
b'\x1b\x01\x35\x01\x4f\x01\x75\x01\x9e\x01\xb2\x01\xcc\x01\xe0\x01'\
|
b'\x62\x00\x85\x00\x85\x00\xa8\x00\xa8\x00\xe0\x00\xe0\x00\x09\x01'\
|
||||||
|
|
||||||
_mvfont = memoryview(_font)
|
_mvfont = memoryview(_font)
|
||||||
# Boilerplate code omitted
|
|
||||||
|
|
||||||
def get_ch(ch):
|
def get_ch(ch):
|
||||||
# validate ch, if out of range use '?'
|
# validate ch, if out of range use '?'
|
||||||
|
@ -124,6 +123,20 @@ character check.
|
||||||
and contains all the bytes required to render the character including trailing
|
and contains all the bytes required to render the character including trailing
|
||||||
space.
|
space.
|
||||||
|
|
||||||
|
The `_font` bytearray holds the glyphs corresponding to every character in the
|
||||||
|
font. Entry 0 is the default glyph, used if an attempt is made to render a
|
||||||
|
nonexistent character.
|
||||||
|
|
||||||
|
The index holds two integers (each occupying 2 bytes) per character. The index
|
||||||
|
has an entry for every character in the specified range, whether or not that
|
||||||
|
character exists.
|
||||||
|
|
||||||
|
Index entries are offsets into the `_font` bytearray represnting the start and
|
||||||
|
end of the glyph. If the font comprises a set of characters which is not
|
||||||
|
contiguous, missing characters have an index entry which points to the first
|
||||||
|
glyph in the `_font` bytearray. This ensures that the default glyph is
|
||||||
|
rendered.
|
||||||
|
|
||||||
## Fixed width fonts
|
## Fixed width fonts
|
||||||
|
|
||||||
If a Python font file is created with the `-f` argument, all characters will
|
If a Python font file is created with the `-f` argument, all characters will
|
||||||
|
|
Ładowanie…
Reference in New Issue