OS/2: OS/2 and Windows Metrics Table

class fontTools.ttLib.tables.O_S_2f_2.Panose[source]
fromXML(name, attrs, content, ttFont)[source]
toXML(writer, ttFont)[source]
fontTools.ttLib.tables.O_S_2f_2.intersectUnicodeRanges(unicodes, inverse=False)[source]

Intersect a sequence of (int) Unicode codepoints with the Unicode block ranges defined in the OpenType specification v1.7, and return the set of ‘ulUnicodeRanges’ bits for which there is at least ONE intersection. If ‘inverse’ is True, return the the bits for which there is NO intersection.

>>> intersectUnicodeRanges([0x0410]) == {9}
>>> intersectUnicodeRanges([0x0410, 0x1F000]) == {9, 57, 122}
>>> intersectUnicodeRanges([0x0410, 0x1F000], inverse=True) == (
...     set(range(len(OS2_UNICODE_RANGES))) - {9, 57, 122})
class fontTools.ttLib.tables.O_S_2f_2.table_O_S_2f_2(tag=None)[source]

the OS/2 table

decompile(data, ttFont)[source]
dependencies = ['head']
fromXML(name, attrs, content, ttFont)[source]
property fsFirstCharIndex
property fsLastCharIndex

Return the set of ‘ulUnicodeRange*’ bits currently enabled.

merge(m, tables)
mergeMap = {'*': <function first>, 'fsFirstCharIndex': <built-in function min>, 'fsLastCharIndex': <built-in function max>, 'fsType': <function mergeOs2FsType>, 'panose': <function first>, 'sCapHeight': <function onlyExisting.<locals>.wrapper>, 'sTypoAscender': <built-in function max>, 'sTypoDescender': <built-in function min>, 'sTypoLineGap': <built-in function max>, 'sxHeight': <function onlyExisting.<locals>.wrapper>, 'tableTag': <function equal>, 'ulCodePageRange1': <function onlyExisting.<locals>.wrapper>, 'ulCodePageRange2': <function onlyExisting.<locals>.wrapper>, 'ulUnicodeRange1': <function bitwise_or>, 'ulUnicodeRange2': <function bitwise_or>, 'ulUnicodeRange3': <function bitwise_or>, 'ulUnicodeRange4': <function bitwise_or>, 'usBreakChar': <function onlyExisting.<locals>.wrapper>, 'usDefaultChar': <function onlyExisting.<locals>.wrapper>, 'usLowerOpticalPointSize': <function onlyExisting.<locals>.wrapper>, 'usMaxContext': <function onlyExisting.<locals>.wrapper>, 'usUpperOpticalPointSize': <function onlyExisting.<locals>.wrapper>, 'usWinAscent': <built-in function max>, 'usWinDescent': <built-in function max>, 'version': <built-in function max>, 'xAvgCharWidth': <function first>}

Recalculate xAvgCharWidth using metrics from ttFont’s ‘hmtx’ table.

Set it to 0 if the unlikely event ‘hmtx’ table is not found.

recalcUnicodeRanges(ttFont, pruneOnly=False)[source]

Intersect the codepoints in the font’s Unicode cmap subtables with the Unicode block ranges defined in the OpenType specification (v1.7), and set the respective ‘ulUnicodeRange*’ bits if there is at least ONE intersection. If ‘pruneOnly’ is True, only clear unused bits with NO intersection.


Set the ‘ulUnicodeRange*’ fields to the specified ‘bits’.

toXML(writer, ttFont)[source]
property usMaxContex