fixedTools

fontTools.misc.fixedTools.py – tools for working with fixed numbers.

fontTools.misc.fixedTools.fixedToFloat(value, precisionBits)[source]

Converts a fixed-point number to a float, choosing the float that has the shortest decimal reprentation. Eg. to convert a fixed number in a 2.14 format, use precisionBits=14. This is pretty slow compared to a simple division. Use sporadically.

precisionBits is only supported up to 16.

fontTools.misc.fixedTools.floatToFixed(value, precisionBits)[source]

Converts a float to a fixed-point number given the number of precisionBits. Ie. int(round(value * (1<<precisionBits))).

fontTools.misc.fixedTools.ensureVersionIsLong(value)[source]

Ensure a table version is an unsigned long (unsigned short major, unsigned short minor) instead of a float.

fontTools.misc.fixedTools.versionToFixed(value)[source]

Converts a table version to a fixed