a
    —Æàg¶  ã                   @   s>   d dl mZ d dlmZ ddgZG dd„ deƒZd	dd„ZdS )
é    )Úpairwise)ÚContourFilterPenÚreversedContourÚReverseContourPenc                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )r   a  Filter pen that passes outline data to another pen, but reversing
    the winding direction of all contours. Components are simply passed
    through unchanged.

    Closed contours are reversed in such a way that the first point remains
    the first point.
    Fc                    s   t ƒ  |¡ || _d S ©N)ÚsuperÚ__init__ÚoutputImpliedClosingLine)ÚselfZoutPenr	   ©Ú	__class__© úY/var/www/sistema_ama/venv/lib/python3.9/site-packages/fontTools/pens/reverseContourPen.pyr      s    zReverseContourPen.__init__c                 C   s   t || jƒS r   )r   r	   )r
   Úcontourr   r   r   ÚfilterContour   s    zReverseContourPen.filterContour)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r      s   Fc                 c   s  | sdS t | ƒdksJ dƒ‚|  ¡ d }|dv s4J ‚|dk}|  d¡\}}|dv s^J d| ƒ‚|d	 }|d
kr¬|du s~J dƒ‚| rŠJ dƒ‚|d ftt|dd	… ƒƒ d }| sÐ|dkr¾d}nd}||fV  �n0| d	 \}}|d	 }	|�r’||fV  ||	k�r(d|	ffV  |t|dd	… ƒ|f f| d	< t | ƒdk�rD| d \}
}n
|| }
}|�s¼|
dk�r¼||k�r¼| d= | �r¼|t|dd	… ƒ| f| d	< n*||	ffV  |t|dd	… ƒ|f f| d	< t| dd�D ]6\\}}\}}|tt|dd	… ƒƒ|d	 f fV  �qÈ|�r
dnddfV  dS )zGenerator that takes a list of pen's (operator, operands) tuples,
    and yields them with the winding direction reversed.
    Né   zinvalid contourr   )ÚendPathÚ	closePathr   )ÚmoveToÚqCurveToz invalid initial segment type: %réÿÿÿÿr   z)off-curve only paths must end with 'None'z,only one qCurveTo allowed per off-curve pathr   r   FTZlineTo)Úreverser   r   )ÚlenÚpopÚtupleÚreversedr   )r   r	   ZcontourTypeÚclosedZ	firstTypeZfirstPtsZfirstOnCurveZlastTypeZlastPtsZlastOnCurveZ
secondTypeZ	secondPtsZcurTypeZcurPtsÚ_ZnextPtsr   r   r   r      sP    
ÿ"


(N)F)ZfontTools.misc.arrayToolsr   ZfontTools.pens.filterPenr   Ú__all__r   r   r   r   r   r   Ú<module>   s   