textTools

fontTools.misc.textTools.py – miscellaneous routines.

fontTools.misc.textTools.binary2num(bin)[source]
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.deHexStr(hexdata)[source]

Convert a hex string to binary data.

fontTools.misc.textTools.hexStr(data)[source]

Convert binary data to a hex string.

fontTools.misc.textTools.num2binary(l, bits=32)[source]
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.readHex(content)[source]

Convert a list of hex strings to binary data.