psCharStrings

psCharStrings.py – module implementing various kinds of CharStrings: CFF dictionary data and Type1/Type2 CharStrings.

class fontTools.misc.psCharStrings.ByteCodeBase
read_byte(b0, data, index)
read_smallInt1(b0, data, index)
read_smallInt2(b0, data, index)
read_shortInt(b0, data, index)
read_longInt(b0, data, index)
read_fixed1616(b0, data, index)
read_realNumber(b0, data, index)
fontTools.misc.psCharStrings.buildOperatorDict(operatorList)
fontTools.misc.psCharStrings.getIntEncoder(format)
fontTools.misc.psCharStrings.encodeIntCFF(value, fourByteOp='\x1d', chr=<built-in function chr>, pack=<built-in function pack>, unpack=<built-in function unpack>)
fontTools.misc.psCharStrings.encodeIntT1(value, fourByteOp='\xff', chr=<built-in function chr>, pack=<built-in function pack>, unpack=<built-in function unpack>)
fontTools.misc.psCharStrings.encodeIntT2(value, fourByteOp=None, chr=<built-in function chr>, pack=<built-in function pack>, unpack=<built-in function unpack>)
fontTools.misc.psCharStrings.encodeFixed(f, pack=<built-in function pack>)
fontTools.misc.psCharStrings.encodeFloat(f)
exception fontTools.misc.psCharStrings.CharStringCompileError

Bases: exceptions.Exception

class fontTools.misc.psCharStrings.T2CharString(bytecode=None, program=None, private=None, globalSubrs=None)

Bases: fontTools.misc.psCharStrings.ByteCodeBase

operandEncoding = ['do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'read_shortInt', 'do_operator', 'do_operator', 'do_operator', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'read_fixed1616']
getIntEncoder()
getFixedEncoder()
decompile()
draw(pen)
compile()
needsDecompilation()
setProgram(program)
setBytecode(bytecode)
getToken(index, len=<built-in function len>, ord=<built-in function ord>, getattr=<built-in function getattr>, type=<type 'type'>, StringType=<type 'str'>)
getBytes(index, nBytes)
do_operator(b0, data, index)
toXML(xmlWriter)
fromXML((name, attrs, content))
opcodes = {'and': (12, 3), 'load': (12, 13), 'drop': (12, 18), 'random': (12, 23), 'not': (12, 5), 'rlinecurve': (25,), 'hflex1': (12, 36), 'eq': (12, 15), 'ignore': (12, 0), 'vlineto': (7,), 'cntrmask': (20,), 'endchar': (14,), 'vmoveto': (4,), 'sqrt': (12, 26), 'add': (12, 10), 'abs': (12, 9), 'ifelse': (12, 22), 'vstemhm': (23,), 'dup': (12, 27), 'mul': (12, 24), 'flex1': (12, 37), 'hvcurveto': (31,), 'store': (12, 8), 'flex': (12, 35), 'return': (11,), 'get': (12, 21), 'vhcurveto': (30,), 'hlineto': (6,), 'vvcurveto': (26,), 'callsubr': (10,), 'neg': (12, 14), 'hmoveto': (22,), 'exch': (12, 28), 'rrcurveto': (8,), 'sub': (12, 11), 'hstem': (1,), 'rcurveline': (24,), 'put': (12, 20), 'rmoveto': (21,), 'callgsubr': (29,), 'roll': (12, 30), 'rlineto': (5,), 'hflex': (12, 34), 'index': (12, 29), 'hstemhm': (18,), 'vstem': (3,), 'div': (12, 12), 'hhcurveto': (27,), 'blend': (16,), 'or': (12, 4), 'hintmask': (19,)}
operators = {1: 'hstem', 3: 'vstem', 4: 'vmoveto', 5: 'rlineto', 6: 'hlineto', 7: 'vlineto', 8: 'rrcurveto', 10: 'callsubr', 11: 'return', 14: 'endchar', 16: 'blend', 18: 'hstemhm', 19: 'hintmask', 20: 'cntrmask', 21: 'rmoveto', 22: 'hmoveto', 23: 'vstemhm', 24: 'rcurveline', 25: 'rlinecurve', 26: 'vvcurveto', 27: 'hhcurveto', (12, 9): 'abs', 29: 'callgsubr', 30: 'vhcurveto', 31: 'hvcurveto', (12, 20): 'put', (12, 27): 'dup', (12, 13): 'load', (12, 24): 'mul', (12, 37): 'flex1', (12, 36): 'hflex1', (12, 10): 'add', (12, 28): 'exch', (12, 3): 'and', (12, 21): 'get', (12, 34): 'hflex', (12, 12): 'div', (12, 14): 'neg', (12, 18): 'drop', (12, 11): 'sub', (12, 29): 'index', (12, 22): 'ifelse', (12, 35): 'flex', (12, 5): 'not', (12, 15): 'eq', (12, 0): 'ignore', (12, 26): 'sqrt', (12, 4): 'or', (12, 30): 'roll', (12, 23): 'random', (12, 8): 'store'}
class fontTools.misc.psCharStrings.T1CharString(bytecode=None, program=None, subrs=None)

Bases: fontTools.misc.psCharStrings.T2CharString

operandEncoding = ['do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'read_longInt']
getIntEncoder()
getFixedEncoder()
decompile()
draw(pen)
opcodes = {'vstem3': (12, 1), 'dotsection': (12, 0), 'pop': (12, 17), 'seac': (12, 6), 'closepath': (9,), 'callothersubr': (12, 16), 'vlineto': (7,), 'endchar': (14,), 'vmoveto': (4,), 'hvcurveto': (31,), 'return': (11,), 'sbw': (12, 7), 'vhcurveto': (30,), 'hlineto': (6,), 'setcurrentpoint': (12, 33), 'callsubr': (10,), 'hmoveto': (22,), 'hstem3': (12, 2), 'hsbw': (13,), 'hstem': (1,), 'rmoveto': (21,), 'rlineto': (5,), 'vstem': (3,), 'div': (12, 12), 'rrcurveto': (8,)}
operators = {1: 'hstem', 3: 'vstem', 4: 'vmoveto', 5: 'rlineto', 6: 'hlineto', 7: 'vlineto', 8: 'rrcurveto', 9: 'closepath', 10: 'callsubr', (12, 12): 'div', 13: 'hsbw', 14: 'endchar', 21: 'rmoveto', 22: 'hmoveto', (12, 16): 'callothersubr', (12, 1): 'vstem3', 30: 'vhcurveto', 31: 'hvcurveto', (12, 2): 'hstem3', (12, 33): 'setcurrentpoint', (12, 6): 'seac', (12, 17): 'pop', 11: 'return', (12, 7): 'sbw', (12, 0): 'dotsection'}
class fontTools.misc.psCharStrings.SimpleT2Decompiler(localSubrs, globalSubrs)
reset()
execute(charString)
pop()
popall()
push(value)
op_return(index)
op_endchar(index)
op_ignore(index)
op_callsubr(index)
op_callgsubr(index)
op_hstem(index)
op_vstem(index)
op_hstemhm(index)
op_vstemhm(index)
op_hintmask(index)
op_cntrmask(index)
countHints()
class fontTools.misc.psCharStrings.T2OutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX)

Bases: fontTools.misc.psCharStrings.SimpleT2Decompiler

reset()
_nextPoint(point)
rMoveTo(point)
rLineTo(point)
rCurveTo(pt1, pt2, pt3)
closePath()
endPath()
popallWidth(evenOdd=0)
countHints()
op_rmoveto(index)
op_hmoveto(index)
op_vmoveto(index)
op_endchar(index)
op_rlineto(index)
op_hlineto(index)
op_vlineto(index)
op_rrcurveto(index)

{dxa dya dxb dyb dxc dyc}+ rrcurveto

op_rcurveline(index)

{dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveline

op_rlinecurve(index)

{dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurve

op_vvcurveto(index)

dx1? {dya dxb dyb dyc}+ vvcurveto

op_hhcurveto(index)

dy1? {dxa dxb dyb dxc}+ hhcurveto

op_vhcurveto(index)

dy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto

op_hvcurveto(index)

dx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf?

op_hflex(index)
op_flex(index)
op_hflex1(index)
op_flex1(index)
op_blend(index)
op_and(index)
op_or(index)
op_not(index)
op_store(index)
op_abs(index)
op_add(index)
op_sub(index)
op_div(index)
op_load(index)
op_neg(index)
op_eq(index)
op_drop(index)
op_put(index)
op_get(index)
op_ifelse(index)
op_random(index)
op_mul(index)
op_sqrt(index)
op_dup(index)
op_exch(index)
op_index(index)
op_roll(index)
alternatingLineto(isHorizontal)
vcurveto(args)
hcurveto(args)
class fontTools.misc.psCharStrings.T1OutlineExtractor(pen, subrs)

Bases: fontTools.misc.psCharStrings.T2OutlineExtractor

reset()
endPath()
popallWidth(evenOdd=0)
exch()
op_rmoveto(index)
op_hmoveto(index)
op_vmoveto(index)
op_closepath(index)
op_setcurrentpoint(index)
op_endchar(index)
op_hsbw(index)
op_sbw(index)
op_callsubr(index)
op_callothersubr(index)
op_pop(index)
doFlex()
op_dotsection(index)
op_hstem3(index)
op_seac(index)

asb adx ady bchar achar seac

op_vstem3(index)
class fontTools.misc.psCharStrings.DictDecompiler(strings)

Bases: fontTools.misc.psCharStrings.ByteCodeBase

operandEncoding = ['do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'do_operator', 'read_shortInt', 'read_longInt', 'read_realNumber', 'do_operator', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_byte', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt1', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'read_smallInt2', 'reserved']
getDict()
decompile(data)
pop()
popall()
do_operator(b0, data, index)
handle_operator(operator, argType)
arg_number(name)
arg_SID(name)
arg_array(name)
arg_delta(name)
fontTools.misc.psCharStrings.calcSubrBias(subrs)