
    Mcg)                     d    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e      Z	 G d de      Z
y)	    )noRoundotRound)	Transform)	FilterPenFilterPointPenRoundingPenRoundingPointPenc                   F     e Zd ZdZeef fd	Zd Zd Zd Z	d Z
d Z x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         |   |       || _        || _        y Nsuper__init__	roundFunctransformRoundFuncselfoutPenr   r   	__class__s       U/var/www/html/bid-api/venv/lib/python3.12/site-packages/fontTools/pens/roundingPen.pyr   zRoundingPen.__init__!        ""4    c                     | j                   j                  | j                  |d         | j                  |d         f       y Nr      )_outPenmoveTor   r   pts     r   r   zRoundingPen.moveTo&   3    T^^BqE2DNN2a54IJKr   c                     | j                   j                  | j                  |d         | j                  |d         f       y r   )r   lineTor   r   s     r   r"   zRoundingPen.lineTo)   r    r   c                 J       j                   j                   fd|D          y )Nc              3   h   K   | ])  \  }}j                  |      j                  |      f + y wr   r   .0xyr   s      r   	<genexpr>z&RoundingPen.curveTo.<locals>.<genexpr>.   -     HAt~~a $.."34   /2)r   curveTor   pointss   ` r   r-   zRoundingPen.curveTo,   s    HH	
r   c                 J       j                   j                   fd|D          y )Nc              3   h   K   | ])  \  }}j                  |      j                  |      f + y wr   r%   r&   s      r   r*   z'RoundingPen.qCurveTo.<locals>.<genexpr>3   r+   r,   )r   qCurveTor.   s   ` r   r2   zRoundingPen.qCurveTo1   s    HH	
r   c                    |\  }}}}}}| j                   j                  |t        | j                  |      | j                  |      | j                  |      | j                  |      | j	                  |      | j	                  |                   y r   r   addComponentr   r   r   )	r   	glyphNametransformationxxxyyxyydxdys	            r   r5   zRoundingPen.addComponent6   s    !/BBB!!''+''+''+''+r"r"
	
r   )__name__
__module____qualname____doc__r   r   r   r   r"   r-   r2   r5   __classcell__r   s   @r   r   r   	   s/    . *1W 5
LL




r   c                   :     e Zd ZdZeef fd	Z	 ddZddZ x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                 @    t         |   |       || _        || _        y r   r   r   s       r   r   zRoundingPointPen.__init__c   r   r   c                      | j                   j                  | j                  |d         | j                  |d         ff||||d| y )Nr   r   )segmentTypesmoothname
identifier)r   addPointr   )r   r   rG   rH   rI   rJ   kwargss          r   rK   zRoundingPointPen.addPointh   sU     	^^BqE"DNN2a5$9:	
#!	
 	
r   c                 &   |\  }}}}}	}
 | j                   j                  d|t        | j                  |      | j                  |      | j                  |      | j                  |      | j	                  |	      | j	                  |
            |d| y )N)baseGlyphNamer7   rJ    r4   )r   rN   r7   rJ   rL   r8   r9   r:   r;   r<   r=   s              r   r5   zRoundingPointPen.addComponentt   s    !/BBB!!! 	
'$''+''+''+''+r"r" "	
 	
r   )NFNNr   )
r>   r?   r@   rA   r   r   r   rK   r5   rB   rC   s   @r   r	   r	   E   s%    : *1W 5 IM


r   N)fontTools.misc.roundToolsr   r   fontTools.misc.transformr   fontTools.pens.filterPenr   r   __all__r   r	   rO   r   r   <module>rT      s4    6 . > ,
-9
) 9
x=
~ =
r   