OS/2
: OS/2 and Windows Metrics Table
- class fontTools.ttLib.tables.O_S_2f_2.table_O_S_2f_2(tag=None)[source]
Bases:
DefaultTable
the OS/2 table
- dependencies = ['head']
- property usMaxContex
- property fsFirstCharIndex
- property fsLastCharIndex
- 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.
- recalcAvgCharWidth(ttFont)[source]
Recalculate xAvgCharWidth using metrics from ttFont’s ‘hmtx’ table.
Set it to 0 if the unlikely event ‘hmtx’ table is not found.
- 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>}
- 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} True >>> intersectUnicodeRanges([0x0410, 0x1F000]) == {9, 57, 122} True >>> intersectUnicodeRanges([0x0410, 0x1F000], inverse=True) == ( ... set(range(len(OS2_UNICODE_RANGES))) - {9, 57, 122}) True
- fontTools.ttLib.tables.O_S_2f_2.calcCodePageRanges(unicodes)[source]
Given a set of Unicode codepoints (integers), calculate the corresponding OS/2 CodePage range bits. This is a direct translation of FontForge implementation: https://github.com/fontforge/fontforge/blob/7b2c074/fontforge/tottf.c#L3158