o
    hO                     @   sL  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$e$ Z-e-.d$ e-/d% e-/d& e-0d'd(d) e-/d* e-1  e2e-j3 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   j/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/misc/symfont.py	<genexpr>   s   ( r   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   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   	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
   	integratesympifyysubsxdiffr   )fcurveXYr   r   r   green,   s   "r6   c                   @   s   e Zd Zdd Zdd ZdS )_BezierFuncsLazyc                 C   s   || _ i | _d S r"   )_symfunc	_bezfuncs)self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,   r6   r8   BezierCurver
   	gcd_termscollectr(   r#   lambdify)r:   r   argsr4   r   r   r   __missing__8   s   z_BezierFuncsLazy.__missing__N)__name__
__module____qualname__r<   rE   r   r   r   r   r7   3   s    r7   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_BezierFuncsr7   )celffuncfuncstrr   r   r   _getGreenBezierFuncsB   s   

zGreenPen._getGreenBezierFuncsNc                 C   s"   t | | | || _d| _d S )Nr   )r   r<   rO   _funcsvalue)r:   rM   glyphsetr   r   r   r<   I   s   
zGreenPen.__init__c                 C   s
   || _ d S r"   )_startPointr:   p0r   r   r   _moveToN   s   
zGreenPen._moveToc                 C   s&   |   }|| jkr| | j d S d S r"   )_getCurrentPointrS   _lineTorT   r   r   r   
_closePathQ   s   
zGreenPen._closePathc                 C   s   |   }|| jkrtd S r"   )rW   rS   NotImplementedErrorrT   r   r   r   _endPathV   s   
zGreenPen._endPathc                 C   s&   |   }|  j| jd ||7  _d S )Nr	   rW   rQ   rP   )r:   p1rU   r   r   r   rX   \   s   zGreenPen._lineToc                 C   s(   |   }|  j| jd |||7  _d S )Nr+   r\   )r:   r]   p2rU   r   r   r   _qCurveToOne`   s    zGreenPen._qCurveToOnec                 C   s*   |   }|  j| jd ||||7  _d S )Nr   r\   )r:   r]   r^   p3rU   r   r   r   _curveToOned   s   "zGreenPen._curveToOner"   )rF   rG   rH   rK   classmethodrO   r<   rV   rY   r[   rX   r_   ra   r   r   r   r   rI   ?   s    

rI   )rM   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."
			)
 )endrc   )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   )r6   r@   )r   namer4   r   r   r   r>      s    z!printGreenPen.<locals>.<listcomp>c              	   S   s"   g | ]}t |ttd qS )r   )r
   rA   rB   r(   r#   r   r4   r   r   r   r>      s   " c                    s   g | ]}|  qS r   r1   rj   rk   r   r   r>      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>)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   rj   r   r   r   r>      r?   z		self.%s += %szj
if __name__ == '__main__':
	from fontTools.misc.symfont import x, y, printGreenPen
	printGreenPen('%s', [z		      ('%s', %s),z			     ]))printr,   r
   cser   ziprJ   )
penNamefuncsrc   	docstringri   r4   greensdefsexprsrQ   r   )r   r1   r   printGreenPent   st   

	
rx   __main__)d   rz   )rz      )r{   r{   )r{      ),  r}   )r|   i^  )r{   rz   )4fontTools.pens.basePenr   	functoolsr   	itertoolsr   sympyr
   sysr   r   r   r2   r0   r   r   rf   rg   rq   r#   r-   BinomialCoefficientr,   r   r   lenthisappendr    BernsteinPolynomialr@   BezierCurveCr6   dictr7   rI   AreaPen
MomentXPen
MomentYPenMomentXXPenMomentYYPenMomentXYPenstdoutrx   rF   penmoveTolineTocurveTo	closePathro   rQ   r   r   r   r   <module>   s`    -
x



