a
    w=icÛ  ã                   @   sT   d dl 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 )	é    )ÚotRound)Ú	Transform)Ú	FilterPenÚFilterPointPenÚRoundingPenÚRoundingPointPenc                       sL   e Zd ZdZef‡ fdd„	Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
‡  ZS )r   aþ  
    Filter pen that rounds point coordinates and component XY offsets to integer.

    >>> 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                    s   t ƒ  |¡ || _d S ©N©ÚsuperÚ__init__Ú	roundFunc©ÚselfZoutPenr   ©Ú	__class__© úk/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/pens/roundingPen.pyr      s    zRoundingPen.__init__c                 C   s(   | j  |  |d ¡|  |d ¡f¡ d S ©Nr   é   )Ú_outPenÚmoveTor   ©r   Úptr   r   r   r   #   s    zRoundingPen.moveToc                 C   s(   | j  |  |d ¡|  |d ¡f¡ d S r   )r   ÚlineTor   r   r   r   r   r   &   s    zRoundingPen.lineToc                    s   ˆ j j‡ fdd„|D ƒŽ  d S )Nc                 3   s&   | ]\}}ˆ   |¡ˆ   |¡fV  qd S r   ©r   ©Ú.0ÚxÚy©r   r   r   Ú	<genexpr>+   ó    z&RoundingPen.curveTo.<locals>.<genexpr>)r   ÚcurveTo©r   Zpointsr   r   r   r"   )   s    ÿzRoundingPen.curveToc                    s   ˆ j j‡ fdd„|D ƒŽ  d S )Nc                 3   s&   | ]\}}ˆ   |¡ˆ   |¡fV  qd S r   r   r   r   r   r   r    0   r!   z'RoundingPen.qCurveTo.<locals>.<genexpr>)r   ÚqCurveTor#   r   r   r   r$   .   s    ÿzRoundingPen.qCurveToc              	   C   s@   | j  |tg |d d… ¢|  |d ¡‘|  |d ¡‘R Ž ¡ d S ©Né   é   ©r   ÚaddComponentr   r   )r   Z	glyphNameÚtransformationr   r   r   r)   3   s    
ÿþýþzRoundingPen.addComponent)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r"   r$   r)   Ú__classcell__r   r   r   r   r   	   s   c                       s6   e Zd ZdZef‡ fdd„	Zd
dd„Zdd	„ Z‡  ZS )r   a'  
    Filter point pen that rounds point coordinates and component XY offsets to integer.

    >>> 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                    s   t ƒ  |¡ || _d S r   r	   r   r   r   r   r   Z   s    zRoundingPointPen.__init__NFc                 K   s8   | j j|  |d ¡|  |d ¡ff|||dœ|¤Ž d S )Nr   r   )ÚsegmentTypeÚsmoothÚname)r   ÚaddPointr   )r   r   r0   r1   r2   Úkwargsr   r   r   r3   ^   s    ÿüûzRoundingPointPen.addPointc                 K   sH   | j j|tg |d d… ¢|  |d ¡‘|  |d ¡‘R Ž fi |¤Ž d S r%   r(   )r   ZbaseGlyphNamer*   r4   r   r   r   r)   g   s    
ÿþýþùzRoundingPointPen.addComponent)NFN)	r+   r,   r-   r.   r   r   r3   r)   r/   r   r   r   r   r   >   s   
	N)
ZfontTools.misc.roundToolsr   ZfontTools.misc.transformr   ZfontTools.pens.filterPenr   r   Ú__all__r   r   r   r   r   r   Ú<module>   s
   5