o
    iA                     @   s`  d dl mZ d dlmZ d dlmZ d dlZd dlZdZ	ej
ddd\ZZZej
d	d
dZeej
de	d  ddZeej
de	d  ddZeedd dD  Zeej
de	d  d
dZdgZede	d D ]Zed Zedd eeeD d Zee qiedd eD Z[[edd eeD Zedd eeD Zedd eeD Zdd Z G dd de!Z"G dd deZ#ee#dd Z$ee#ed Z%ee#ed Z&ee#ee d Z'ee#ee d Z(ee#ee d Z)ej*dfd!d"Z+e,d#kr,d dlZej-dd r.ej-d Z.d$d% eej-d&dd& ej-ddd& D Z/e+e.e/ej*d' dS dS dS )(    )BasePen)partial)countN   zt x yTrealcFzx:%d   zy:%dc                 c   s*    | ]}t jd td |f ddV  qdS )zp:%d[%s]r	   Tr   N)spsymbolsn).0w r   e/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/fontTools/misc/symfont.py	<genexpr>   s   ( r   Z01zc:%d)r	   r   c                 c   s$    | ]}t |d   t |  V  qdS r	   N)last)r   jr   r   r   r         " r   c                 c   s     | ]}t |d d V  qd S )Nr   )tuple)r   itemr   r   r   r          c                 #   s.    | ]\ }t  fd dt|D V  qdS )c                 3   s0    | ]\}}|t |  d t   |   V  qdS r   )t)r   ir   r   r   r   r      s   . <genexpr>.<genexpr>N)r   	enumerate)r   Zcoeffsr   r   r   r      s
    
c                 #   s.    | ]\} t  fd dtdD V  qdS )c                 3   s*    | ] t  fd dtD V  qdS )c                 3   s$    | ]\}}t |   | V  qd S N)Pr   r   Z	bernsteinr   r   r   r   !   r   z<genexpr>.<genexpr>.<genexpr>Nsumr   )r   
bernsteinsr#   r   r       s
    
r      N)r   range)r   r   r   r&   r   r      s    
c                 c   s*    | ]\}}t d d t|D V  qdS )c                 s   s     | ]\}}t | | V  qd S r    )Cr"   r   r   r   r   '   r   r   Nr$   )r   r   r'   r   r   r   r   &   s
    
c                 C   sT   t t | t } | t|d t|d i} t | t |d t tddf} | S )Nr   r	   )r
   Z	integrateZsympifyysubsxdiffr   )fZcurveXYr   r   r   green,   s   "r0   c                   @   s   e Zd Zdd Zdd ZdS )_BezierFuncsLazyc                 C   s   || _ i | _d S r    )_symfuncZ	_bezfuncs)selfZsymfuncr   r   r   __init__4   s   
z_BezierFuncsLazy.__init__c                 C   sH   dd t |d D }t| jt| }t|ttd}t	||S )Nc                 S   s   g | ]}d | qS )zp%dr   )r   dr   r   r   
<listcomp>9       z0_BezierFuncsLazy.__missing__.<locals>.<listcomp>r	   r   )
r)   r0   r2   BezierCurver
   	gcd_termscollectr%   r!   Zlambdify)r3   r   argsr/   r   r   r   __missing__8   s   z_BezierFuncsLazy.__missing__N)__name__
__module____qualname__r4   r<   r   r   r   r   r1   3   s    r1   c                   @   sV   e Zd Zi Zedd ZdddZdd Zdd	 Zd
d Z	dd Z
dd Zdd ZdS )GreenPenc                 C   s*   t |}|| jvrt|| j|< | j| S r    )str_BezierFuncsr1   )ZcelffuncZfuncstrr   r   r   _getGreenBezierFuncsB   s   

zGreenPen._getGreenBezierFuncsNc                 C   s"   t | | | || _d| _d S )Nr   )r   r4   rD   _funcsvalue)r3   rC   Zglyphsetr   r   r   r4   I   s   
zGreenPen.__init__c                 C   s
   || _ d S r    )_startPointr3   p0r   r   r   _moveToN   s   
zGreenPen._moveToc                 C   s&   |   }|| jkr| | j d S d S r    )_getCurrentPointrG   _lineTorH   r   r   r   
_closePathQ   s   
zGreenPen._closePathc                 C   s   |   }|| jkrtd S r    )rK   rG   NotImplementedErrorrH   r   r   r   _endPathV   s   
zGreenPen._endPathc                 C   s&   |   }|  j| jd ||7  _d S )Nr	   rK   rF   rE   )r3   p1rI   r   r   r   rL   \   s   zGreenPen._lineToc                 C   s(   |   }|  j| jd |||7  _d S )Nr(   rP   )r3   rQ   p2rI   r   r   r   _qCurveToOne`   s    zGreenPen._qCurveToOnec                 C   s*   |   }|  j| jd ||||7  _d S )Nr   rP   )r3   rQ   rR   Zp3rI   r   r   r   _curveToOned   s   "zGreenPen._curveToOner    )r=   r>   r?   rB   classmethodrD   r4   rJ   rM   rO   rL   rS   rT   r   r   r   r   r@   ?   s    

r@   )rC   c           
         s  |d ur
t d|  t d| | f |d |D ]\}}t d| |d qt dd|d dD ] d	d
 t d D  fdd|D }dd |D }fdd|D }tj|ddd t D d\}}t   |D ]\}}	t d| |d qg dkrt d|d n dkrt d|d n
 dkrt d|d |D ]\}}	t d||	f |d qt |d tdd |D |D ]\}}	t d||	f |d qq,t d|  |d |D ]\}}t d|t|f |d qt d|d d S ) Nz"""%s"""ap  from fontTools.pens.basePen import BasePen, OpenContourError
try:
	import cython
except (AttributeError, ImportError):
	# if cython not installed, use mock module with no-op decorators and types
	from fontTools.misc import cython
COMPILED = cython.compiled


__all__ = ["%s"]

class %s(BasePen):

	def __init__(self, glyphset=None):
		BasePen.__init__(self, glyphset)
filez		self.%s = 0aT  
	def _moveTo(self, p0):
		self._startPoint = p0

	def _closePath(self):
		p0 = self._getCurrentPoint()
		if p0 != self._startPoint:
			self._lineTo(self._startPoint)

	def _endPath(self):
		p0 = self._getCurrentPoint()
		if p0 != self._startPoint:
			raise OpenContourError(
							"Glyph statistics is not defined on open contours."
			)
 )endrW   )r	   r(   r   c                 S   s4   i | ]}t d D ]}t| | ttg| | qqS )r(   )r)   r!   XY)r   r   r   r   r   r   
<dictcomp>   s   4 z!printGreenPen.<locals>.<dictcomp>r	   c                    s   g | ]\}}t |t  qS r   )r0   r8   r   namer/   r   r   r   r6      s    z!printGreenPen.<locals>.<listcomp>c              	   S   s"   g | ]}t |ttd qS )r   )r
   r9   r:   r%   r!   r   r/   r   r   r   r6      s   " c                    s   g | ]}|  qS r   r,   r_   r`   r   r   r6      s    basicc                 s   s    | ]
}t d | V  qdS )zr%dN)r
   Symbol)r   r   r   r   r   r      s    z printGreenPen.<locals>.<genexpr>)Zoptimizationsr   z!	@cython.locals(%s=cython.double)z	@cython.locals(x0=cython.double, y0=cython.double)
	@cython.locals(x1=cython.double, y1=cython.double)
	def _lineTo(self, p1):
		x0,y0 = self._getCurrentPoint()
		x1,y1 = p1
r(   z	@cython.locals(x0=cython.double, y0=cython.double)
	@cython.locals(x1=cython.double, y1=cython.double)
	@cython.locals(x2=cython.double, y2=cython.double)
	def _qCurveToOne(self, p1, p2):
		x0,y0 = self._getCurrentPoint()
		x1,y1 = p1
		x2,y2 = p2
r   a=  	@cython.locals(x0=cython.double, y0=cython.double)
	@cython.locals(x1=cython.double, y1=cython.double)
	@cython.locals(x2=cython.double, y2=cython.double)
	@cython.locals(x3=cython.double, y3=cython.double)
	def _curveToOne(self, p1, p2, p3):
		x0,y0 = self._getCurrentPoint()
		x1,y1 = p1
		x2,y2 = p2
		x3,y3 = p3
z			%s = %sc                 S   s   g | ]}|d  qS r   r   r_   r   r   r   r6      r7   z		self.%s += %szj
if __name__ == '__main__':
	from fontTools.misc.symfont import x, y, printGreenPen
	printGreenPen('%s', [z		      ('%s', %s),z			     ]))printr)   r
   Zcser   ziprA   )
penNamefuncsrW   	docstringr^   r/   ZgreensZdefsexprsrF   r   )r   r,   r   printGreenPent   st   

	
ri   __main__c                 C   s   g | ]
\}}|t |fqS r   )evalr]   r   r   r   r6      s    r6   r(   rV   )0ZfontTools.pens.basePenr   	functoolsr   	itertoolsr   Zsympyr
   sysr   r   r   r-   r+   r   r   rZ   r[   rd   r!   r*   ZBinomialCoefficientr)   r   r   lenthisappendr   ZBernsteinPolynomialr8   ZBezierCurveCr0   dictr1   r@   ZAreaPenZ
MomentXPenZ
MomentYPenZMomentXXPenZMomentYYPenZMomentXYPenstdoutri   r=   argvre   rf   r   r   r   r   <module>   s\    -
x
,