L i/DddlmZmZmZdZGddeZGddeZdZdZ Gd d eZ Gd d eZ d Z dZ dddefdZdZdZy))SimpleT2DecompilerT2WidthExtractor calcSubrBiasc*tt|SN)sortedset)ls a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/cffLib/transforms.py _uniq_sortr s #a&>c eZdZy)StopHintCountEventN)__name__ __module__ __qualname__r r rr sr rc<eZdZdZd dZdZdZdZdZdZ d Z y) _DesubroutinizingT2Decompiler) op_hintmask op_cntrmask op_rmoveto op_hmoveto op_vmovetoNc4tj||||yr)r__init__)self localSubrs globalSubrsprivates r rz&_DesubroutinizingT2Decompiler.__init__s##D*k7Kr cd|_|jD]}t|||jt |dr1|jr$|j r t j||yyg|_ t j|||jdd}t|jD]R\}}|dk\sJ||dz dvs J||dz t||dz tk(sJ|ddk(r|dd}|||dz |T|jjsd|vr|d|j!ddz}||_|` y#t$r|j d=YywxYw) NT_desubroutinized)callsubr callgsubrreturnendchar)need_hintcountstop_hintcount_opssetattrstop_hint_counthasattr callingStackrexecuter_patchesprogramreversedtypeintr in_cff2indexr")r charStringop_namedesubroutinizedidx expansions r r0z%_DesubroutinizingT2Decompiler.executes".. 9G D'4#7#7 8 9 :1 2 ""t'8'8.&..tZ@  ""44$,,Q/&z':':; 7NC!8O8"37+0 (sQw' (a01S8 88}(%crN -6OC!Gc * 7||##O+"1:o++I6:#'6 #  3*.))"- .sD>>EEc|j|jd|jz}tj|||j ||yNr#)r operandStack localBiasr op_callsubr processSubrrr7subrs r rAz)_DesubroutinizingT2Decompiler.op_callsubrDsDt004t~~EF&&tU3 %r c|j|jd|jz}tj|||j ||yr>)rr? globalBiasr op_callgsubrrBrCs r rGz*_DesubroutinizingT2Decompiler.op_callgsubrIsF 1 1" 5 GH''e4 %r cd|_|jD]}t||d|jd}t |dr t y)NFr#r")r*r+r,r/r.r)rargsr9css r r-z-_DesubroutinizingT2Decompiler.stop_hint_countNsT#.. )G D'4 ( )   r " 2) *$& & +r cjtj|||jr|jyyr)rrr*r-rr7s r rz)_DesubroutinizingT2Decompiler.op_hintmaskVs,&&tU3     " r c|jd}t|ds(|jj||jfyy)Nr#r")r/r.r1appendr")rr7rDrJs r rBz)_DesubroutinizingT2Decompiler.processSubr[s?   r "r-. KK  t'<'<= >/r r) rrrr+rr0rArGr-rrBrr r rrs/L& P& & '# ?r rc|jt|jdg}t||j|j}|j ||j |_|`y)z%Desubroutinize a charstring in-place.SubrsN) decompilegetattrr rrr0r"r2)rJsubrs decompilers r desubroutinizeCharStringrUasTLLN BJJ ,E.ubnnbjjQJr$$BJ r c|jD]}||}|j}|jD] }t|t |drH|j D]8}|j }t |dr|`d|jvs,|jd=:|j }t |dr|`d|jvs|jd=|jjy)NFDArrayrP) fontNames CharStringsvaluesrUr.rWPrivaterPrawDict GlobalSubrsclear)cfffontNamefontrJcfdpds r desubroutinizereksMM(8}    (A $Q ' ( 4 #ll ,ZZ2w'bjj( 7+  ,Br7#H"**$JJw'%((OOr ceZdZdZdZdZy)_MarkingT2Decompilerctj||||||fD]!}|st|drt|_#y)N_used)rrr.r ri)rrrr rSs r rz_MarkingT2Decompiler.__init__s?##D*k7K +. $EWUG4!e  $r c|jjj|jd|jzt j ||yr>)rriaddr?r@rrArLs r rAz _MarkingT2Decompiler.op_callsubrs> !!$"3"3B"7$.."HI&&tU3r c|jjj|jd|jzt j ||yr>)rrirkr?rFrrGrLs r rGz!_MarkingT2Decompiler.op_callgsubrs@ ""4#4#4R#84??#JK''e4r N)rrrrrArGrr r rgrgs$ 45r rgcteZdZGddeZ ddZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZy)_DehintingT2DecompilerceZdZdZy)_DehintingT2Decompiler.HintscXd|_d|_d|_d|_d|_g|_y)NFr)has_hint last_hint last_checkedstatus has_hintmask deletions)rs r rz%_DehintingT2Decompiler.Hints.__init__s4 "DMDN!"D DK %D DNr N)rrrrrr r Hintsrps  . r rxNcR||_tj|||||||_yr)_cssrrr )rcssrr nominalWidthX defaultWidthXr s r rz_DehintingT2Decompiler.__init__s- !! *k=-  r cVt|dr |jnd}|j|_tj|||j}|j s |j r|jj||jdk7rxt|jt|jdz D]/}t|j|tr d|_ n d|_ 1t|j|_ |r|j |j k(sJyy)N_hintsr$r%)r.rrxrr0rrrvrzrkrurangertlenr2 isinstancestr__dict__)rr8 old_hintshintsis r r0z_DehintingT2Decompiler.executes)0X)FJ%%D  JJL   z2!! >>U// IIMM* % <<1 5--s:3E3E/F/JK %j003S9#$EL#$EL  % "%Z%7%7!8E  >>Y%7%77 77 r c|j|jd|jz}tj|||j ||yr>)rr?r@rrArBrCs r rAz"_DehintingT2Decompiler.op_callsubrsDt004t~~EF$$T51 %r c|j|jd|jz}tj|||j ||yr>)rr?rFrrGrBrCs r rGz#_DehintingT2Decompiler.op_callgsubrsF 1 1" 5 GH%%dE2 %r cRtj|||j|yr)rop_hstem processHintrLs r rz_DehintingT2Decompiler.op_hstem !!$. r cRtj|||j|yr)rop_vstemrrLs r rz_DehintingT2Decompiler.op_vstemrr cRtj|||j|yr)r op_hstemhmrrLs r rz!_DehintingT2Decompiler.op_hstemhm ##D%0 r cRtj|||j|yr)r op_vstemhmrrLs r rz!_DehintingT2Decompiler.op_vstemhmrr cTtj||}|j||Sr)rrprocessHintmaskrr7rvs r rz"_DehintingT2Decompiler.op_hintmask'  ) )$ 6 U# r cTtj||}|j||Sr)rrrrs r rz"_DehintingT2Decompiler.op_cntrmaskrr c2|jd}|j}d|_|jdk7r\t |j |dz D](}t |j|ts!d|_nd|_ |dz|_ d|_|dz|_y)Nr#Tr$r%r) r/rrvrurrtrr2rrrrs)rr7rJrrs r rz&_DehintingT2Decompiler.processHintmasks   r " ! <<1 5--uqy9 !bjjmS1#$EL ! "&"'!)  "QYr cd|jd}|j}d|_||_||_y)Nr#T)r/rrrrsrt)rr7rJrs r rz"_DehintingT2Decompiler.processHints1   r " "r c,|jd}|j}|j}|jdk7rKt|j|dz D](}t |j |ts!d|_n||_|jdk7r5|jrSd|_|jdk(r||_ n5|dz |_ n*|jdk(r|jj|t|j|j|_y)Nr#r$r%Tr) r/rrurrtrr2rrrrsrwrNmax)rr7rDrJr subr_hintsrs r rBz"_DehintingT2Decompiler.processSubr s   r " [[  <<1 5--uqy9 bjjmS1#$EL "'E  <<1 ""!%$$)&+EO&+aiEO   ! # OO " "5 )5<<):):; r r)rrrobjectrxrr0rArGrrrrrrrrrBrr r rnrnsV  6SW80& &       '"#.>#>?&BRBRR a!eH r c|j}|jr.|j}t|jD] }||dz |= |jr|jr|j |jdksJ|j|j d|_|js|jj dt|dr}|j|jjk7rZ|jjJd|jjd|j|jjz |jrSd}|j}|t|kr7||dvr|dzt|ksJ|||dz=1|dz }|t|kr7t|jsJ|`y)Nr$rr)widthz5CFF2 CharStrings must not have an initial width value)hintmaskcntrmaskr%)rrwr2r3rrrsrNr.rr r}insertr|rvr)rrrr;rs r _cs_drop_hintsr6s   E    EOO, !C#'C-  ! ~~??eoo9K&KKK'//0AB !!    % %i 0 :w ':#5#5#C#CC&&44@KJK@""))z''**<*<*J*JJ     #a&jt//1uA&a!a%iL FA #a&j z!! "" "r T)removeUnusedSubrsrc |jD]O}||}|j}t}|jD]}|j t |j dg}t|||j|j j|j j|j }|j||j|_ |D] } t| ~g} t|dr#| jd|j Dn| j#|j$| D]#} dD]} t| | st'| | d%R|r t)|yy)NrPrWc34K|]}|jywr)r[.0rcs r zremove_hints..s?BRZZ?s) BlueValues OtherBlues FamilyBluesFamilyOtherBlues BlueScale BlueShiftBlueFuzz StemSnapH StemSnapVStdHWStdVW ForceBold LanguageGroupExpansionFactor)keysrYr rZrQrRr rnrr|r}r0rrr.extendrWrNr[r,remove_unused_subroutines) r_rfontnamerarJr{rbrSrTr all_privsprivks r remove_hintsr^s\HHJ<+8}    e 'A KKMAIIw3E/  '' '' J   q ! &&AG ' 'J : & '  4 #   ?$,,? ?   T\\ * +D + 4#D!T*# + +U<+z!#&r crt|dr+|jsd|jvr |jd=|`yyy)NrP)r.rPr\) private_dicts r _pd_delete_empty_subrsrs?|W%l.@.@ l** *$$W-  /A%r c|jD]9}||}|j}|jD]K}t|jdg}t ||j |j}|j|M|jg}t|dr#|jd|jDnQt|jdr;|jjr%|j|jjt}|D]a}t|dst|_t#|j |_t%||_t%|j |_c|jD]0}t|jdd}t+|||j2|D]+}||jk(rt|ds-t|jdr|jj}npt|dr_t-|jdk(rGt|jdjdr$|jdjj}nd}n|}|j D cgc]} |j.| c} |_t|dr|`t|dr|`|j.D]} t+| ||j.t|dr'|jD]} t5| jnt5|j|D]}|`|`|` <ycc} w) NrPrWc3K|]F}t|jdr.|jjr|jjHyw)rPN)r.r[rPrs r rz,remove_unused_subroutines..s<2::w/BJJ4D4D   sA Arir%rfileoffsets)rrYrZrRr rgrr0r]r.rrWr[rPrNr rir rrrrritemsrrr) r_rrarJrbrSrT all_subrs local_subrsrrDrcs r rrsHHJG>8}    "AAIIw3E-eQ]]AIINJ   q ! " %%& 4 #   ,,  T\\7 + 0B0B   T\\// 0E  8E5'*!e $U[[1EK*51EO*5;;7EO  8 ?AAIIw5E "1eT-=-= > ?  LE(((tY/GDLL'4R"&,,"4"4KD),DLL)Q. Q 7 7A#',,q/"9"9"?"?K"&K# 38;;?a5;;q>?EKuf%Jui(M  L&t[$:J:JK L- L4 4 #ll 3&rzz2 3 #4<< 0 >E U_eo >MG>j@sMN)fontTools.misc.psCharStringsrrrr ExceptionrrrUrergrnrrboolrrrrr r rs  N?$6N?b0 5- 5 S<-Sr