§
    ‚ÛgÉ0  ã                   ó®  — d Z ddlmZmZ ddlmZmZ g d¢Zd„ Z G d„ de¦  «        Z	 G d„ d	ee	¦  «        Z
 G d
„ de¦  «        Z G d„ dee¦  «        Zdd„Zedk    rw e	¦   «         Ze                     d¦  «         e                     d¦  «         e                     ddd¦  «         e                     ¦   «          ddlmZ  eej        ¦  «         dS dS )z:Pen recording operations that can be accessed or replayed.é    )ÚAbstractPenÚDecomposingPen)ÚAbstractPointPenÚDecomposingPointPen)ÚreplayRecordingÚRecordingPenÚDecomposingRecordingPenÚDecomposingRecordingPointPenÚRecordingPointPenÚlerpRecordingsc                 ó<   — | D ]\  }} t          ||¦  «        |Ž  ŒdS )a2  Replay a recording, as produced by RecordingPen or DecomposingRecordingPen,
    to a pen.

    Note that recording does not have to be produced by those pens.
    It can be any iterable of tuples of method name and tuple-of-arguments.
    Likewise, pen can be any objects receiving those method calls.
    N)Úgetattr)Ú	recordingÚpenÚoperatorÚoperandss       úQ/granary/edev/quantum/lib/python3.11/site-packages/fontTools/pens/recordingPen.pyr   r      s<   € ð (ð *ð *Ñˆ�(Ø���XÑÔ Ð)Ð)Ð)ð*ð *ó    c                   óR   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ ZeZdS )r   aP  Pen recording operations that can be accessed or replayed.

    The recording can be accessed as pen.value; or replayed using
    pen.replay(otherPen).

    :Example:
        .. code-block::

            from fontTools.ttLib import TTFont
            from fontTools.pens.recordingPen import RecordingPen

            glyph_name = 'dollar'
            font_path = 'MyFont.otf'

            font = TTFont(font_path)
            glyphset = font.getGlyphSet()
            glyph = glyphset[glyph_name]

            pen = RecordingPen()
            glyph.draw(pen)
            print(pen.value)
    c                 ó   — g | _         d S ©N©Úvalue©Úselfs    r   Ú__init__zRecordingPen.__init__5   ó   € ØˆŒ
ˆ
ˆ
r   c                 ó@   — | j                              d|ff¦  «         d S )NÚmoveTo©r   Úappend)r   Úp0s     r   r   zRecordingPen.moveTo8   ó%   € ØŒ
×Ò˜8 b UÐ+Ñ,Ô,Ð,Ð,Ð,r   c                 ó@   — | j                              d|ff¦  «         d S )NÚlineTor    )r   Úp1s     r   r%   zRecordingPen.lineTo;   r#   r   c                 ó>   — | j                              d|f¦  «         d S )NÚqCurveTor    ©r   Úpointss     r   r(   zRecordingPen.qCurveTo>   s#   € ØŒ
×Ò˜: vÐ.Ñ/Ô/Ð/Ð/Ð/r   c                 ó>   — | j                              d|f¦  «         d S )NÚcurveTor    r)   s     r   r,   zRecordingPen.curveToA   s#   € ØŒ
×Ò˜9 fÐ-Ñ.Ô.Ð.Ð.Ð.r   c                 ó:   — | j                              d¦  «         d S )N)Ú	closePath© r    r   s    r   r.   zRecordingPen.closePathD   s   € ØŒ
×ÒÐ+Ñ,Ô,Ð,Ð,Ð,r   c                 ó:   — | j                              d¦  «         d S )N)ÚendPathr/   r    r   s    r   r1   zRecordingPen.endPathG   s   € ØŒ
×Ò˜/Ñ*Ô*Ð*Ð*Ð*r   c                 óB   — | j                              d||ff¦  «         d S )NÚaddComponentr    )r   Ú	glyphNameÚtransformations      r   r3   zRecordingPen.addComponentJ   s(   € ØŒ
×Ò˜>¨I°~Ð+FÐGÑHÔHÐHÐHÐHr   c                 óD   — | j                              d|||ff¦  «         d S )NÚaddVarComponentr    )r   r4   r5   Úlocations       r   r7   zRecordingPen.addVarComponentM   s+   € ØŒ
×ÒÐ,¨y¸.È(Ð.SÐTÑUÔUÐUÐUÐUr   c                 ó0   — t          | j        |¦  «         d S r   )r   r   )r   r   s     r   ÚreplayzRecordingPen.replayP   s   € Ý˜œ
 CÑ(Ô(Ð(Ð(Ð(r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r%   r(   r,   r.   r1   r3   r7   r:   Údrawr/   r   r   r   r      s»   € € € € € ðð ð.ð ð ð-ð -ð -ð-ð -ð -ð0ð 0ð 0ð/ð /ð /ð-ð -ð -ð+ð +ð +ðIð Ið IðVð Vð Vð)ð )ð )ð €D€D€Dr   r   c                   ó   — e Zd ZdZdZdS )r	   aa	  Same as RecordingPen, except that it doesn't keep components
    as references, but draws them decomposed as regular contours.

    The constructor takes a required 'glyphSet' positional argument,
    a dictionary of glyph objects (i.e. with a 'draw' method) keyed
    by thir name; other arguments are forwarded to the DecomposingPen's
    constructor::

        >>> class SimpleGlyph(object):
        ...     def draw(self, pen):
        ...         pen.moveTo((0, 0))
        ...         pen.curveTo((1, 1), (2, 2), (3, 3))
        ...         pen.closePath()
        >>> class CompositeGlyph(object):
        ...     def draw(self, pen):
        ...         pen.addComponent('a', (1, 0, 0, 1, -1, 1))
        >>> class MissingComponent(object):
        ...     def draw(self, pen):
        ...         pen.addComponent('foobar', (1, 0, 0, 1, 0, 0))
        >>> class FlippedComponent(object):
        ...     def draw(self, pen):
        ...         pen.addComponent('a', (-1, 0, 0, 1, 0, 0))
        >>> glyphSet = {
        ...    'a': SimpleGlyph(),
        ...    'b': CompositeGlyph(),
        ...    'c': MissingComponent(),
        ...    'd': FlippedComponent(),
        ... }
        >>> for name, glyph in sorted(glyphSet.items()):
        ...     pen = DecomposingRecordingPen(glyphSet)
        ...     try:
        ...         glyph.draw(pen)
        ...     except pen.MissingComponentError:
        ...         pass
        ...     print("{}: {}".format(name, pen.value))
        a: [('moveTo', ((0, 0),)), ('curveTo', ((1, 1), (2, 2), (3, 3))), ('closePath', ())]
        b: [('moveTo', ((-1, 1),)), ('curveTo', ((0, 2), (1, 3), (2, 4))), ('closePath', ())]
        c: []
        d: [('moveTo', ((0, 0),)), ('curveTo', ((-1, 1), (-2, 2), (-3, 3))), ('closePath', ())]

        >>> for name, glyph in sorted(glyphSet.items()):
        ...     pen = DecomposingRecordingPen(
        ...         glyphSet, skipMissingComponents=True, reverseFlipped=True,
        ...     )
        ...     glyph.draw(pen)
        ...     print("{}: {}".format(name, pen.value))
        a: [('moveTo', ((0, 0),)), ('curveTo', ((1, 1), (2, 2), (3, 3))), ('closePath', ())]
        b: [('moveTo', ((-1, 1),)), ('curveTo', ((0, 2), (1, 3), (2, 4))), ('closePath', ())]
        c: []
        d: [('moveTo', ((0, 0),)), ('lineTo', ((-3, 3),)), ('curveTo', ((-2, 2), (-1, 1), (0, 0))), ('closePath', ())]
    FN©r;   r<   r=   r>   ÚskipMissingComponentsr/   r   r   r	   r	   V   s#   € € € € € ð2ð 2ðj "ÐÐÐr   r	   c                   óL   — e Zd ZdZd„ Zdd„Zd„ Z	 dd„Zdd„Z	 dd	„Z	d
„ Z
e
ZdS )r   a‹  PointPen recording operations that can be accessed or replayed.

    The recording can be accessed as pen.value; or replayed using
    pointPen.replay(otherPointPen).

    :Example:
        .. code-block::

            from defcon import Font
            from fontTools.pens.recordingPen import RecordingPointPen

            glyph_name = 'a'
            font_path = 'MyFont.ufo'

            font = Font(font_path)
            glyph = font[glyph_name]

            pen = RecordingPointPen()
            glyph.drawPoints(pen)
            print(pen.value)

            new_glyph = font.newGlyph('b')
            pen.replay(new_glyph.getPointPen())
    c                 ó   — g | _         d S r   r   r   s    r   r   zRecordingPointPen.__init__©   r   r   Nc                 óN   — |�||d<   | j                              dd|f¦  «         d S )NÚ
identifierÚ	beginPathr/   r    )r   rF   Úkwargss      r   rG   zRecordingPointPen.beginPath¬   s5   € ØÐ!Ø#-ˆF�<Ñ ØŒ
×Ò˜;¨¨FÐ3Ñ4Ô4Ð4Ð4Ð4r   c                 ó@   — | j                              ddi f¦  «         d S )Nr1   r/   r    r   s    r   r1   zRecordingPointPen.endPath±   s%   € ØŒ
×Ò˜9 b¨"Ð-Ñ.Ô.Ð.Ð.Ð.r   Fc                 óV   — |�||d<   | j                              d||||f|f¦  «         d S )NrF   ÚaddPointr    )r   ÚptÚsegmentTypeÚsmoothÚnamerF   rH   s          r   rK   zRecordingPointPen.addPoint´   s@   € ð Ð!Ø#-ˆF�<Ñ ØŒ
×Ò˜:¨¨K¸ÀÐ'FÈÐOÑPÔPÐPÐPÐPr   c                 óR   — |�||d<   | j                              d||f|f¦  «         d S )NrF   r3   r    )r   ÚbaseGlyphNamer5   rF   rH   s        r   r3   zRecordingPointPen.addComponent»   s:   € ØÐ!Ø#-ˆF�<Ñ ØŒ
×Ò˜>¨M¸>Ð+JÈFÐSÑTÔTÐTÐTÐTr   c                 óT   — |�||d<   | j                              d|||f|f¦  «         d S )NrF   r7   r    )r   rQ   r5   r8   rF   rH   s         r   r7   z!RecordingPointPen.addVarComponentÀ   sI   € ð Ð!Ø#-ˆF�<Ñ ØŒ
×ÒØ °ÀÐ IÈ6ÐRñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óN   — | j         D ]\  }}} t          ||¦  «        |i |¤Ž Œd S r   )r   r   )r   ÚpointPenr   ÚargsrH   s        r   r:   zRecordingPointPen.replayÉ   sF   € Ø&*¤jð 	9ð 	9Ñ"ˆH�d˜FØ'�G�H˜hÑ'Ô'¨Ð8°Ð8Ð8Ð8Ð8ð	9ð 	9r   r   )NFNN)r;   r<   r=   r>   r   rG   r1   rK   r3   r7   r:   Ú
drawPointsr/   r   r   r   r   �   s²   € € € € € ðð ð2ð ð ð5ð 5ð 5ð 5ð
/ð /ð /ð IMðQð Qð Qð QðUð Uð Uð Uð CGð
ð 
ð 
ð 
ð9ð 9ð 9ð €J€J€Jr   r   c                   ó   — e Zd ZdZdZdS )r
   a¦  Same as RecordingPointPen, except that it doesn't keep components
    as references, but draws them decomposed as regular contours.

    The constructor takes a required 'glyphSet' positional argument,
    a dictionary of pointPen-drawable glyph objects (i.e. with a 'drawPoints' method)
    keyed by thir name; other arguments are forwarded to the DecomposingPointPen's
    constructor::

        >>> from pprint import pprint
        >>> class SimpleGlyph(object):
        ...     def drawPoints(self, pen):
        ...         pen.beginPath()
        ...         pen.addPoint((0, 0), "line")
        ...         pen.addPoint((1, 1))
        ...         pen.addPoint((2, 2))
        ...         pen.addPoint((3, 3), "curve")
        ...         pen.endPath()
        >>> class CompositeGlyph(object):
        ...     def drawPoints(self, pen):
        ...         pen.addComponent('a', (1, 0, 0, 1, -1, 1))
        >>> class MissingComponent(object):
        ...     def drawPoints(self, pen):
        ...         pen.addComponent('foobar', (1, 0, 0, 1, 0, 0))
        >>> class FlippedComponent(object):
        ...     def drawPoints(self, pen):
        ...         pen.addComponent('a', (-1, 0, 0, 1, 0, 0))
        >>> glyphSet = {
        ...    'a': SimpleGlyph(),
        ...    'b': CompositeGlyph(),
        ...    'c': MissingComponent(),
        ...    'd': FlippedComponent(),
        ... }
        >>> for name, glyph in sorted(glyphSet.items()):
        ...     pen = DecomposingRecordingPointPen(glyphSet)
        ...     try:
        ...         glyph.drawPoints(pen)
        ...     except pen.MissingComponentError:
        ...         pass
        ...     pprint({name: pen.value})
        {'a': [('beginPath', (), {}),
               ('addPoint', ((0, 0), 'line', False, None), {}),
               ('addPoint', ((1, 1), None, False, None), {}),
               ('addPoint', ((2, 2), None, False, None), {}),
               ('addPoint', ((3, 3), 'curve', False, None), {}),
               ('endPath', (), {})]}
        {'b': [('beginPath', (), {}),
               ('addPoint', ((-1, 1), 'line', False, None), {}),
               ('addPoint', ((0, 2), None, False, None), {}),
               ('addPoint', ((1, 3), None, False, None), {}),
               ('addPoint', ((2, 4), 'curve', False, None), {}),
               ('endPath', (), {})]}
        {'c': []}
        {'d': [('beginPath', (), {}),
               ('addPoint', ((0, 0), 'line', False, None), {}),
               ('addPoint', ((-1, 1), None, False, None), {}),
               ('addPoint', ((-2, 2), None, False, None), {}),
               ('addPoint', ((-3, 3), 'curve', False, None), {}),
               ('endPath', (), {})]}

        >>> for name, glyph in sorted(glyphSet.items()):
        ...     pen = DecomposingRecordingPointPen(
        ...         glyphSet, skipMissingComponents=True, reverseFlipped=True,
        ...     )
        ...     glyph.drawPoints(pen)
        ...     pprint({name: pen.value})
        {'a': [('beginPath', (), {}),
               ('addPoint', ((0, 0), 'line', False, None), {}),
               ('addPoint', ((1, 1), None, False, None), {}),
               ('addPoint', ((2, 2), None, False, None), {}),
               ('addPoint', ((3, 3), 'curve', False, None), {}),
               ('endPath', (), {})]}
        {'b': [('beginPath', (), {}),
               ('addPoint', ((-1, 1), 'line', False, None), {}),
               ('addPoint', ((0, 2), None, False, None), {}),
               ('addPoint', ((1, 3), None, False, None), {}),
               ('addPoint', ((2, 4), 'curve', False, None), {}),
               ('endPath', (), {})]}
        {'c': []}
        {'d': [('beginPath', (), {}),
               ('addPoint', ((0, 0), 'curve', False, None), {}),
               ('addPoint', ((-3, 3), 'line', False, None), {}),
               ('addPoint', ((-2, 2), None, False, None), {}),
               ('addPoint', ((-1, 1), None, False, None), {}),
               ('endPath', (), {})]}
    FNrA   r/   r   r   r
   r
   Ð   s%   € € € € € ðTð Tðn "ÐÐÐr   r
   ç      à?c              #   ó„  ‡K  — t          | ¦  «        t          |¦  «        k    r.t          dt          | ¦  «        t          |¦  «        fz  ¦  «        ‚t          | |¦  «        D ]]\  \  }}\  }}||k    rt          d|›d|›�¦  «        ‚|dk    rt          d¦  «        ‚ˆfd„t          ||¦  «        D ¦   «         }||fV — Œ^dS )a¤  Linearly interpolate between two recordings. The recordings
    must be decomposed, i.e. they must not contain any components.

    Factor is typically between 0 and 1. 0 means the first recording,
    1 means the second recording, and 0.5 means the average of the
    two recordings. Other values are possible, and can be useful to
    extrapolate. Defaults to 0.5.

    Returns a generator with the new recording.
    zMismatched lengths: %d and %dzMismatched operations: z, r3   zCannot interpolate componentsc                 óN   •— g | ]!\  \  }}\  }}|||z
  ‰z  z   |||z
  ‰z  z   f‘Œ"S r/   r/   )Ú.0Úx1Úy1Úx2Úy2Úfactors        €r   ú
<listcomp>z"lerpRecordings.<locals>.<listcomp>@  sV   ø€ ð ð ð á&‘H�R˜™h˜r 2ð �r˜B‘w &Ñ(Ñ(¨"°°R±¸6Ñ/AÑ*AÐBðð ð r   N)ÚlenÚ
ValueErrorÚzip)Ú
recording1Ú
recording2r`   Úop1Úargs1Úop2Úargs2Úmid_argss     `     r   r   r   +  s  øè è € õ ˆ:�„�#˜j™/œ/Ò)Ð)ÝØ+­s°:©¬ÅÀJÁÄÐ.PÑPñ
ô 
ð 	
õ '*¨*°jÑ&AÔ&Að 
ð 
Ñ"‰ˆˆe‘l�s˜EØ�#Š:ˆ:Ý�*ÀÀÀÀSÀSÐIÑJÔJÐJØ�.Ò Ð ÝÐ<Ñ=Ô=Ð=ðð ð ð å*-¨e°UÑ*;Ô*;ðñ ô ˆHð �HˆoÐÐÐÐð
ð 
r   Ú__main__)r   r   )r   éd   )é2   éK   )é<   rn   )rn   é   )ÚpprintN)rX   )r>   ÚfontTools.pens.basePenr   r   ÚfontTools.pens.pointPenr   r   Ú__all__r   r   r	   r   r
   r   r;   r   r   r%   r,   r.   rr   r   r/   r   r   ú<module>rv      s»  ðØ @Ð @à >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ Iðð ð €ð	*ð 	*ð 	*ð6ð 6ð 6ð 6ð 6�;ñ 6ô 6ð 6ðr6"ð 6"ð 6"ð 6"ð 6"˜n¨lñ 6"ô 6"ð 6"ðr>ð >ð >ð >ð >Ð(ñ >ô >ð >ðBX"ð X"ð X"ð X"ð X"Ð#6Ð8Iñ X"ô X"ð X"ðvð ð ð ð8 ˆzÒÐØ
ˆ,‰.Œ.€CØ‡J‚JˆvÑÔÐØ‡J‚JˆxÑÔÐØ‡K‚K�˜( HÑ-Ô-Ð-Ø‡M‚M�O„O€OØÐÐÐÐÐà
€Fˆ3Œ9ÑÔÐÐÐð Ðr   