o
    h                     @   s    d dl mZ G dd deZdS )    )ContourFilterPenc                   @   s   e Zd ZdZdd ZdS )ExplicitClosingLinePena
  A filter pen that adds an explicit lineTo to the first point of each closed
    contour if the end point of the last segment is not already the same as the first point.
    Otherwise, it passes the contour through unchanged.

    >>> from pprint import pprint
    >>> from fontTools.pens.recordingPen import RecordingPen
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.lineTo((100, 0))
    >>> pen.lineTo((100, 100))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('lineTo', ((100, 0),)),
     ('lineTo', ((100, 100),)),
     ('lineTo', ((0, 0),)),
     ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.lineTo((100, 0))
    >>> pen.lineTo((100, 100))
    >>> pen.lineTo((0, 0))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('lineTo', ((100, 0),)),
     ('lineTo', ((100, 100),)),
     ('lineTo', ((0, 0),)),
     ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.curveTo((100, 0), (0, 100), (100, 100))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('curveTo', ((100, 0), (0, 100), (100, 100))),
     ('lineTo', ((0, 0),)),
     ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.curveTo((100, 0), (0, 100), (100, 100))
    >>> pen.lineTo((0, 0))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('curveTo', ((100, 0), (0, 100), (100, 100))),
     ('lineTo', ((0, 0),)),
     ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.curveTo((100, 0), (0, 100), (0, 0))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('curveTo', ((100, 0), (0, 100), (0, 0))),
     ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)), ('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.closePath()
    >>> pprint(rec.value)
    [('closePath', ())]
    >>> rec = RecordingPen()
    >>> pen = ExplicitClosingLinePen(rec)
    >>> pen.moveTo((0, 0))
    >>> pen.lineTo((100, 0))
    >>> pen.lineTo((100, 100))
    >>> pen.endPath()
    >>> pprint(rec.value)
    [('moveTo', ((0, 0),)),
     ('lineTo', ((100, 0),)),
     ('lineTo', ((100, 100),)),
     ('endPath', ())]
    c                 C   s   |r|d d dks|d d dkst |dk rd S |d d d }|d d }|r=||d kr?d|ffd	g|dd < d S d S d S )
Nr   moveTo	closePath      lineTo)r    )len)selfcontourmovePtlastSegr   r   g/var/www/html/optinet_system/venv/lib/python3.10/site-packages/fontTools/pens/explicitClosingLinePen.pyfilterContourZ   s   z$ExplicitClosingLinePen.filterContourN)__name__
__module____qualname____doc__r   r   r   r   r   r      s    Ur   N)fontTools.pens.filterPenr   r   r   r   r   r   <module>   s    