textTools

fontTools.misc.textTools.py – miscellaneous routines.

class fontTools.misc.textTools.Tag(content)[source]

Bases: str

static transcode(blob)[source]
tobytes()[source]
fontTools.misc.textTools.readHex(content)[source]

Convert a list of hex strings to binary data.

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.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.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, encoding='ascii', errors='strict')[source]
fontTools.misc.textTools.tobytes(s, encoding='ascii', errors='strict')[source]
fontTools.misc.textTools.bytechr(n)[source]
fontTools.misc.textTools.byteord(c)[source]
fontTools.misc.textTools.strjoin(iterable, joiner='')[source]
fontTools.misc.textTools.bytesjoin(iterable, joiner=b'')[source]