
    ]Mh                     X   d Z ddlmZmZmZmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlZddlZ ej        e          Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zdgdz  Zdegz  edd<   degz  edd<   degz  edd<   degz  edd<   eed<    ee          dk    sJ edd         Zeed<   eed<   edd         Zeed<   eed<   eed<   g dZd  e e          D             Z!dZ"d Z#g dZ$d Z% e%d          Z& e%d           Z' e%d!          Z(ej)        fd"Z* ed           ed#          z   Z+d$ Z, G d% d&e-          Z. G d' d(e/          Z0g d)Z1 G d* d+e0          Z2 G d, d-e2          Z3 G d. d/e3          Z4 G d0 d1e/          Z5 G d2 d3e5          Z6 G d4 d5e/          Z7d6 Z8dS )7zwpsCharStrings.py -- module implementing various kinds of CharStrings:
CFF dictionary data and Type1/Type2 CharStrings.
    )fixedToFloatfloatToFixedfloatToFixedToStrstrToFixedToFloat)bytechrbyteord	bytesjoinstrjoin)	BoundsPenNc                     |dk    r|t          ||                   f}|dz   }n|}	 | j        |         }n# t          $ r d |fcY S w xY w|                     |          }||fS )N      )r   	operatorsKeyErrorhandle_operator)selfb0dataindexopoperatorvalues          \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/misc/psCharStrings.pyread_operatorr      s    	Rxx'$u+&&'	>"%   U{  **E%<s   5 AAc                     |dz
  |fS )N    r   r   r   r   s       r   	read_byter   "   s    8U?    c                 R    t          ||                   }|dz
  dz  |z   dz   |dz   fS )N      l   r   r   r   r   r   r   b1s        r   read_smallInt1r(   &   s5    	e		BHb 3&	11r    c                 T    t          ||                   }|dz
   dz  |z
  dz
  |dz   fS )N   r#   r$   r   r%   r&   s        r   read_smallInt2r+   +   s7    	e		B#X;r!C'22r    c                 T    t          j        d|||dz                      \  }||dz   fS )N>h   structunpackr   r   r   r   r   s        r   read_shortIntr3   0   2    }T4	(9#:;;HU%!)r    c                 T    t          j        d|||dz                      \  }||dz   fS )N>l   r/   r2   s        r   read_longIntr8   5   r4   r    c                 r    t          j        d|||dz                      \  }t          |d          |dz   fS )Nr6   r7      precisionBits)r0   r1   r   r2   s        r   read_fixed1616r=   :   s?    }T4	(9#:;;HUR000%!);;r    c                 &    t           sJ t          |fS N)NotImplementedErrorNotImplementedr   s       r   read_reservedrB   ?   s    5  r    c                     d}	 t          ||                   }|dz   }|dz  dz	  }|dz  }|dk    rn(|t          |         z   }|dk    rn|t          |         z   }Vt          |          |fS )N Tr      r7      )r   realNibblesfloat)r   r   r   r   numberbnibble0nibble1s           r   read_realNumberrM   D   s    F
/DK  	t8/d(c>>+g..c>>+g..
/ ==%r    r#          r"   r7   r*               )0123456789.EE-N-c                     i | ]\  }}||	S r   r   ).0ivs      r   
<dictcomp>rf   w   s    ;;;DAq1a;;;r       c                 
   i }i }| D ]y}t          |          dk    r|d         ||d         <   n|dd          ||d         <   t          |d         t                    r|d         ||d         <   g|d         f||d         <   z||fS )Nr.   r   r   )len
isinstancetuple)operatorListoperopcitems       r   buildOperatorDictrp   |   s    D
C & &t99>> GDaMM HDaMd1gu%% 	&7CQLL G:CQLL9r    )4r   hstem   vstemr7   vmoveto   rlineto   hlineto   vlineto   	rrcurveto
   callsubr   return   endchar)rF   vsindex)r:   blend)   hstemhm)   hintmask)   cntrmask   rmoveto   hmoveto)   vstemhm)   
rcurveline)   
rlinecurve)   	vvcurveto)   	hhcurveto)rR   	callgsubrrS   	vhcurveto   	hvcurveto)r   r   ignore))r   rt   and))r   r7   or))r   ry   not))r   r   store))r   	   abs))r   r   add))r   r   sub)r   r   div))r      load))r   r   neg))r   rF   eq))r   r   drop))r   r   put))r   r   get))r   r   ifelse))r   r   random))r   r   mul))r   r   sqrt))r   r   dup))r   rQ   exch))r   rR   r   ))r   rS   roll))r   "   hflex))r   #   flex))r   $   hflex1))r   %   flex1c                     | dk    rt          d          }t          d          }n1| dk    rd }t          d          }n| dk    sJ t          d          }d }|t           t          j        t          j        |fd}|S )NcffrQ   rR   t1rP   t2c                    d| cxk    rdk    rn n || dz             }nd| cxk    rdk    r)n n&| dz
  }  || dz	  dz              || dz            z   }nd	| cxk    rd
k    r*n n'|  dz
  }  || dz	  dz              || dz            z   }nf| d| cxk    rdk    rn n| |d|           z   }nD|3t                               d            |d           |d|           z   }n| |d|           z   }|S )Nik   r   r$   k  r   r"   rP   iir*   i i  r-   zk4-byte T2 number got passed to the IntType handler. This should happen only when reading in old XML files.
r6   )logwarning)r   
fourByteOpr   packr1   	twoByteOpcodes          r   	encodeIntz getIntEncoder.<locals>.encodeInt   s    5C753;''DDE!!!!T!!!!!CKE7EQJ#-..1F1FFDDe####t#####FSLE7EQJ#-..1F1FFDD"v'?'?'?'?%'?'?'?'?'?ttD%000DD KK#  
 73<<$$tU"3"33DDT5 1 11Dr    )r   r0   r   r1   )formatr   r   r   s       r   getIntEncoderr      s    BKK	R[[

	4	S\\

~~~~BKK	
 [}# # # #J r    r   r   r   c                 x    t          | d          }|dz  dk    rt          |dz	            S d |d|          z   S )zFor T2 onlyr:   r;   i  r      r6   )r   encodeIntT2)fr   r   s      r   encodeFixedr      sL    "---Ev~5B;'''dE****r    rF   c                 6   | dk    rt           S d| z  }|d d         dk    r|dd          }n|d d         dk    rd|dd          z   }n|                    d	          r:|                    d
          }d|t          |          t          |          z
  fz  }n|                    d          }|                    d          }|dk    r_|dk    rY|d |         }||dz   |         }t          ||dz   d                    }|t          |          z
  }|dk    r||d
}nd|||fz  }|                    d          rA|                    dd          \  }	}d|	|                    d
          t          |          fz  }g }
|r|d         }|dd          }|dk    rL|d d         }|dk    r|dd          }d}n|dk    r
|dd          }|                    d
          r
|dd          }|
	                    t          |                    ||
	                    d           t          |
          dz  r|
	                    d           t          d          }t          dt          |
          d          D ])}|t          |
|         dz  |
|dz            z            z   }*|S )Ng        z%.8Gr.   z0.r   rt   z-0.ra   000rT   z%sE%dr^   r_   z%s%sE%d)z.0z-.0z%s%sE-%dr   r`   +rF   rS   r7   )realZeroBytesendswithrstripri   findint
startswithsplitlstripappendrealNibblesDictr   range)r   ssignificantDigitsdotIndexeIndexintegerPartfractionalPartexponentnewExponentsignnibblescc2drd   s                  r   encodeFloatr     s   Cxx 	
A!u}}abbE	
2A2%!ABB%K	
E		 KHHSMM(#a&&37H3I3I*IJJ66#;;r>>fllIXI,Kx!|f45N1VaZ\\?++H"S%8%88Ka*{NNN;nk JJ||M"" 7''#q//a$s1vv66G
 +aDabbE882A2BSyyabbEsabbE||C   abbEq)***  + NN3
7||a sA1c'llA&& : :
a'!a%.8999Hr    c                       e Zd ZdS )CharStringCompileErrorN)__name__
__module____qualname__r   r    r   r   r   ?  s        Dr    r   c                   
   e Zd Zd+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 Ze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  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,dS ),SimpleT2DecompilerNc                     || _         t          |          | _        || _        t          |          | _        || _        || _        |                                  d S r?   )
localSubrscalcSubrBias	localBiasglobalSubrs
globalBiasprivateblenderreset)r   r  r
  r  r  s        r   __init__zSimpleT2Decompiler.__init__D  sN    $%j11&&{33

r    c                 Z    g | _         g | _        d| _        d| _        d| _        d| _        d S Nr   )callingStackoperandStack	hintCounthintMaskBytes
numRegionsvsIndexr   s    r   r  zSimpleT2Decompiler.resetM  s3    r    c                    | j                             |           |                                }|r
g }|j        }nd }| j        j        }d}	 |                    |          \  }}}|nd ||           |rKd|z   }	t          | |	d           }
|
 |
|          }|r|\  }} ||           n |                                  n ||           |r|                    |           | j         d= d S )Nc                     d S r?   r   )xs    r   <lambda>z,SimpleT2Decompiler.execute.<locals>.<lambda>\  s    d r    r   Top_r   )r  r   needsDecompilationr  getTokengetattrpopall
setProgram)r   
charStringr  programpushToProgrampushToStackr   token
isOperatorhandlerNamehandlerrvr  s                r   executezSimpleT2Decompiler.executeU  s:     ,,,'::<< 	+G#NMM*NM'.	#'1':':5'A'A$E:u}M%    ##em!$T::& B 5/1,u%m444KKMMMME"""!	#"  	+!!'***b!!!r    c                 0    | j         d         }| j         d= |S Nr   r  r   r   s     r   popzSimpleT2Decompiler.popt  s    !"%b!r    c                 <    | j         d d          }g | j         d d <   |S r?   r/  r   stacks     r   r!  zSimpleT2Decompiler.popally  s)    !!!!$!!!!r    c                 :    | j                             |           d S r?   )r  r   r0  s     r   pushzSimpleT2Decompiler.push~  s      '''''r    c                     | j         rd S d S r?   r/  r   r   s     r   	op_returnzSimpleT2Decompiler.op_return  s     	D	 	r    c                     d S r?   r   r8  s     r   
op_endcharzSimpleT2Decompiler.op_endchar      r    c                     d S r?   r   r8  s     r   	op_ignorezSimpleT2Decompiler.op_ignore  r<  r    c                     |                                  }| j        || j        z            }|                     |           d S r?   )r1  r  r	  r,  r   r   	subrIndexsubrs       r   op_callsubrzSimpleT2Decompiler.op_callsubr  s:    HHJJ	y4>9:Tr    c                     |                                  }| j        || j        z            }|                     |           d S r?   )r1  r
  r  r,  r@  s       r   op_callgsubrzSimpleT2Decompiler.op_callgsubr  s;    HHJJ		DO ;<Tr    c                 .    |                                   d S r?   
countHintsr8  s     r   op_hstemzSimpleT2Decompiler.op_hstem      r    c                 .    |                                   d S r?   rG  r8  s     r   op_vstemzSimpleT2Decompiler.op_vstem  rJ  r    c                 .    |                                   d S r?   rG  r8  s     r   
op_hstemhmzSimpleT2Decompiler.op_hstemhm  rJ  r    c                 .    |                                   d S r?   rG  r8  s     r   
op_vstemhmzSimpleT2Decompiler.op_vstemhm  rJ  r    c                     | j         s&|                                  | j        dz   dz  | _         | j        d                             || j                   \  }}||fS )Nr   r   r   )r  rH  r  r  getBytes)r   r   r  s      r   op_hintmaskzSimpleT2Decompiler.op_hintmask  sa    ! 	;OO"&.1"4!:D#04==eTEWXXue##r    c                 l    |                                  }| j        t          |          dz  z   | _        d S Nr.   )r!  r  ri   r   argss     r   rH  zSimpleT2Decompiler.countHints  s+    {{}}#d))q.8r    c                     t           r?   r@   r8  s     r   op_andzSimpleT2Decompiler.op_and      !!r    c                     t           r?   rY  r8  s     r   op_orzSimpleT2Decompiler.op_or  r[  r    c                     t           r?   rY  r8  s     r   op_notzSimpleT2Decompiler.op_not  r[  r    c                     t           r?   rY  r8  s     r   op_storezSimpleT2Decompiler.op_store  r[  r    c                     t           r?   rY  r8  s     r   op_abszSimpleT2Decompiler.op_abs  r[  r    c                     t           r?   rY  r8  s     r   op_addzSimpleT2Decompiler.op_add  r[  r    c                     t           r?   rY  r8  s     r   op_subzSimpleT2Decompiler.op_sub  r[  r    c                     t           r?   rY  r8  s     r   op_divzSimpleT2Decompiler.op_div  r[  r    c                     t           r?   rY  r8  s     r   op_loadzSimpleT2Decompiler.op_load  r[  r    c                     t           r?   rY  r8  s     r   op_negzSimpleT2Decompiler.op_neg  r[  r    c                     t           r?   rY  r8  s     r   op_eqzSimpleT2Decompiler.op_eq  r[  r    c                     t           r?   rY  r8  s     r   op_dropzSimpleT2Decompiler.op_drop  r[  r    c                     t           r?   rY  r8  s     r   op_putzSimpleT2Decompiler.op_put  r[  r    c                     t           r?   rY  r8  s     r   op_getzSimpleT2Decompiler.op_get  r[  r    c                     t           r?   rY  r8  s     r   	op_ifelsezSimpleT2Decompiler.op_ifelse  r[  r    c                     t           r?   rY  r8  s     r   	op_randomzSimpleT2Decompiler.op_random  r[  r    c                     t           r?   rY  r8  s     r   op_mulzSimpleT2Decompiler.op_mul  r[  r    c                     t           r?   rY  r8  s     r   op_sqrtzSimpleT2Decompiler.op_sqrt  r[  r    c                     t           r?   rY  r8  s     r   op_dupzSimpleT2Decompiler.op_dup  r[  r    c                     t           r?   rY  r8  s     r   op_exchzSimpleT2Decompiler.op_exch  r[  r    c                     t           r?   rY  r8  s     r   op_indexzSimpleT2Decompiler.op_index  r[  r    c                     t           r?   rY  r8  s     r   op_rollzSimpleT2Decompiler.op_roll  r[  r    c                    | j         dk    r| j                                        | _         |                                 }|| j         dz   z  }| j        | j        ||z
   d = d S t          | j                  |z
  }||z   x}}||k     rV|| j         z   }| j        ||         }|                     | j        |          }	| j        |xx         |	z  cc<   |}|dz  }||k     Vg | j        |d <   d S Nr   r   )r  r  getNumRegionsr1  r  r  ri   r  )
r   r   	numBlendsnumOpsargiend_argstupleinext_tideltasdeltas
             r   op_blendzSimpleT2Decompiler.op_blend  s"   ?a"l88::DOHHJJ	do12<!9$%''   t())F2D $y 00Hv// 4?2*6'>:T\6::!$'''50''' 	 // ,.Dhii(((r    c                 z    |                                  }|| _        | j                            |          | _        d S r?   )r1  r  r  r  r  )r   r   vis      r   
op_vsindexzSimpleT2Decompiler.op_vsindex  s1    XXZZ,44R88r    NN)-r  r  r  r  r  r,  r1  r!  r6  r9  r;  r>  rC  rE  rI  rL  rN  rP  rS  op_cntrmaskrH  rZ  r]  r_  ra  rc  re  rg  ri  rk  rm  ro  rq  rs  ru  rw  ry  r{  r}  r  r  r  r  r  r  r   r    r   r  r  C  s            " " ">  
  
( ( (        
  
        $ $ $ K9 9 9
" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " ". . .*9 9 9 9 9r    r  )rq   rs   rv   rx   r{   r~   r   )r   	closepathr   r   )r   hsbwr   r   r   r   r   )r   
dotsection))r   r   vstem3))r   r.   hstem3))r   r|   seac))r   r   sbwr   ))r   r:   callothersubr))r      r1  ))r   !   setcurrentpointc                   F    e Zd Z	 	 ddZd ZddZd Zd Zd Zd	 Z	d
 Z
dS )T2WidthExtractorNc                 ^    t                               | ||||           || _        || _        d S r?   )r  r  nominalWidthXdefaultWidthX)r   r  r
  r  r  r  r  s          r   r  zT2WidthExtractor.__init__+  s6     	##D*k7GTTT**r    c                 V    t                               |            d| _        d| _        d S r  )r  r  gotWidthwidthr  s    r   r  zT2WidthExtractor.reset8  s(      &&&


r    r   c                     |                                  }| j        sY|t          |          dz  z  r1| j        
J d            | j        |d         z   | _        |dd          }n| j        | _        d| _        |S )Nr.   z5CFF2 CharStrings must not have an initial width valuer   r   )r!  r  ri   r  r  r  )r   evenOddrW  s      r   popallWidthzT2WidthExtractor.popallWidth=  s    {{}}} 
	#d))a-( 0 &22J 322!/$q'9
ABBx!/
DMr    c                 l    |                                  }| j        t          |          dz  z   | _        d S rU  )r  r  ri   rV  s     r   rH  zT2WidthExtractor.countHintsL  s/    !!#d))q.8r    c                 .    |                                   d S r?   r  r8  s     r   
op_rmovetozT2WidthExtractor.op_rmovetoP      r    c                 0    |                      d           d S Nr   r  r8  s     r   
op_hmovetozT2WidthExtractor.op_hmovetoS      r    c                 0    |                      d           d S r  r  r8  s     r   
op_vmovetozT2WidthExtractor.op_vmovetoV  r  r    c                 .    |                                   d S r?   r  r8  s     r   r;  zT2WidthExtractor.op_endcharY  r  r    r  r   )r  r  r  r  r  r  rH  r  r  r  r;  r   r    r   r  r  *  s         + + + +  
   9 9 9          r    r  c                   V    e Zd Z	 	 d6dZd Z f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 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" 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/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6 xZ7S )7T2OutlineExtractorNc           	      b    t                               | ||||||           || _        d| _        d S r  )r  r  pen	subrLevel)r   r  r  r
  r  r  r  r  s           r   r  zT2OutlineExtractor.__init__^  sE     	!!	
 	
 	
 r    c                 d    t                               |            d| _        d| _        d| _        d S )Nr   r   r   )r  r  currentPoint	sawMoveTor  r  s    r   r  zT2OutlineExtractor.resett  s0    t$$$"r    c                     | xj         dz  c_         t                                          |           | xj         dz  c_         | j         dk    r|                                  d S d S Nr   r   )r  superr,  endPath)r   r#  	__class__s     r   r,  zT2OutlineExtractor.executez  s_    !
###!>QLLNNNNN r    c                 T    | j         \  }}||d         z   ||d         z   f}|| _         |S r  )r  )r   pointr  ys       r   
_nextPointzT2OutlineExtractor._nextPoint  s5     1E!Ha%(l*!r    c                 n    | j                             |                     |                     d| _        d S r  )r  moveTor  r  r   r  s     r   rMoveTozT2OutlineExtractor.rMoveTo  s-    ..///r    c                     | j         s|                     d           | j                            |                     |                     d S Nr  )r  r  r  lineTor  r  s     r   rLineTozT2OutlineExtractor.rLineTo  sD    ~ 	!LL   ../////r    c                     | j         s|                     d           | j        }| j                             ||           ||           ||                     d S r  )r  r  r  r  curveTo)r   pt1pt2pt3	nextPoints        r   rCurveTozT2OutlineExtractor.rCurveTo  s]    ~ 	!LL   O	333HHHHHr    c                 T    | j         r| j                                         d| _         d S r  )r  r  	closePathr  s    r   r  zT2OutlineExtractor.closePath  s+    > 	!H   r    c                 @    | j         r|                                  d S d S r?   )r  r  r  s    r   r  zT2OutlineExtractor.endPath  s.    
 > 	NN	 	r    c                 |    |                                   |                     |                                            d S r?   r  r  r  r8  s     r   r  zT2OutlineExtractor.op_rmoveto  s3    T%%''(((((r    c                     |                                   |                     |                     d          d         df           d S r  r  r8  s     r   r  zT2OutlineExtractor.op_hmoveto  s?    d&&q))!,a011111r    c                     |                                   |                     d|                     d          d         f           d S r  r  r8  s     r   r  zT2OutlineExtractor.op_vmoveto  s?    a))!,,Q/011111r    c           	         |                                   |                                 }|r[ddlm} |\  }}}}||         }| j                            |d           ||         }	| j                            |	dddd||f           d S d S )Nr   StandardEncodingr   r   r   r   r   r   r   )r  r  $fontTools.encodings.StandardEncodingr  r  addComponent)
r   r   rW  r  adxadybcharachar	baseGlyphaccentGlyphs
             r   r;  zT2OutlineExtractor.op_endchar  s    !! 		GMMMMMM &*"CeU(/IH!!)-?@@@*51KH!!+1aC/EFFFFF		G 		Gr    c                     |                                  }t          dt          |          d          D ]$}|||dz            }|                     |           %d S )Nr   r.   )r!  r   ri   r  )r   r   rW  rd   r  s        r   
op_rlinetozT2OutlineExtractor.op_rlineto  s`    {{}}q#d))Q'' 	  	 AQUOELL	  	 r    c                 0    |                      d           d S r  alternatingLinetor8  s     r   
op_hlinetozT2OutlineExtractor.op_hlineto      q!!!!!r    c                 0    |                      d           d S r  r  r8  s     r   
op_vlinetozT2OutlineExtractor.op_vlineto  r  r    c                     |                                  }t          dt          |          d          D ]3}|||dz            \  }}}}}}	|                     ||f||f||	f           4dS )z${dxa dya dxb dyb dxc dyc}+ rrcurvetor   r|   N)r!  r   ri   r  )
r   r   rW  rd   dxadyadxbdybdxcdycs
             r   op_rrcurvetozT2OutlineExtractor.op_rrcurveto  s    {{}}q#d))Q'' 		> 		>A QQYMM3*sCj3*====		> 		>r    c                    |                                  }t          dt          |          dz
  d          D ]3}|||dz            \  }}}}}}	|                     ||f||f||	f           4|                     |dd                    dS )z-{dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveliner   r.   r|   N)r!  r   ri   r  r  )
r   r   rW  rd   r  r  r  r  dxddyds
             r   op_rcurvelinez T2OutlineExtractor.op_rcurveline  s    {{}}q#d))a-++ 	> 	>A+/AE	?(Cc3SMM3*sCj3*====T"##Yr    c                     |                                  }|dd         }t          dt          |          d          D ]"}|                     |||dz                       #|dd         \  }}}}}	}
|                     ||f||f|	|
f           dS )z-{dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurveNir   r.   )r!  r   ri   r  r  )r   r   rW  lineArgsrd   r  r  r  r  r  r  s              r   op_rlinecurvez T2OutlineExtractor.op_rlinecurve  s    {{}}9q#h--++ 	. 	.ALL!a!e),----'+BCCy$S#sCsCj3*sCj99999r    c                     |                                  }t          |          dz  r|d         }|dd         }nd}t          dt          |          d          D ]3}|||dz            \  }}}}|                     ||f||fd|f           d}4dS )z!dx1? {dya dxb dyb dyc}+ vvcurvetor.   r   r   Nr7   r!  ri   r   r  )	r   r   rW  dx1rd   r  r  r  r  s	            r   op_vvcurvetozT2OutlineExtractor.op_vvcurveto  s    {{}}t99q= 	q'C8DDCq#d))Q'' 	 	A!%a!a%iCc3MM3*sCj1c(;;;CC	 	r    c                     |                                  }t          |          dz  r|d         }|dd         }nd}t          dt          |          d          D ]3}|||dz            \  }}}}|                     ||f||f|df           d}4dS )z!dy1? {dxa dxb dyb dxc}+ hhcurvetor.   r   r   Nr7   r  )	r   r   rW  dy1rd   r  r  r  r  s	            r   op_hhcurvetozT2OutlineExtractor.op_hhcurveto  s    {{}}t99q= 	q'C8DDCq#d))Q'' 	 	A!%a!a%iCc3MM3*sCj3(;;;CC	 	r    c                     |                                  }|r0|                     |          }|r|                     |          }|.dS dS )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!  vcurvetohcurvetor   r   rW  s      r   op_vhcurvetozT2OutlineExtractor.op_vhcurveto  a     {{}} 	+==&&D +}}T**  	+ 	+ 	+ 	+ 	+r    c                     |                                  }|r0|                     |          }|r|                     |          }|.dS dS )zpdx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf?
        {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf?
        N)r!  r  r  r  s      r   op_hvcurvetozT2OutlineExtractor.op_hvcurveto%  r  r    c                     |                                  \  }}}}}}}dx}	x}
x}}| }|                     ||	f||f||
f           |                     ||f||f||f           d S r  r!  r  )r   r   r	  dx2dy2dx3dx4dx5dx6r  dy3dy4dy6dy5s                 r   op_hflexzT2OutlineExtractor.op_hflex2  s    ,0KKMM)S#sCc !!!c!C#dsCj3*sCj999sCj3*sCj99999r    c                     |                                  \  }}}}}}}}	}
}}}}|                     ||f||f||f           |                     ||	f|
|f||f           d S r?   r  )r   r   r	  r  r  r  r  r  r  r  r  r!  r  r   fds                  r   op_flexzT2OutlineExtractor.op_flex9  st    IMFS#sCc3S#sBsCj3*sCj999sCj3*sCj99999r    c           	          |                                  \	  }}}}}}}}	}
dx}}||z   |z   |z   |	z    }|                     ||f||f||f           |                     ||f||	f|
|f           d S r  r  )r   r   r	  r  r  r  r  r  r  r!  r  r  r  r   s                 r   	op_hflex1zT2OutlineExtractor.op_hflex1>  s    6:kkmm3S#sCc3cc	C#%+,sCj3*sCj999sCj3*sCj99999r    c                 H   |                                  \  }}}}}}}}	}
}}||z   |z   |z   |
z   }||z   |z   |	z   |z   }t          |          t          |          k    r|}| }n| }|}|                     ||f||f||f           |                     ||	f|
|f||f           d S r?   )r!  r   r  )r   r   r	  r  r  r  r  r  r  r  r  r!  d6dxdyr  r   s                    r   op_flex1zT2OutlineExtractor.op_flex1F  s    ?C{{}}<S#sCc3S"3Y_s"S(3Y_s"S(r77SWWC#CC#CCsCj3*sCj999sCj3*sCj99999r    c                     t           r?   rY  r8  s     r   rZ  zT2OutlineExtractor.op_andT  r[  r    c                     t           r?   rY  r8  s     r   r]  zT2OutlineExtractor.op_orW  r[  r    c                     t           r?   rY  r8  s     r   r_  zT2OutlineExtractor.op_notZ  r[  r    c                     t           r?   rY  r8  s     r   ra  zT2OutlineExtractor.op_store]  r[  r    c                     t           r?   rY  r8  s     r   rc  zT2OutlineExtractor.op_abs`  r[  r    c                     t           r?   rY  r8  s     r   re  zT2OutlineExtractor.op_addc  r[  r    c                     t           r?   rY  r8  s     r   rg  zT2OutlineExtractor.op_subf  r[  r    c                     |                                  }|                                  }||z  }||z  }||k    r|                     |           d S |                     |           d S r?   )r1  r6  )r   r   num2num1d1d2s         r   ri  zT2OutlineExtractor.op_divi  s]    xxzzxxzzT\D[88IIbMMMMMIIbMMMMMr    c                     t           r?   rY  r8  s     r   rk  zT2OutlineExtractor.op_loads  r[  r    c                     t           r?   rY  r8  s     r   rm  zT2OutlineExtractor.op_negv  r[  r    c                     t           r?   rY  r8  s     r   ro  zT2OutlineExtractor.op_eqy  r[  r    c                     t           r?   rY  r8  s     r   rq  zT2OutlineExtractor.op_drop|  r[  r    c                     t           r?   rY  r8  s     r   rs  zT2OutlineExtractor.op_put  r[  r    c                     t           r?   rY  r8  s     r   ru  zT2OutlineExtractor.op_get  r[  r    c                     t           r?   rY  r8  s     r   rw  zT2OutlineExtractor.op_ifelse  r[  r    c                     t           r?   rY  r8  s     r   ry  zT2OutlineExtractor.op_random  r[  r    c                     t           r?   rY  r8  s     r   r{  zT2OutlineExtractor.op_mul  r[  r    c                     t           r?   rY  r8  s     r   r}  zT2OutlineExtractor.op_sqrt  r[  r    c                     t           r?   rY  r8  s     r   r  zT2OutlineExtractor.op_dup  r[  r    c                     t           r?   rY  r8  s     r   r  zT2OutlineExtractor.op_exch  r[  r    c                     t           r?   rY  r8  s     r   r  zT2OutlineExtractor.op_index  r[  r    c                     t           r?   rY  r8  s     r   r  zT2OutlineExtractor.op_roll  r[  r    c                 ~    |                                  }|D ]%}|r|df}nd|f}|                     |           | }&d S r  )r!  r  )r   isHorizontalrW  argr  s        r   r  z$T2OutlineExtractor.alternatingLineto  s`    {{}} 	, 	,C !aCLL++LL	, 	,r    c                     |d d         \  }}}}|dd          }t          |          dk    r|d         }g }nd}|                     d|f||f||f           |S Nr7   r   r   ri   r  )r   rW  r  r  r  r  r  s          r   r  zT2OutlineExtractor.vcurveto  sp    !"1"XS#sABBxt99>>q'CDDCq#hc
S#J777r    c                     |d d         \  }}}}|dd          }t          |          dk    r|d         }g }nd}|                     |df||f||f           |S rK  rL  )r   rW  r  r  r  r  r  s          r   r  zT2OutlineExtractor.hcurveto  sp    !"1"XS#sABBxt99>>q'CDDCsAhc
S#J777r    r  )8r  r  r  r  r  r,  r  r  r  r  r  r  r  r  r  r;  r  r  r  r  r  r  r
  r  r  r  r"  r%  r'  r,  rZ  r]  r_  ra  rc  re  rg  ri  rk  rm  ro  rq  rs  ru  rw  ry  r{  r}  r  r  r  r  r  r  r  __classcell__r  s   @r   r  r  ]  sH           ,          0 0 0
I I I  
  6) ) )2 2 22 2 2G G G"     " " "" " "> > >     : : :    + + ++ + +: : :: : :
: : :: : :" " "" " "" " "" " "" " "" " "" " "  " " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " "" " ", , ,	 	 		 	 	 	 	 	 	r    r  c                       e Zd Zd Zd Zd Zd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 Zd Zd ZdS )T1OutlineExtractorc                 J    || _         || _        |                                  d S r?   )r  subrsr  )r   r  rS  s      r   r  zT1OutlineExtractor.__init__  s!    


r    c                 d    d| _         d| _        d| _        t                              |            d S r  )flexingr  sbxr  r  r  s    r   r  zT1OutlineExtractor.reset  s1    
  &&&&&r    c                 T    | j         r| j                                         d| _         d S r  )r  r  r  r  s    r   r  zT1OutlineExtractor.endPath  s+    > 	Hr    r   c                 *    |                                  S r?   r!  )r   r  s     r   r  zT1OutlineExtractor.popallWidth      {{}}r    c                 B    | j         }|d         |d         c|d<   |d<   d S )Nr   r   r/  r3  s     r   r   zT1OutlineExtractor.exch  s*    !$Ry%)b	5999r    c                     | j         rd S |                                  |                     |                                            d S r?   )rU  r  r  r!  r8  s     r   r  zT1OutlineExtractor.op_rmoveto  s>    < 	FT[[]]#####r    c                     | j         r|                     d           d S |                                  |                     |                                 d         df           d S r  )rU  r6  r  r  r!  r8  s     r   r  zT1OutlineExtractor.op_hmoveto  sW    < 	IIaLLLFdkkmmA&*+++++r    c                     | j         r+|                     d           |                                  d S |                                  |                     d|                                 d         f           d S r  )rU  r6  r   r  r  r!  r8  s     r   r  zT1OutlineExtractor.op_vmoveto  sd    < 	IIaLLLIIKKKFaq)*+++++r    c                 .    |                                   d S r?   )r  r8  s     r   op_closepathzT1OutlineExtractor.op_closepath  s    r    c                 J    |                                  }|\  }}||f| _        d S r?   )r!  r  )r   r   rW  r  r  s        r   op_setcurrentpointz%T1OutlineExtractor.op_setcurrentpoint  s*    {{}}1qDr    c                 .    |                                   d S r?   )r  r8  s     r   r;  zT1OutlineExtractor.op_endchar  s    r    c                 x    |                                  \  }}|| _        || _        || j        d         f| _        d S r  )r!  r  rV  r  )r   r   rV  wxs       r   op_hsbwzT1OutlineExtractor.op_hsbw  s<    ++--R
!21!55r    c                 .    |                                   d S r?   rY  r8  s     r   op_sbwzT1OutlineExtractor.op_sbw      r    c                 r    |                                  }| j        |         }|                     |           d S r?   )r1  rS  r,  r@  s       r   rC  zT1OutlineExtractor.op_callsubr  s3    HHJJ	z)$Tr    c                     |                                  }|                                  }|dk    r#|dk    r|                                  d| _        d S |dk    r|dk    rd| _        d S d S d S )Nr   rt   r   )r1  doFlexrU  )r   r   rA  nArgss       r   op_callothersubrz#T1OutlineExtractor.op_callothersubr  sl    HHJJ	

>>eqjjKKMMMDLLL!^^

DLLL ^

r    c                     d S r?   r   r8  s     r   op_popzT1OutlineExtractor.op_pop  r<  r    c                 Z   |                                  }|                                  }|                                   |                                  }|                                  }|                                  }|                                  }|                                  }|                                  }|                                  }	|                                  }
|                                  }|                                  }|                                  }|                                  }|                                  }|                                  }|                     ||z              |                     ||z              |                     |           |                     |           |                     |
           |                     |	           |                     d            |                     |           |                     |           |                     |           |                     |           |                     |           |                     |           |                     d            |                     |           |                     |           d S r?   )r1  r6  r  )r   finalyfinalxp3yp3xbcp4ybcp4xbcp3ybcp3xp2yp2xbcp2ybcp2xbcp1ybcp1xrpyrpxs                    r   rl  zT1OutlineExtractor.doFlex  s   


hhjjhhjj







hhjjhhjj







hhjjhhjj 			%#+		%#+		%		%		#		#$ 			%		%		%		%		#		#$ 			&		&r    c                 .    |                                   d S r?   rY  r8  s     r   op_dotsectionz T1OutlineExtractor.op_dotsectionE  ri  r    c                 .    |                                   d S r?   rY  r8  s     r   	op_hstem3zT1OutlineExtractor.op_hstem3H  ri  r    c           	          ddl m} |                                 \  }}}}}||         }| j                            |d           ||         }	|| j        z   |z
  }| j                            |	dddd||f           dS )zasb adx ady bchar achar seacr   r  r  r   N)r  r  r!  r  r  rV  )
r   r   r  asbr  r  r  r  r  r  s
             r   op_seaczT1OutlineExtractor.op_seacK  s    IIIIII&*kkmm#S#ue$U+	i);<<<&u-DHns"kAq!QS+ABBBBBr    c                 .    |                                   d S r?   rY  r8  s     r   	op_vstem3zT1OutlineExtractor.op_vstem3V  ri  r    Nr  )r  r  r  r  r  r  r  r   r  r  r  r`  rb  r;  rf  rh  rC  rn  rp  rl  r  r  r  r  r   r    r   rQ  rQ    sX         
' ' '  
   4 4 4$ $ $, , ,, , ,  ! ! !
  6 6 6    
    ( ( (T    	C 	C 	C    r    rQ  c                       e Zd ZeZ ee          \  ZZe	Z
eZddZddZd Zd Zd Zd ZddZd	 ZddZd Zd Zd ZeeefdZd Zd ZddZd Z dS )T2CharStringNc                 \    |g }|| _         || _        || _        ||ng | _        d | _        d S r?   )bytecoder$  r  r
  _cur_vsindex)r   r  r$  r  r
  s        r   r  zT2CharString.__init__`  s@    ?G *5*A;;r r    c                     | j         }|J ||| _        n%| j        t          |d          r|j        nd| _        |                    | j                  S )Nr   r   )r  r  hasattrr   r  )r   r   pds      r   r  zT2CharString.getNumRegionsi  s`    \~~~ 'D&.5b).D.D K

!D 1222r    c                     | j         d| j        j        t          |           fz  S d| j        j        t          |           fz  S )Nz<%s (source) at %x>z<%s (bytecode) at %x>)r  r  r  idr  s    r   __repr__zT2CharString.__repr__r  s@    = (DN,CRXX+NNN*dn.Er$xx-PPPr    c                     t           S r?   )r   r  s    r   r   zT2CharString.getIntEncoderx      r    c                     t           S r?   )r   r  s    r   getFixedEncoderzT2CharString.getFixedEncoder{  r  r    c                     |                                  sd S t          | j        dg           }|                     || j        | j                  }|                    |            d S NSubrs)r  r   r  decompilerClassr
  r,  )r   rS  
decompilers      r   	decompilezT2CharString.decompile~  sd    &&(( 	Fgr22))%1A4<PP
4     r    c           	          t          | j        dg           }|                     ||| j        | j        j        | j        j        | j        |          }|                    |            |j        | _        d S r  )r   r  outlineExtractorr
  r  r  r,  r  )r   r  r  rS  	extractors        r   drawzT2CharString.draw  sq    gr22))L&L&L
 
	 	$_


r    c                 X    t          |          }|                     |           |j        S r?   )r   r  bounds)r   glyphSet	boundsPens      r   
calcBoundszT2CharString.calcBounds  s*    h''			)r    Fc                    | j         d S | j        }| j        }|r|r|d         dv r
|d d         }n,|r*t          |d         t                    st          d          g }|                                 }|                                 }d}t          |          }||k     r||         }	|dz   }t          |	t                    rl	 |	                    d ||	         D                        n # t          $ r t          d|	z            w xY w|	dv r |                    ||                    |dz   }nt          |	t                    r|                     ||	                     nNt          |	t                    r|                     ||	                     nJ d	t          |	          z              ||k     	 t          |          }n)# t           $ r t"                              |            w xY w|                     |           d S )
Nr   )r   r   z@T2CharString or Subr has items on the stack after last operator.r   r   c              3   4   K   | ]}t          |          V  d S r?   )r   )rc   rJ   s     r   	<genexpr>z'T2CharString.compile.<locals>.<genexpr>  s(      #G#G1GAJJ#G#G#G#G#G#Gr    zillegal operator: %sr   r   zunsupported type: %s)r  opcodesr$  rj   strr   r   r  ri   extendr   r   r   rH   typer	   	TypeErrorr   errorsetBytecode)
r   isCFF2r  r$  r  r   r   rd   endr'  s
             r   compilezT2CharString.compile  sV   =$F,, 	 '72;*???!#2#, 	ZS99 	(R   &&((	**,,'ll#ggAJEAA%%% ?QOO#G#G#G#G#GGGGG Q Q Q01G%1OPPPQ444OOGAJ///AAE3'' ?		% 0 01111E5)) ?E 2 23333>04;;>>>>! #gg"	 **HH 	 	 	IIh	 	"""""s   %C( (D7G &G-c                     | j         d uS r?   )r  r  s    r   r  zT2CharString.needsDecompilation  s    }D((r    c                 "    || _         d | _        d S r?   )r$  r  )r   r$  s     r   r"  zT2CharString.setProgram  s    r    c                 "    || _         d | _        d S r?   )r  r$  )r   r  s     r   r  zT2CharString.setBytecode  s     r    c                 6   | j         U| || j                   k    rdS  || j         |                   }|dz   }| j        |         } || || j         |          \  }}n(| || j                  k    rdS | j        |         }|dz   } ||t                    }|||fS )N)Nr   r   r   )r  operandEncodingr$  r  )	r   r   ri   r   rj   r   r*  r'  r(  s	            r   r  zT2CharString.getToken  s    =$DM****!zu-..BAIE*2.G"74T]EBBLE55DL))))!zL'EAIEZs++
j%''r    c                     | j         ||z   }| j         ||         }|}n| j        |         }|dz   }t          |          |k    sJ ||fS r  )r  r$  ri   )r   r   nBytesnewIndexbytess        r   rR  zT2CharString.getBytes  s`    =$v~HM%.1EEEL'EAIE5zzV####e|r    c                     |S r?   r   )r   r   s     r   r   zT2CharString.handle_operator  s    r    c                    ddl m} | j        |                    | j                   d S d}g }	 |                     |          \  }}}|n|r|dv rv|                     |          \  }}}g }	|D ].}
|	                     |t          |
          d                     /t          |	          }d                    |||gz             }nd                    ||gz             }|	                    |           |
                                 g }nKt          |t                    rt          |d          }nt          |          }|                    |           +|r,d                    |          }|	                    |           d S d S )	Nr   )
num2binaryTr  r    r:   r;   )fontTools.misc.textToolsr  r  dumphexr  r   r   r
   joinwritenewlinerj   rH   r   r  )r   	xmlWriterttFontr  r   rW  r'  r(  hintMaskbitsbytelines               r   toXMLzT2CharString.toXML  s   777777=$dm,,,,,ED'+/==+?+?(z5= ' 8886:mmE6J6J3*e!$, F FD KK

74==!(D(DEEEE#*4=="xxx/@(@AA"xxw77OOD)))%%'''DD!%// + 1%r J J J #E

KK&&&-'.  & xx~~%%%%%& &r    c                 0   ddl m}m} |                    d          r |                      ||                     d S t          |          }|                                }g }t          |          }d}||k     r||         }	|dz   }	 t          |	          }	|	                    |	           n# t          $ r 	 t          |	d          }	|	                    |	           n# t          $ r |	                    |	           |	dv rk||         }
d}t          dt          |
          d	          D ](}|t           ||
||d	z                                z   })|	                    |           |dz   }Y nw xY wY nw xY w||k     |                     |           d S )
Nr   )
binary2numreadHexrawr   r:   r;   r  r    r   )r  r  r  r   r  r
   r   ri   r   r   
ValueErrorr   r   r   r"  )r   nameattrscontentr  r  r$  r  rd   r'  mask	maskBytesjs                r   fromXMLzT2CharString.fromXML  s   @@@@@@@@99U 	WWW--...F'""--//'ll#ggAJEAA&E

  u%%%%  * * **-e2FFFE NN5)))) " " " "NN5))) 888&qz$'	!&q#d))Q!7!7 Y YA(1GJJtAPQTUPUI<W<W4X4X(XIIy111E"* #gg* 	     s7   	B. .
E79C 
E7 BE1.E70E11E76E7)NNNNr?   )F)!r  r  r  t2OperandEncodingr  rp   t2Operatorsr   r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r"  r  ri   r   rj   r  rR  r   r  r  r   r    r   r  r  Z  sd       'O**;77Iw(O)! ! ! !3 3 3 3Q Q Q    ! ! !% % % %     
*# *# *# *#X) ) )     #&w: ( ( ( ( 	 	 	  $& $& $& $&L !  !  !  !  !r    r  c                   X     e Zd ZeZ ee          \  ZZd fd	Z	d Z
d Zd Zd Z xZS )T1CharStringNc                 Z    t                                          ||           || _        d S r?   )r  r  rS  )r   r  r$  rS  r  s       r   r  zT1CharString.__init__:  s(    7+++


r    c                     t           S r?   )encodeIntT1r  s    r   r   zT1CharString.getIntEncoder>  r  r    c                     d }d S )Nc                      t          d          )Nz8Type 1 charstrings don't support floating point operands)r  )r   s    r   r   z1T1CharString.getFixedEncoder.<locals>.encodeFixedB  s    VWWWr    r   )r   r   s     r   r  zT1CharString.getFixedEncoderA  s     	X 	X 	X 	X 	Xr    c                     | j         d S g }d}	 |                     |          \  }}}|n|                    |           2|                     |           d S r  )r  r  r   r"  )r   r$  r   r'  r(  s        r   r  zT1CharString.decompileE  so    = F	"'+}}U';';$E:u}NN5!!!		"
 	     r    c                 r    t          || j                  }|                    |            |j        | _        d S r?   )rQ  rS  r,  r  )r   r  r  s      r   r  zT1CharString.drawQ  s4    &sDJ77	$_


r    )NNN)r  r  r  t1OperandEncodingr  rp   t1Operatorsr   r  r  r   r  r  r  rN  rO  s   @r   r  r  6  s        'O**;77Iw       X X X
! 
! 
!% % % % % % %r    r  c                   \    e Zd ZeZd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S )DictDecompilerNc                 >    g | _         || _        i | _        || _        d S r?   )r4  stringsdictparent)r   r  r  s      r   r  zDictDecompiler.__init__Z  s"    
	r    c                 T    t          | j                  dk    s
J d            | j        S )Nr   znon-empty stack)ri   r4  r  r  s    r   getDictzDictDecompiler.getDict`  s,    4:!###%6###yr    c                     d}t          |          }| j        j        }||k     rMt          ||                   }|dz   }| j        |         } || |||          \  }}| ||           ||k     Kd S d S r  )ri   r4  r   r   r  )r   r   r   lenDatar6  r   r*  r   s           r   r  zDictDecompiler.decompiled  s    d))z gooe%%BAIE*2.G"74T599LE5 U goooooor    c                 0    | j         d         }| j         d= |S r.  r4  r0  s     r   r1  zDictDecompiler.popp  s    
2JrNr    c                 8    | j         d d          }| j         d d = |S r?   r  rV  s     r   r!  zDictDecompiler.popallu  s#    z!!!}JqqqMr    c                 p   |\  }}t          |t                    rQd}t          t          |          dz
  dd          D ],}||         }t	          | d|z             } ||          f|z   }-nt	          | d|z             } ||          }|dk    r| j                            |           d S || j        |<   d S )Nr   r   r   arg_r   )rj   rk   r   ri   r   r4  r  r  )r   r   argTyper   rd   rI  
arghandlers          r   r   zDictDecompiler.handle_operatorz  s    $'gu%% 	)E3w<<!+R44 8 8aj$T6C<88
#H--/%78
 !v'788JJx((EwJe$$$$$"'DIhr    c                     t          | j        d         t                    r|                     | j                  }n|                                 }|S r  )rj   r4  listarg_blend_numberr1  )r   r  outs      r   
arg_numberzDictDecompiler.arg_number  sC    djmT** 	''
33CC((**C
r    c                     g }|                                  }t          |          }|                    |           |                    d           |                                 }|S )Nr   )r1  ri   r   r!  )r   r  r  	blendArgs
numMastersdummys         r   r  zDictDecompiler.arg_blend_number  sV    HHJJ	^^


9

7r    c                 @    | j         |                                          S r?   )r  r1  r   r  s     r   arg_SIDzDictDecompiler.arg_SID  s    |DHHJJ''r    c                 *    |                                  S r?   rY  r  s     r   	arg_arrayzDictDecompiler.arg_array  rZ  r    c                    | j                             dd          }| j                            |          dz   }|                                 }|                                 }t          |          }|||z  k    sJ dg|z  }|dz
  }d}	d}
|	|k     r6||	         |
z   }|}
||	|z  z   }|g||||z            z   }|||	<   |	dz  }	|	|k     6|S )a  
        There may be non-blend args at the top of the stack. We first calculate
        where the blend args start in the stack. These are the last
        numMasters*numBlends) +1 args.
        The blend args starts with numMasters relative coordinate values, the  BlueValues in the list from the default master font. This is followed by
        numBlends list of values. Each of  value in one of these lists is the
        Variable Font delta for the matching region.

        We re-arrange this to be a list of numMaster entries. Each entry starts with the corresponding default font relative value, and is followed by
        the delta values. We then convert the default values, the first item in each entry, to an absolute value.
        r   r   r   N)r  r   r  r  r1  r!  ri   )r   r  r   r  r  rW  numArgsr   	numDeltasrd   prevValnewValmasterOffset	blendLists                 r   arg_blendListzDictDecompiler.arg_blendList  s     )--	1--K%%g..2 	 HHJJ	{{}}d))*y00000"N	)mm!Ww&FG$I6L4|i7O(O#PPI E!HFA )mm r    c                     |                                  }g }|rt          |d         t                    r|}n!d}|D ]}||z   }|                    |           |S r  )r!  rj   r  r   )r   r  	valueListr  currentre   s         r   	arg_deltazDictDecompiler.arg_delta  so    KKMM	 	$IaL$77 	$CCG $ $!A+

7####
r    r?   )r  r  r  cffDictOperandEncodingr  r  r  r  r1  r!  r   r  r  r  r  r  r  r   r    r   r  r  W  s        ,O     
 
 
  
  
( ( (     ( ( (       D    r    r  c                 L    t          |           }|dk     rd}n|dk     rd}nd}|S )Ni  r   il  r   i   )ri   )rS  nSubrsbiass      r   r  r    s7    ZZF}}	%Kr    )9__doc__fontTools.misc.fixedToolsr   r   r   r   r  r   r   r	   r
   fontTools.pens.boundsPenr   r0   logging	getLoggerr  r   r   r   r(   r+   r3   r8   r=   rB   rM   r  ri   r  r  rG   	enumerater   
maxOpStackrp   r  r   encodeIntCFFr  r   r   r   r   r   	Exceptionr   objectr  r  r  r  rQ  r  r  r  r  r   r    r   <module>r"     s               J I I I I I I I I I I I . . . . . .   g!!    2 2 2
3 3 3
  
  
< < <
! ! !
       FSL -0 !B$ %)4 "S& 'N+;; #c' 'N+;; #c' % # 
s$$$$%aaa( % " ' # *111- ) r , r + s   " <;IIk$:$:;;;
  8 8 8v1 1 1h }U##mD!!mD!!  + + + + ggcll*1 1 1h	 	 	 	 	Y 	 	 	F9 F9 F9 F9 F9 F9 F9 F9R  <0 0 0 0 0) 0 0 0fa a a a a) a a aHV V V V V+ V V VrY! Y! Y! Y! Y!6 Y! Y! Y!x% % % % %< % % %Bv v v v vV v v vr    r    