textTools: Tools for working with text data
fontTools.misc.textTools.py – miscellaneous routines.
- fontTools.misc.textTools.caselessSort(alist)[source]
Return a sorted copy of a list. If there are only strings in the list, it will not consider case.
- fontTools.misc.textTools.pad(data, size)[source]
Pad byte string ‘data’ with null bytes until its length is a multiple of ‘size’.
>>> len(pad(b'abcd', 4)) 4 >>> len(pad(b'abcde', 2)) 6 >>> len(pad(b'abcde', 4)) 8 >>> pad(b'abcdef', 4) == b'abcdef\x00\x00' True
- fontTools.misc.textTools.tostr(s: str | bytes, encoding: str = 'ascii', errors: str = 'strict') str[source]