
    ]Mh)                     r    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
dS )	    )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                 f    t                                          |           || _        || _        d S Nsuper__init__	roundFunctransformRoundFuncselfoutPenr   r   	__class__s       Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/pens/roundingPen.pyr   zRoundingPen.__init__!   0       ""4    c                     | j                             |                     |d                   |                     |d                   f           d S Nr      )_outPenmoveTor   r   pts     r   r   zRoundingPen.moveTo&   C    T^^BqE22DNN2a54I4IJKKKKKr   c                     | j                             |                     |d                   |                     |d                   f           d S r   )r   lineTor   r   s     r   r"   zRoundingPen.lineTo)   r    r   c                 >       j         j         fd|D               d S )Nc              3   r   K   | ]1\  }}                     |                               |          fV  2d S r   r   .0xyr   s      r   	<genexpr>z&RoundingPen.curveTo.<locals>.<genexpr>.   D      HHAt~~a  $.."3"34HHHHHHr   )r   curveTor   pointss   ` r   r,   zRoundingPen.curveTo,   s8    HHHHHHH	
 	
 	
 	
r   c                 >       j         j         fd|D               d S )Nc              3   r   K   | ]1\  }}                     |                               |          fV  2d S r   r%   r&   s      r   r*   z'RoundingPen.qCurveTo.<locals>.<genexpr>3   r+   r   )r   qCurveTor-   s   ` r   r1   zRoundingPen.qCurveTo1   s8    HHHHHHH	
 	
 	
 	
r   c                 V   |\  }}}}}}| j                             |t          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |                               d S r   r   addComponentr   r   r   )	r   	glyphNametransformationxxxyyxyydxdys	            r   r4   zRoundingPen.addComponent6   s    !/BBB!!''++''++''++''++r""r"" 
	
 
	
 
	
 
	
 
	
r   )__name__
__module____qualname____doc__r   r   r   r   r"   r,   r1   r4   __classcell__r   s   @r   r   r   	   s         . *1W 5 5 5 5 5 5
L L LL 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                 f    t                                          |           || _        || _        d S r   r   r   s       r   r   zRoundingPointPen.__init__c   r   r   NFc                      | j         j        |                     |d                   |                     |d                   ff||||d| d S )Nr   r   )segmentTypesmoothname
identifier)r   addPointr   )r   r   rF   rG   rH   rI   kwargss          r   rJ   zRoundingPointPen.addPointh   so     	^^BqE""DNN2a5$9$9:	
#!	
 	
 	
 	
 	
 	
 	
r   c                 L   |\  }}}}}	}
 | j         j        d|t          |                     |          |                     |          |                     |          |                     |          |                     |	          |                     |
                    |d| d S )N)baseGlyphNamer6   rI    r3   )r   rM   r6   rI   rK   r7   r8   r9   r:   r;   r<   s              r   r4   zRoundingPointPen.addComponentt   s    !/BBB!! 	
'$''++''++''++''++r""r""  "	
 	
 	
 	
 	
 	
 	
r   )NFNNr   )
r=   r>   r?   r@   r   r   r   rJ   r4   rA   rB   s   @r   r	   r	   E   s}         : *1W 5 5 5 5 5 5 IM

 

 

 


 
 
 
 
 
 
 
r   N)fontTools.misc.roundToolsr   r   fontTools.misc.transformr   fontTools.pens.filterPenr   r   __all__r   r	   rN   r   r   <module>rS      s    6 6 6 6 6 6 6 6 . . . . . . > > > > > > > > ,
-9
 9
 9
 9
 9
) 9
 9
 9
x=
 =
 =
 =
 =
~ =
 =
 =
 =
 =
r   