o
    h)                     @   sX   d dl mZmZ d dlmZ d dlmZmZ ddgZG dd deZ	G dd deZ
dS )	    )noRoundotRound)	Transform)	FilterPenFilterPointPenRoundingPenRoundingPointPenc                       sN   e Zd ZdZeef fdd	Zdd Zdd Zdd	 Z	d
d Z
dd Z  ZS )r   ag  
    Filter pen that rounds point coordinates and component XY offsets to integer. For
    rounding the component transform values, a separate round function can be passed to
    the pen.

    >>> from fontTools.pens.recordingPen import RecordingPen
    >>> recpen = RecordingPen()
    >>> roundpen = RoundingPen(recpen)
    >>> roundpen.moveTo((0.4, 0.6))
    >>> roundpen.lineTo((1.6, 2.5))
    >>> roundpen.qCurveTo((2.4, 4.6), (3.3, 5.7), (4.9, 6.1))
    >>> roundpen.curveTo((6.4, 8.6), (7.3, 9.7), (8.9, 10.1))
    >>> roundpen.addComponent("a", (1.5, 0, 0, 1.5, 10.5, -10.5))
    >>> recpen.value == [
    ...     ('moveTo', ((0, 1),)),
    ...     ('lineTo', ((2, 3),)),
    ...     ('qCurveTo', ((2, 5), (3, 6), (5, 6))),
    ...     ('curveTo', ((6, 9), (7, 10), (9, 10))),
    ...     ('addComponent', ('a', (1.5, 0, 0, 1.5, 11, -10))),
    ... ]
    True
    c                       t  | || _|| _d S Nsuper__init__	roundFunctransformRoundFuncselfoutPenr   r   	__class__ n/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/pens/roundingPen.pyr   !      
zRoundingPen.__init__c                 C   (   | j | |d | |d f d S Nr      )_outPenmoveTor   r   ptr   r   r   r   &      (zRoundingPen.moveToc                 C   r   r   )r   lineTor   r   r   r   r   r    )   r   zRoundingPen.lineToc                        j j fdd|D   d S )Nc                 3   (    | ]\}}  |  |fV  qd S r
   r   .0xyr   r   r   	<genexpr>.      & z&RoundingPen.curveTo.<locals>.<genexpr>)r   curveTor   pointsr   r(   r   r+   ,      zRoundingPen.curveToc                    r!   )Nc                 3   r"   r
   r#   r$   r(   r   r   r)   3   r*   z'RoundingPen.qCurveTo.<locals>.<genexpr>)r   qCurveTor,   r   r(   r   r/   1   r.   zRoundingPen.qCurveToc           	      C   sT   |\}}}}}}| j |t| || || || || || | d S r
   r   addComponentr   r   r   )	r   	glyphNametransformationxxxyyxyydxdyr   r   r   r1   6   s   zRoundingPen.addComponent)__name__
__module____qualname____doc__r   r   r   r   r    r+   r/   r1   __classcell__r   r   r   r   r   	   s    c                       s<   e Zd ZdZeef fdd	Z	d
ddZddd	Z  Z	S )r   a  
    Filter point pen that rounds point coordinates and component XY offsets to integer.
    For rounding the component scale values, a separate round function can be passed to
    the pen.

    >>> from fontTools.pens.recordingPen import RecordingPointPen
    >>> recpen = RecordingPointPen()
    >>> roundpen = RoundingPointPen(recpen)
    >>> roundpen.beginPath()
    >>> roundpen.addPoint((0.4, 0.6), 'line')
    >>> roundpen.addPoint((1.6, 2.5), 'line')
    >>> roundpen.addPoint((2.4, 4.6))
    >>> roundpen.addPoint((3.3, 5.7))
    >>> roundpen.addPoint((4.9, 6.1), 'qcurve')
    >>> roundpen.endPath()
    >>> roundpen.addComponent("a", (1.5, 0, 0, 1.5, 10.5, -10.5))
    >>> recpen.value == [
    ...     ('beginPath', (), {}),
    ...     ('addPoint', ((0, 1), 'line', False, None), {}),
    ...     ('addPoint', ((2, 3), 'line', False, None), {}),
    ...     ('addPoint', ((2, 5), None, False, None), {}),
    ...     ('addPoint', ((3, 6), None, False, None), {}),
    ...     ('addPoint', ((5, 6), 'qcurve', False, None), {}),
    ...     ('endPath', (), {}),
    ...     ('addComponent', ('a', (1.5, 0, 0, 1.5, 11, -10)), {}),
    ... ]
    True
    c                    r	   r
   r   r   r   r   r   r   c   r   zRoundingPointPen.__init__NFc                 K   s:   | j j| |d | |d ff||||d| d S )Nr   r   )segmentTypesmoothname
identifier)r   addPointr   )r   r   r?   r@   rA   rB   kwargsr   r   r   rC   h   s   
zRoundingPointPen.addPointc                 K   s`   |\}}}}}	}
| j jd|t| || || || || |	| |
|d| d S )N)baseGlyphNamer3   rB   r   r0   )r   rE   r3   rB   rD   r4   r5   r6   r7   r8   r9   r   r   r   r1   t   s   
zRoundingPointPen.addComponent)NFNNr
   )
r:   r;   r<   r=   r   r   r   rC   r1   r>   r   r   r   r   r   E   s    
N)fontTools.misc.roundToolsr   r   fontTools.misc.transformr   fontTools.pens.filterPenr   r   __all__r   r   r   r   r   r   <module>   s    <