a
    w=ic                     @   sH  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 ]4Zed Zedd eeeD d Zee qe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rDe$ Z-e-.d$ e-/d% e-/d& e-0d'd(d) e-/d* e-1  e2e-j3 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   g/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/misc/symfont.py	<genexpr>       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   r   c                 c   s   | ]}t |d d V  qd S )Nr   )tuple)r   itemr   r   r   r      r   c                 #   s,   | ]$\ }t  fd dt|D V  qdS )c                 3   s.   | ]&\}}|t |  d t   |   V  qdS r   )t)r   ir   r   r   r   r      r   <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    "r/   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__0   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>5   r   z0_BezierFuncsLazy.__missing__.<locals>.<listcomp>r	   r   )
r(   r/   r1   BezierCurver
   	gcd_termscollectr$   r    Zlambdify)r2   r   argsr.   r   r   r   __missing__4   s    z_BezierFuncsLazy.__missing__N)__name__
__module____qualname__r3   r:   r   r   r   r   r0   .   s   r0   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_BezierFuncsr0   )ZcelffuncZfuncstrr   r   r   _getGreenBezierFuncs>   s    
zGreenPen._getGreenBezierFuncsNc                 C   s"   t | | | || _d| _d S )Nr   )r   r3   rB   _funcsvalue)r2   rA   Zglyphsetr   r   r   r3   E   s    zGreenPen.__init__c                 C   s
   || _ d S r   )_GreenPen__startPointr2   p0r   r   r   _moveToJ   s    zGreenPen._moveToc                 C   s"   |   }|| jkr| | j d S r   )_getCurrentPointrE   _lineTorF   r   r   r   
_closePathM   s    
zGreenPen._closePathc                 C   s   |   }|| jkrtd S r   )rI   rE   NotImplementedErrorrF   r   r   r   _endPathR   s    
zGreenPen._endPathc                 C   s&   |   }|  j| jd ||7  _d S )Nr	   rI   rD   rC   )r2   p1rG   r   r   r   rJ   X   s    zGreenPen._lineToc                 C   s(   |   }|  j| jd |||7  _d S )Nr'   rN   )r2   rO   p2rG   r   r   r   _qCurveToOne\   s    zGreenPen._qCurveToOnec                 C   s*   |   }|  j| jd ||||7  _d S )Nr   rN   )r2   rO   rP   Zp3rG   r   r   r   _curveToOne`   s    zGreenPen._curveToOne)N)r;   r<   r=   r@   classmethodrB   r3   rH   rK   rM   rJ   rQ   rR   r   r   r   r   r>   :   s   

r>   )rA   c           
         s  |d urt d|  t d| | f |d |D ]\}}t d| |d q,t dd|d dD ]8 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 qЈ dkrt d|d n. dkrt d|d n dkr0t d|d |D ]\}}	t d||	f |d q4t |d tdd |D |D ]\}}	t d||	f |d qrqXt d|  |d |D ]"\}}t d|t|f |d qt d|d d S ) Nz"""%s"""a  from fontTools.pens.basePen import BasePen, OpenContourError
try:
	import cython
except ImportError:
	# if cython not installed, use mock module with no-op decorators and types
	from fontTools.misc import cython

if cython.compiled:
	# Yep, I'm compiled.
	COMPILED = True
else:
	# Just a lowly interpreted script.
	COMPILED = False


__all__ = ["%s"]

class %s(BasePen):

	def __init__(self, glyphset=None):
		BasePen.__init__(self, glyphset)
)filez		self.%s = 0a  
	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:
			# Green theorem is not defined on open contours.
			raise OpenContourError(
							"Green theorem is not defined on open contours."
			)
 )endrT   )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>   r   z!printGreenPen.<locals>.<dictcomp>r	   c                    s   g | ]\}}t |t  qS r   )r/   r6   )r   namer.   r   r   r   r5      r   z!printGreenPen.<locals>.<listcomp>c              	   S   s"   g | ]}t |ttd qS )r   )r
   r7   r8   r$   r    r   r.   r   r   r   r5      r   c                    s   g | ]}|  qS r   r+   r[   r\   r   r   r5      r   basicc                 s   s   | ]}t d | V  qdS )zr%dN)r
   Symbol)r   r   r   r   r   r      r   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   r5      r   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   zipr?   )
ZpenNamefuncsrT   	docstringrZ   r.   ZgreensZdefsexprsrD   r   )r   r+   r   printGreenPeno   sd    



	


rd   __main__)d   rf   )rf      )rg   rg   )rg      ),  ri   )rh   i^  )rg   rf   )4ZfontTools.pens.basePenr   	functoolsr   	itertoolsr   Zsympyr
   sysr   r   r   r,   r*   r   r   rW   rX   r`   r    r)   ZBinomialCoefficientr(   r   r   lenthisappendr   ZBernsteinPolynomialr6   ZBezierCurveCr/   dictr0   r>   ZAreaPenZ
MomentXPenZ
MomentYPenZMomentXXPenZMomentYYPenZMomentXYPenstdoutrd   r;   penZmoveToZlineToZcurveToZ	closePathr_   rD   r   r   r   r   <module>   s\   -l




