)EjtdZddlmZmZmZmZddlmZmZm Z m Z ddl m Z ddl Z ddlZejeZdZdZdZd Zd Zd Zd Zd ZdZdgdzZdegzedd<degzedd<degzedd<degzedd<eed<eedksJeddZeed<eed<eddZeed<eed<eed<gdZde eDZ!dZ"dZ#gdZ$dZ%e%dZ&e%d Z'e%d!Z(e j)fd"Z*eded#zZ+d$Z,Gd%d&e-Z.Gd'd(e/Z0gd)Z1Gd*d+e0Z2Gd,d-e0Z3Gd.d/e3Z4Gd0d1e4Z5Gd2d3e/Z6Gd4d5e6Z7Gd6d7e/Z8d8Z9dS)9zwpsCharStrings.py -- module implementing various kinds of CharStrings: CFF dictionary data and Type1/Type2 CharStrings. ) fixedToFloat floatToFixedfloatToFixedToStrstrToFixedToFloat)bytechrbyteord bytesjoinstrjoin) BoundsPenNc|dkr|t||f}|dz}n|} |j|}n#t$rd|fcYSwxYw||}||fS)N )r operatorsKeyErrorhandle_operator)selfb0dataindexopoperatorvalues NC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/misc/psCharStrings.py read_operatorrs Rxx'$u+&& '  >"% U{   * *E %<s 5AAc|dz |fS)Nrrrrs r read_byter"s 8U?cRt||}|dz dz|zdz|dzfS)Nlrrrrrrb1s rread_smallInt1r(&s5 e  B H b 3 & 11r cTt||}|dz dz|z dz |dzfS)Nr#r$rr%r&s rread_smallInt2r++s7 e  B #X; r !C ' 22r cTtjd|||dz\}||dzfS)N>hstructunpackrrrrrs r read_shortIntr302}T4 (9#:;;HU %!) r cTtjd|||dz\}||dzfS)N>lr/r2s r read_longIntr85r4r crtjd|||dz\}t|d|dzfS)Nr6r7 precisionBits)r0r1rr2s rread_fixed1616r=:s?}T4 (9#:;;HU R 0 0 0%!) ;;r c&tsJt|fSN)NotImplementedErrorNotImplementedrs r read_reservedrB?s   5  r cd} t||}|dz}|dzdz }|dz}|dkrn(|t|z}|dkrn|t|z}Vt||fS)NTrr7)r realNibblesfloat)rrrrnumberbnibble0nibble1s rread_realNumberrMDs F / DK  t8/d( c>> +g.. c>> +g.. / ==% r r# r"r7r*)0123456789.EE-N-ci|]\}}|| Srr).0ivs r rfws;;;DAq1a;;;r c i}i}|D]y}t|dkr|d||d<n|dd||d<t|dtr|d||d<g|df||d<z||fS)Nr.rr)len isinstancetuple) operatorListoperopcitems rbuildOperatorDictrp|s D C&& t99>> GDaMM HDaM d1gu % % &7CQLL G:CQLL 9r )4rhstemvstemr7vmovetorlinetohlinetovlineto rrcurveto callsubr returnendchar)rFvsindex)r:blend)hstemhm)hintmask)cntrmaskrmovetohmoveto)vstemhm) rcurveline) rlinecurve) vvcurveto) hhcurveto)rR callgsubrrS vhcurveto hvcurveto)r rignore))r rtand))r r7or))r rynot))r rstore))r abs))r radd))r rsub)r r div))r load))r rneg))r rFeq))r rdrop))r rput))r rget))r rifelse))r rrandom))r rmul))r rsqrt))r rdup))r rQexch))r rRr))r rSroll))r "hflex))r #flex))r $hflex1))r %flex1c|dkrtd}td}n1|dkrd}td}n|dksJtd}d}|ttjtj|fd}|S)NcffrQrRt1rPt2cd|cxkrdkrnn||dz}nd|cxkrdkr)nn&|dz }||dz dz||dzz}nd |cxkrd kr*nn'| dz }||dz d z||dzz}nf| d |cxkrd krnn||d|z}nD|3td|d|d|z}n||d|z}|S)Nikrr$krr"rPiir*iir-zk4-byte T2 number got passed to the IntType handler. This should happen only when reading in old XML files. r6)logwarning)r fourByteOprpackr1 twoByteOpcodes r encodeIntz getIntEncoder..encodeInts 5    C     753;''DD E ! ! ! !T ! ! ! ! !CKE7EQJ#-..1F1FFDD e # # # #t # # # # #FSLE7EQJ#-..1F1FFDD  "v'?'?'?'?%'?'?'?'?'?ttD%000DD   KK#    73<<$$tU"3"33DDT5 1 11D r )rr0rr1)formatrrrs r getIntEncoderrs BKK R[[ 4 S\\ ~~~~BKK   [} ####J r rrrcxt|d}|dzdkrt|dz Sd|d|zS)z For T2 onlyr:r;irr6)r encodeIntT2)frrs r encodeFixedrsL " - - -E v~5B;'''dE****r rFc6|dkrtSd|z}|dddkr |dd}n|dddkrd|ddz}n|d r:|d }d |t|t|z fz}n|d }|d }|dkr_|dkrY|d|}||dz|}t ||dzd}|t|z }|dkr||d }nd|||fz}|drA|d d\} }d| |d t|fz}g} |r|d} |dd}| d krL|dd} | dkr |dd}d} n| dkr |dd}|d r |dd}| t| || dt| dzr| dtd} tdt| dD])}| t| |dz| |dzzz} *| S)Ngz%.8Gr.z0.rrtz-0.ra000rTz%sE%dr^r_z%s%sE%d)z.0z-.0z%s%sE-%drr`+rFrSr7) realZeroBytesendswithrstriprifindint startswithsplitlstripappendrealNibblesDictrrange)rssignificantDigitsdotIndexeIndex integerPartfractionalPartexponent newExponentsignnibblescc2drds r encodeFloatr sCxx  A!u}} abbE 2A2% !ABB%K E  KHHSMM (#a&&37H3I3I*IJ J66#;; r>>fllIXI,Kx!|f45N1VaZ\\?++H"S%8%88Ka*{NNN;nk JJ||M""7''#q//a $ s1vv6 6G + aD abbE 882A2BSyyabbEsabbE||C   abbEq)*** + NN3 7||as A 1c'llA & &::  a'!a%.899 9 Hr ceZdZdS)CharStringCompileErrorN)__name__ __module__ __qualname__rr rrr?sDr rceZdZd,dZdZdddZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZeZdZdZdZdZdZdZdZdZdZdZdZdZdZ d Z!d!Z"d"Z#d#Z$d$Z%d%Z&d&Z'd'Z(d(Z)d)Z*d*Z+d+Z,dS)-SimpleT2DecompilerNc||_t||_||_t||_||_||_|dSr?) localSubrs calcSubrBias localBias globalSubrs globalBiasprivateblenderreset)rrr r r s r__init__zSimpleT2Decompiler.__init__DsN$%j11&&{33   r cZg|_g|_d|_d|_d|_d|_dSNr) callingStack operandStack hintCount hintMaskBytes numRegionsvsIndexrs rrzSimpleT2Decompiler.resetMs3 r  pushToStackc|j||}|r g}|j}nd}| |jj}d} ||\}}}|nd|||rKd|z} t || d} | | |} | r| \} }|| n |n |||r|||jd=dS)NcdSr?r)xs rz,SimpleT2Decompiler.execute..\sdr rTop_r)rrneedsDecompilationrgetTokengetattrpopall setProgram) r charStringrr program pushToProgramrtoken isOperator handlerNamehandlerrvrs rexecutezSimpleT2Decompiler.executeUs@   ,,,'::<<  +G#NMM*NM  +2K #'1':':5'A'A $E:u} M%  ##em !$ T::& B5/1, u% m444KKMMMM E"""! #"  +  ! !' * * *  b ! ! !r c0|jd}|jd=|SNrrrrs rpopzSimpleT2Decompiler.popus!"%  b ! r c<|jdd}g|jdd<|Sr?r0rstacks rr#zSimpleT2Decompiler.popallzs)!!!!$!!!! r c:|j|dSr?)rrr1s rpushzSimpleT2Decompiler.pushs   '''''r c|jrdSdSr?r0rrs r op_returnzSimpleT2Decompiler.op_returns    D  r cdSr?rr9s r op_endcharzSimpleT2Decompiler.op_endchar r cdSr?rr9s r op_ignorezSimpleT2Decompiler.op_ignorer=r c|}|j||jz}||dSr?)r2rr r-rr subrIndexsubrs r op_callsubrzSimpleT2Decompiler.op_callsubrs:HHJJ y4>9: Tr c|}|j||jz}||dSr?)r2r r r-rAs r op_callgsubrzSimpleT2Decompiler.op_callgsubrs;HHJJ  DO ;< Tr c.|dSr? countHintsr9s rop_hstemzSimpleT2Decompiler.op_hstem r c.|dSr?rHr9s rop_vstemzSimpleT2Decompiler.op_vstemrKr c.|dSr?rHr9s r op_hstemhmzSimpleT2Decompiler.op_hstemhmrKr c.|dSr?rHr9s r op_vstemhmzSimpleT2Decompiler.op_vstemhmrKr c|js&||jdzdz|_|jd||j\}}||fS)Nrrr)rrIrrgetBytes)rrrs r op_hintmaskzSimpleT2Decompiler.op_hintmasksa! ; OO   "&.1"4!:D #04==eTEWXX ue##r cl|}|jt|dzz|_dSNr.)r#rrirargss rrIzSimpleT2Decompiler.countHintss+{{}}#d))q.8r ctr?r@r9s rop_andzSimpleT2Decompiler.op_and!!r ctr?rZr9s rop_orzSimpleT2Decompiler.op_orr\r ctr?rZr9s rop_notzSimpleT2Decompiler.op_notr\r ctr?rZr9s rop_storezSimpleT2Decompiler.op_storer\r ctr?rZr9s rop_abszSimpleT2Decompiler.op_absr\r ctr?rZr9s rop_addzSimpleT2Decompiler.op_addr\r ctr?rZr9s rop_subzSimpleT2Decompiler.op_subr\r ctr?rZr9s rop_divzSimpleT2Decompiler.op_divr\r ctr?rZr9s rop_loadzSimpleT2Decompiler.op_loadr\r ctr?rZr9s rop_negzSimpleT2Decompiler.op_negr\r ctr?rZr9s rop_eqzSimpleT2Decompiler.op_eqr\r ctr?rZr9s rop_dropzSimpleT2Decompiler.op_dropr\r ctr?rZr9s rop_putzSimpleT2Decompiler.op_putr\r ctr?rZr9s rop_getzSimpleT2Decompiler.op_getr\r ctr?rZr9s r op_ifelsezSimpleT2Decompiler.op_ifelser\r ctr?rZr9s r op_randomzSimpleT2Decompiler.op_randomr\r ctr?rZr9s rop_mulzSimpleT2Decompiler.op_mulr\r ctr?rZr9s rop_sqrtzSimpleT2Decompiler.op_sqrtr\r ctr?rZr9s rop_dupzSimpleT2Decompiler.op_dupr\r ctr?rZr9s rop_exchzSimpleT2Decompiler.op_exchr\r ctr?rZr9s rop_indexzSimpleT2Decompiler.op_indexr\r ctr?rZr9s rop_rollzSimpleT2Decompiler.op_rollr\r c|jdkr|j|_|}||jdzz}|j|j||z d=dSt |j|z }||zx}}||krV||jz}|j||}||j|} |j|xx| z cc<|}|dz }||kVg|j|d<dSNrr)rr  getNumRegionsr2r rrir) rr numBlendsnumOpsargiend_argstupleinext_tideltasdeltas rop_blendzSimpleT2Decompiler.op_blends" ?a  "l88::DOHHJJ do12 < !9$%''t())F2D $y 0 0Hv// 4?2*6'>: T\6::!$'''50'''   //,.D hii ( ( (r cz|}||_|j||_dSr?)r2rr rr)rrvis r op_vsindexzSimpleT2Decompiler.op_vsindexs1 XXZZ ,44R88r NN)-rrrrrr-r2r#r7r:r<r?rDrFrJrMrOrQrT op_cntrmaskrIr[r^r`rbrdrfrhrjrlrnrprrrtrvrxrzr|r~rrrrrrrr rrrCs26"""""@  (((        $$$K999 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""...*99999r r)rqrsrvrxr{r~r)r closepathrr)rhsbwrrrrr)r dotsection))r rvstem3))r r.hstem3))r r|seac))r rsbwr))r r: callothersubr))r r2))r !setcurrentpointceZdZfdZxZS)T2StackUseExtractorcbdfd}t||S)Nrcj|ttjdSr?)rrmaxri)r maxStackUsers rrz0T2StackUseExtractor.execute..pushToStack0s8   $ $U + + +k3t/@+A+ABBKKKr r)superr-)rr%rr __class__s` @rr-zT2StackUseExtractor.execute-sP  C C C C C C  <<<r )rrrr- __classcell__rs@rrr+s8         r rcFeZdZ d dZdZd dZdZdZdZd Z d Z dS) T2WidthExtractorNc^t|||||||_||_dSr?)rr nominalWidthX defaultWidthX)rrr rrr r s rrzT2WidthExtractor.__init__:s6 ##D*k7GTTT**r cVt|d|_d|_dSr)rrgotWidthwidthrs rrzT2WidthExtractor.resetGs(  &&&  r rc|}|jsY|t|dzz r1|j Jd|j|dz|_|dd}n |j|_d|_|S)Nr.z5CFF2 CharStrings must not have an initial width valuerr)r#rrirrr)revenOddrXs r popallWidthzT2WidthExtractor.popallWidthLs{{}}} #d))a-( 0&22J322!/$q'9 ABBx!/ DM r cl|}|jt|dzz|_dSrV)rrrirWs rrIzT2WidthExtractor.countHints[s/!!#d))q.8r c.|dSr?rr9s r op_rmovetozT2WidthExtractor.op_rmoveto_ r c0|ddSNrrr9s r op_hmovetozT2WidthExtractor.op_hmovetob r c0|ddSrrr9s r op_vmovetozT2WidthExtractor.op_vmovetoerr c.|dSr?rr9s rr<zT2WidthExtractor.op_endcharhrr rr) rrrrrrrIrrrr<rr rrr9s + + + +    999r rcVeZdZ d6dZdZfdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ d Z!d!Z"d"Z#d#Z$d$Z%d%Z&d&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6xZ7S)7T2OutlineExtractorNc bt|||||||||_d|_dSr)rrpen subrLevel)rrrr rrr r s rrzT2OutlineExtractor.__init__msE !!          r cdt|d|_d|_d|_dS)Nrrr)rr currentPoint sawMoveTorrs rrzT2OutlineExtractor.resets0t$$$"r c|xjdz c_t||xjdzc_|jdkr|dSdSNrr)rrr-endPath)rr%rs rr-zT2OutlineExtractor.executes_ !  ### ! >Q   LLNNNNN  r cT|j\}}||dz||dzf}||_|Sr)r)rpointrys r _nextPointzT2OutlineExtractor._nextPoints5 1E!H a%(l*! r cn|j||d|_dSr)rmoveTorrrrs rrMoveTozT2OutlineExtractor.rMoveTos- ..///r c|js|d|j||dSNr)rrrlineTorrs rrLineTozT2OutlineExtractor.rLineTosD~ ! LL  ../////r c|js|d|j}|j||||||dSr)rrrrcurveTo)rpt1pt2pt3 nextPoints rrCurveTozT2OutlineExtractor.rCurveTos]~ ! LL O  333HHHHHr cT|jr|jd|_dSr)rr closePathrs rrzT2OutlineExtractor.closePaths+ > ! H   r c@|jr|dSdSr?)rrrs rrzT2OutlineExtractor.endPaths. >  NN       r c||||dSr?rrrr9s rrzT2OutlineExtractor.op_rmovetos3  T%%''(((((r c|||dddfdSrrr9s rrzT2OutlineExtractor.op_hmovetos?  d&&q))!,a011111r c||d|ddfdSrrr9s rrzT2OutlineExtractor.op_vmovetos?  a))!,,Q/011111r c ||}|r[ddlm}|\}}}}||}|j|d||} |j| dddd||fdSdS)NrStandardEncodingrrrrrrr)rr$fontTools.encodings.StandardEncodingrr addComponent) rrrXradxadybcharachar baseGlyph accentGlyphs rr<zT2OutlineExtractor.op_endchars !!  G M M M M M M&* "CeU(/I H ! !)-? @ @ @*51K H ! !+1aC/E F F F F F G Gr c|}tdt|dD]$}|||dz}||%dS)Nrr.)r#rrir)rrrXrdrs r op_rlinetozT2OutlineExtractor.op_rlinetos`{{}}q#d))Q''  AQUOE LL      r c0|ddSralternatingLinetor9s r op_hlinetozT2OutlineExtractor.op_hlineto q!!!!!r c0|ddSrrr9s r op_vlinetozT2OutlineExtractor.op_vlinetorr c|}tdt|dD]3}|||dz\}}}}}} |||f||f|| f4dS)z${dxa dya dxb dyb dxc dyc}+ rrcurvetorr|N)r#rrir) rrrXrddxadyadxbdybdxcdycs r op_rrcurvetozT2OutlineExtractor.op_rrcurvetos{{}}q#d))Q'' > >AQQY  MM3*sCj3* = = = = > >r c|}tdt|dz dD]3}|||dz\}}}}}} |||f||f|| f4||dddS)z-{dxa dya dxb dyb dxc dyc}+ dxd dyd rcurvelinerr.r|N)r#rrirr) rrrXrdrrrrdxddyds r op_rcurvelinez T2OutlineExtractor.op_rcurvelines{{}}q#d))a-++ > >A+/AE ? (Cc3S MM3*sCj3* = = = = T"##Yr c |}|dd}tdt|dD]"}||||dz#|dd\}}}}} } |||f||f| | fdS)z-{dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurveNirr.)r#rrirr) rrrXlineArgsrdrrrrr r s r op_rlinecurvez T2OutlineExtractor.op_rlinecurves{{}}9q#h--++ . .A LL!a!e), - - - -'+BCCy$S#sC sCj3*sCj99999r c |}t|dzr|d}|dd}nd}tdt|dD]3}|||dz\}}}}|||f||fd|fd}4dS)z!dx1? {dya dxb dyb dyc}+ vvcurvetor.rrNr7r#rirr) rrrXdx1rdrrrrs r op_vvcurvetozT2OutlineExtractor.op_vvcurvetos{{}} t99q= q'C8DDCq#d))Q''  A!%a!a%i Cc3 MM3*sCj1c( ; ; ;CC  r c |}t|dzr|d}|dd}nd}tdt|dD]3}|||dz\}}}}|||f||f|dfd}4dS)z!dy1? {dxa dxb dyb dxc}+ hhcurvetor.rrNr7r) rrrXdy1rdrrrrs r op_hhcurvetozT2OutlineExtractor.op_hhcurvetos{{}} t99q= q'C8DDCq#d))Q''  A!%a!a%i Cc3 MM3*sCj3( ; ; ;CC  r c|}|r0||}|r||}|.dSdS)zdy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto N)r#vcurvetohcurvetorrrXs r op_vhcurvetozT2OutlineExtractor.op_vhcurveto*a{{}} +==&&D +}}T** + + + + +r c|}|r0||}|r||}|.dSdS)zpdx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf? N)r#rrrs r op_hvcurvetozT2OutlineExtractor.op_hvcurveto4rr c|\}}}}}}}dx} x} x} } | } ||| f||f|| f||| f|| f|| fdSrr#r)rrrdx2dy2dx3dx4dx5dx6rdy3dy4dy6dy5s rop_hflexzT2OutlineExtractor.op_hflexAs,0KKMM)S#sCc !!!c!C#d sCj3*sCj999 sCj3*sCj99999r c |\ }}}}}}}} } } } } }|||f||f||f||| f| | f| | fdSr?r )rrrrr!r"r#r'r$r(r%r*r&r)fds rop_flexzT2OutlineExtractor.op_flexHstIMFS#sCc3S#sB sCj3*sCj999 sCj3*sCj99999r c |\ }}}}}}}} } dx} } ||z| z| z| z } |||f||f|| f||| f|| f| | fdSrr )rrrrr!r"r#r$r%r*r&r'r(r)s r op_hflex1zT2OutlineExtractor.op_hflex1Ms6:kkmm3S#sCc3 cc C#%+, sCj3*sCj999 sCj3*sCj99999r c H|\ }}}}}}}} } } } ||z|z|z| z} ||z|z| z| z}t| t|kr| }| }n| }| }|||f||f||f||| f| | f||fdSr?)r#rr)rrrrr!r"r#r'r$r(r%r*d6dxdyr&r)s rop_flex1zT2OutlineExtractor.op_flex1Us?C{{}}<S#sCc3S" 3Y_s "S ( 3Y_s "S ( r77SWW  C#CC#CC sCj3*sCj999 sCj3*sCj99999r ctr?rZr9s rr[zT2OutlineExtractor.op_andcr\r ctr?rZr9s rr^zT2OutlineExtractor.op_orfr\r ctr?rZr9s rr`zT2OutlineExtractor.op_notir\r ctr?rZr9s rrbzT2OutlineExtractor.op_storelr\r ctr?rZr9s rrdzT2OutlineExtractor.op_absor\r ctr?rZr9s rrfzT2OutlineExtractor.op_addrr\r ctr?rZr9s rrhzT2OutlineExtractor.op_subur\r c|}|}||z}||z }||kr||dS||dSr?)r2r7)rrnum2num1d1d2s rrjzT2OutlineExtractor.op_divxs]xxzzxxzz T\ D[ 88 IIbMMMMM IIbMMMMMr ctr?rZr9s rrlzT2OutlineExtractor.op_loadr\r ctr?rZr9s rrnzT2OutlineExtractor.op_negr\r ctr?rZr9s rrpzT2OutlineExtractor.op_eqr\r ctr?rZr9s rrrzT2OutlineExtractor.op_dropr\r ctr?rZr9s rrtzT2OutlineExtractor.op_putr\r ctr?rZr9s rrvzT2OutlineExtractor.op_getr\r ctr?rZr9s rrxzT2OutlineExtractor.op_ifelser\r ctr?rZr9s rrzzT2OutlineExtractor.op_randomr\r ctr?rZr9s rr|zT2OutlineExtractor.op_mulr\r ctr?rZr9s rr~zT2OutlineExtractor.op_sqrtr\r ctr?rZr9s rrzT2OutlineExtractor.op_dupr\r ctr?rZr9s rrzT2OutlineExtractor.op_exchr\r ctr?rZr9s rrzT2OutlineExtractor.op_indexr\r ctr?rZr9s rrzT2OutlineExtractor.op_rollr\r c~|}|D]%}|r|df}nd|f}||| }&dSr)r#r)r isHorizontalrXargrs rrz$T2OutlineExtractor.alternatingLinetos`{{}} , ,C !aC LL   ++LL  , ,r c|dd\}}}}|dd}t|dkr |d}g}nd}|d|f||f||f|SNr7rrrir)rrXrrrrrs rrzT2OutlineExtractor.vcurvetosp!"1"XS#sABBx t99>>q'CDDC q#hc S#J777 r c|dd\}}}}|dd}t|dkr |d}g}nd}||df||f||f|SrTrU)rrXrrrrrs rrzT2OutlineExtractor.hcurvetosp!"1"XS#sABBx t99>>q'CDDC sAhc S#J777 r r)8rrrrrr-rrrrrrrrrr<rrrrr rrrrrr+r.r0r5r[r^r`rbrdrfrhrjrlrnrprrrtrvrxrzr|r~rrrrrrrrrs@rrrlsH,  000 III  6)))222222 G G G"   """""" > > >   :::      ++++++:::::: ::: : : :""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ,,,          r rceZdZdZdZdZddZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdS)T1OutlineExtractorcJ||_||_|dSr?)rsubrsr)rrrZs rrzT1OutlineExtractor.__init__s!  r cdd|_d|_d|_t|dSr)flexingrsbxrrrs rrzT1OutlineExtractor.resets1    &&&&&r cT|jr|jd|_dSr)rrrrs rrzT1OutlineExtractor.endPaths+ >  H     r rc*|Sr?r#)rrs rrzT1OutlineExtractor.popallWidth{{}}r cB|j}|d|dc|d<|d<dS)Nr rr0r4s rrzT1OutlineExtractor.exchs*!$Ry%)b 5999r c|jrdS|||dSr?)r\rrr#r9s rrzT1OutlineExtractor.op_rmovetos> <  F  T[[]]#####r c|jr|ddS|||ddfdSr)r\r7rrr#r9s rrzT1OutlineExtractor.op_hmovetosW <  IIaLLL F  dkkmmA&*+++++r c|jr+|d|dS||d|dfdSr)r\r7rrrr#r9s rrzT1OutlineExtractor.op_vmovetosd <  IIaLLL IIKKK F  aq)*+++++r c.|dSr?)rr9s r op_closepathzT1OutlineExtractor.op_closepaths r cJ|}|\}}||f|_dSr?)r#r)rrrXrrs rop_setcurrentpointz%T1OutlineExtractor.op_setcurrentpoints*{{}}1qDr c.|dSr?)rr9s rr<zT1OutlineExtractor.op_endchar s r cx|\}}||_||_||jdf|_dSr)r#rr]r)rrr]wxs rop_hsbwzT1OutlineExtractor.op_hsbw s<++--R !21!55r c.|dSr?r`r9s rop_sbwzT1OutlineExtractor.op_sbw r cr|}|j|}||dSr?)r2rZr-rAs rrDzT1OutlineExtractor.op_callsubrs3HHJJ z)$ Tr c|}|}|dkr#|dkr|d|_dS|dkr|dkr d|_dSdSdS)Nrrtr)r2doFlexr\)rrrBnArgss rop_callothersubrz#T1OutlineExtractor.op_callothersubrslHHJJ   >>eqjj KKMMMDLLL !^^ DLLL^ r cdSr?rr9s rop_popzT1OutlineExtractor.op_pop'r=r cZ|}|}||}|}|}|}|}|}|} |} |} |} |} |}|}|}|||z|| |z|| || || || |d|||||||||||||d||||dSr?)r2r7r)rfinalyfinalxp3yp3xbcp4ybcp4xbcp3ybcp3xp2yp2xbcp2ybcp2xbcp1ybcp1xrpyrpxs rrszT1OutlineExtractor.doFlex*s   hhjjhhjj    hhjjhhjj    hhjjhhjj %#+ %#+ % % # # $ % % % % # # $ & &r c.|dSr?r`r9s r op_dotsectionz T1OutlineExtractor.op_dotsectionTrpr c.|dSr?r`r9s r op_hstem3zT1OutlineExtractor.op_hstem3Wrpr c ddlm}|\}}}}}||}|j|d||} ||jz|z }|j| dddd||fdS)zasb adx ady bchar achar seacrrrrN)rrr#rrr]) rrrasbrrrrrrs rop_seaczT1OutlineExtractor.op_seacZsIIIIII&*kkmm#S#ue$U+  i);<<<&u- DHns" kAq!QS+ABBBBBr c.|dSr?r`r9s r op_vstem3zT1OutlineExtractor.op_vstem3erpr Nr)rrrrrrrrrrrrgrir<rmrorDrurwrsrrrrrr rrXrXsX '''  444$$$ ,,,,,,!!! 666     (((T C C Cr rXceZdZeZee\ZZe Z e Z ddZ ddZdZdZdZdZddZd Zdd Zd Zd ZdZeeefdZdZdZddZdZ dS) T2CharStringNc\|g}||_||_||_||ng|_d|_dSr?)bytecoder&r r  _cur_vsindex)rrr&r r s rrzT2CharString.__init__os@ ?G    *5*A;;r r c|j}|J|||_n%|jt|dr|jnd|_||jS)Nrr)r rhasattrrr)rrpds rrzT2CharString.getNumRegionsxs` \~~~   'D     &.5b).D.D K !D  1222r c|jd|jjt|fzSd|jjt|fzS)Nz<%s (source) at %x>z<%s (bytecode) at %x>)rrridrs r__repr__zT2CharString.__repr__s@ = (DN,CRXX+NN N*dn.Er$xx-PP Pr ctSr?)rrs rrzT2CharString.getIntEncoderr ctSr?)rrs rgetFixedEncoderzT2CharString.getFixedEncoderrr c|sdSt|jdg}|||j|j}||dSNSubrs)r r"r decompilerClassr r-)rrZ decompilers r decompilezT2CharString.decompilesd&&((  F gr22))%1A4<PP 4     r c t|jdg}||||j|jj|jj|j|}|||j|_dSr)r"r outlineExtractorr rrr-r)rrr rZ extractors rdrawzT2CharString.drawsq gr22))     L & L & L    $_ r cXt|}|||jSr?)r rbounds)rglyphSet boundsPens r calcBoundszT2CharString.calcBoundss*h''  )r Fc|jdS|j}|j}|r|r|ddvr |dd}n,|r*t|dtst dg}|}|}d}t|}||kr||} |dz}t| trl | d|| Dn #t$rt d| zwxYw| dvr | |||dz}nt| tr| || nNt| tr| || nJd t| z||k t|}n)#t $rt"|wxYw||dS) Nr)rrz@T2CharString or Subr has items on the stack after last operator.rrc34K|]}t|VdSr?)r)rcrJs r z'T2CharString.compile..s(#G#G1GAJJ#G#G#G#G#G#Gr zillegal operator: %srrzunsupported type: %s)ropcodesr&rjstrrrrriextendrrrrHtyper TypeErrorrerror setBytecode) risCFF2rr&rrrrdendr(s rcompilezT2CharString.compilesU = $ F,,   '72;*???!#2#,  Z S99 (R &&(( **,, 'll#ggAJEAA%%% ?QOO#G#G#G#G#GGGGGQQQ01G%1OPPPQ444OOGAJ///AAE3'' ? % 0 01111E5)) ? E 2 23333>04;;>>>q!#gg"  **HH    IIh      """""s%C((D7G&G-c|jduSr?)rrs rr zT2CharString.needsDecompilations}D((r c"||_d|_dSr?)r&r)rr&s rr$zT2CharString.setPrograms  r c"||_d|_dSr?)rr&)rrs rrzT2CharString.setBytecodes   r c6|jU|||jkrdS||j|}|dz}|j|}||||j|\}}n(|||jkrdS|j|}|dz}||t}|||fS)N)Nrrr)roperandEncodingr&r) rrrirrjrr+r(r)s rr!zT2CharString.getTokens = $DM****!zu-..BAIE*2.G"74T]EBBLE55DL))))!zL'EAIEZs++ j%''r c|j||z}|j||}|}n|j|}|dz}t||ksJ||fSr)rr&ri)rrnBytesnewIndexbytess rrSzT2CharString.getBytess` = $v~HM%.1EEEL'EAIE5zzV####e|r c|Sr?r)rrs rrzT2CharString.handle_operatorsr cddlm}|j||jdSd}g} ||\}}}|n|r|dvrv||\}}}g} |D].} | |t | d/t| }d|||gz} nd||gz} | | | g}nKt|trt|d}nt|}||+|r,d|} | | dSdS) Nr) num2binaryTrr r:r;)fontTools.misc.textToolsrrdumphexr!rrr joinwritenewlinerjrHrr) r xmlWriterttFontrrrXr(r)hintMaskbitsbytelines rtoXMLzT2CharString.toXMLs777777 = $   dm , , , , ,ED '+/==+?+?(z5=' 8886:mmE6J6J3*e!$,FFD KK 74==!(D(DEEEE#*4=="xxx/@(@AA"xxw77OOD)))%%'''DD!%//+ 1%r J J J #E KK&&&- '. &xx~~%%%%%  & &r c 0ddlm}m}|dr |||dSt |}|}g}t|}d}||kr||} |dz} t| } | | n#t$r t| d} | | n#t$r| | | dvrk||} d} tdt| d D](} | t|| | | d zz} )| | |dz}YnwxYwYnwxYw||k||dS) Nr) binary2numreadHexrawrr:r;rr r)rrrrrr rrirr ValueErrorrrrr$) rnameattrscontentrrr&rrdr(mask maskBytesjs rfromXMLzT2CharString.fromXML"s@@@@@@@@ 99U      WWW-- . . . F'""--//'ll #ggAJEAA &E  u%%%% * * * *-e2FFFENN5))))""""NN5))) 888&qz$' !&q#d))Q!7!7YYA(1GJJtAPQTUPUI.encodeFixedQsVWW Wr r)rrs rrzT1CharString.getFixedEncoderPs  X X X X Xr c|jdSg}d} ||\}}}|n||2||dSr)rr!rr$)rr&rr(r)s rrzT1CharString.decompileTso = F "'+}}U';'; $E:u} NN5 ! ! !  "      r crt||j}|||j|_dSr?)rXrZr-r)rrrs rrzT1CharString.draw`s4&sDJ77 $_ r )NNN)rrrt1OperandEncodingrrp t1Operatorsrrrrrrrrrs@rrrEs'O**;77IwXXX ! ! !%%%%%%%r rc\eZdZeZddZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdS)DictDecompilerNc>g|_||_i|_||_dSr?)r5stringsdictparent)rrrs rrzDictDecompiler.__init__is"    r cTt|jdks Jd|jS)Nrznon-empty stack)rir5rrs rgetDictzDictDecompiler.getDictos,4:!###%6###yr cd}t|}|jj}||krMt||}|dz}|j|}|||||\}}| ||||kKdSdSr)rir5rrr)rrrlenDatar7rr+rs rrzDictDecompiler.decompilessd))z gooe%%BAIE*2.G"74T599LE5 U goooooor c0|jd}|jd=|Sr/r5r1s rr2zDictDecompiler.pops 2 JrN r c8|jdd}|jdd=|Sr?rrWs rr#zDictDecompiler.popalls#z!!!} JqqqM r cp|\}}t|trQd}tt|dz ddD],}||}t |d|z}||f|z}-nt |d|z}||}|dkr|j|dS||j|<dS)Nrrrarg_r)rjrkrrir"r5rr)rrargTyperrdrR arghandlers rrzDictDecompiler.handle_operators$' gu % % )E3w<r)s JIIIIIIIIIII...... g!!   222 333   <<< !!!    FSL-0!B$%)4"S&'N+;;#c''N+;;#c'%# s $$$$%aaa(%"'#*111-)r,r+s "<;IIk$:$:;;;     888 v111h}U## mD!! mD!!  ++++ ggcll* 1 1 1 h     Y   G9G9G9G9G9G9G9G9T <     ,   00000)000faaaaa)aaaH VVVVV+VVVrY!Y!Y!Y!Y!6Y!Y!Y!x%%%%%<%%%BvvvvvVvvvrr