Ë
    £ehÏ2  ã                   ó˜   — d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dl
mZ  G d„ d	e«      Z G d
„ de«      Z G d„ d«      Zy)é    N)Úcurve_to_quadraticÚcurves_to_quadratic)ÚdecomposeSuperBezierSegment)Ú	FilterPen)ÚReverseContourPen)ÚBasePointToSegmentPen)ÚReverseContourPointPenc                   ó:   ‡ — e Zd ZdZ	 	 	 dˆ fd„	Zˆ fd„Zd„ Zˆ xZS )ÚCu2QuPena	  A filter pen to convert cubic bezier curves to quadratic b-splines
    using the FontTools SegmentPen protocol.

    Args:

        other_pen: another SegmentPen used to draw the transformed outline.
        max_err: maximum approximation error in font units. For optimal results,
            if you know the UPEM of the font, we recommend setting this to a
            value equal, or close to UPEM / 1000.
        reverse_direction: flip the contours' direction but keep starting point.
        stats: a dictionary counting the point numbers of quadratic segments.
        all_quadratic: if True (default), only quadratic b-splines are generated.
            if False, quadratic curves or cubic curves are generated depending
            on which one is more economical.
    c                 óh   •— |rt        |«      }t        ‰| �	  |«       || _        || _        || _        y ©N)r   ÚsuperÚ__init__Úmax_errÚstatsÚall_quadratic)ÚselfÚ	other_penr   Úreverse_directionr   r   Ú	__class__s         €úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/pens/cu2quPen.pyr   zCu2QuPen.__init__)   s5   ø€ ñ Ü)¨)Ó4ˆIÜ‰Ñ˜Ô#ØˆŒØˆŒ
Ø*ˆÕó    c                 óÄ  •— | j                   |||f}t        || j                  | j                  «      }| j                  �Ct        t        |«      dz
  «      }| j                  j                  |d«      dz   | j                  |<   | j                  r | j                  |dd  Ž  y t        |«      dk(  r | j                  |dd  Ž  y t        |«      dk(  sJ ‚t        ‰| �(  |dd  Ž  y )Né   r   é   é   é   )Ú
current_ptr   r   r   r   ÚstrÚlenÚgetÚqCurveTor   ÚcurveTo)r   Úpt1Úpt2Úpt3ÚcurveÚresultÚnr   s          €r   Ú_convert_curvezCu2QuPen._convert_curve8   sË   ø€ Ø—‘ # s¨CÐ0ˆÜ# E¨4¯<©<¸×9KÑ9KÓLˆØ�:‰:Ð!Ü”C˜“K !‘OÓ$ˆAØ ŸJ™JŸN™N¨1¨aÓ0°1Ñ4ˆD�J‰J�q‰MØ×ÒØˆD�M‰M˜6 ! "˜:Ò&ä�6‹{˜aÒØ�—‘˜v a b˜zÒ*ä˜6“{ aÒ'Ð'Ð'Ü‘‘ ¨¨ Ò,r   c                 ó¬   — t        |«      }|dk(  r | j                  |Ž  y |dkD  r t        |«      D ]  } | j                  |Ž  Œ y  | j                  |Ž  y )Nr   )r    r*   r   r"   )r   Úpointsr)   Úsegments       r   r#   zCu2QuPen.curveToG   s]   € Ü�‹KˆØ�Š6àˆD×Ñ Ò(Ø�ŠUÜ6°vÓ>ò .�Ø#�×#Ñ# WÒ-ñ.ð ˆD�M‰M˜6Ò"r   ©FNT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r*   r#   Ú__classcell__)r   s   @r   r   r      s"   ø„ ñð(  ØØõ+ô-ö	#r   r   c                   ó¤   — e Zd ZdZdej
                  fdej
                  fdej                  fdej
                  fdœZ	 	 	 dd„Zd„ Z	d	„ Z
d
„ Zd„ Zy)ÚCu2QuPointPena  A filter pen to convert cubic bezier curves to quadratic b-splines
    using the FontTools PointPen protocol.

    Args:
        other_point_pen: another PointPen used to draw the transformed outline.
        max_err: maximum approximation error in font units. For optimal results,
            if you know the UPEM of the font, we recommend setting this to a
            value equal, or close to UPEM / 1000.
        reverse_direction: reverse the winding direction of all contours.
        stats: a dictionary counting the point numbers of quadratic segments.
        all_quadratic: if True (default), only quadratic b-splines are generated.
            if False, quadratic curves or cubic curves are generated depending
            on which one is more economical.
    r   r   r   )ÚmoveÚlineÚqcurver'   Nc                 óŒ   — t        j                  | «       |rt        |«      | _        n|| _        || _        || _        || _        y r   )r   r   r	   Úpenr   r   r   )r   Úother_point_penr   r   r   r   s         r   r   zCu2QuPointPen.__init__j   s>   € ô 	×&Ñ& tÔ,ÙÜ-¨oÓ>ˆD�Hà&ˆDŒHØˆŒØˆŒ
Ø*ˆÕr   c           	      ó:  — t        |«      dk\  sJ ‚|d   d   dk7  }g }|d   d   }|d   d   }|D �]E  \  }}|dk(  �r| j                  |«      D �]  }|d   \  }	}
}}|d   d   |d   d   }}||||	g}t        || j                  | j                  «      }| j
                  �Ct        t        |«      dz
  «      }| j
                  j                  |d«      dz   | j
                  |<   |dd D �cg c]  }|dd i f‘Œ
 }}|j                  |	|
||f«       | j                  st        |«      dk(  r|j                  d|g«       n|j                  d|g«       |d   d   }�Œ
 �Œ+|j                  ||g«       |d   d   }�ŒH |r|dd  |d d z   }| j                  |«       y c c}w )	Nr   r   r6   éÿÿÿÿr'   r   Fr8   )
r    Ú_split_super_bezier_segmentsr   r   r   r   r   r!   ÚappendÚ_drawPoints)r   ÚsegmentsÚclosedÚnew_segmentsÚprev_pointsÚprev_on_curveÚsegment_typer,   Ú
sub_pointsÚon_curveÚsmoothÚnameÚkwargsÚbcp1Úbcp2ÚcubicÚquadr)   ÚptÚ
new_pointss                       r   Ú_flushContourzCu2QuPointPen._flushContour{   sâ  € Ü�8‹} Ò!Ð!Ð!Ø˜!‘˜Q‘ 6Ñ)ˆØˆØ˜r‘l 1‘oˆØ# B™¨Ñ*ˆØ$,ó 	.Ñ ˆL˜&Ø˜wÓ&Ø"&×"CÑ"CÀFÓ"Kó 6�JØ5?À±^Ñ2�H˜f d¨FØ!+¨A¡¨qÑ!1°:¸a±=ÀÑ3C˜$�DØ*¨D°$¸ÐA�EÜ-¨e°T·\±\À4×CUÑCUÓV�DØ—z‘zÐ-Ü¤ D£	¨A¡Ó.˜Ø(,¯
©
¯©°q¸!Ó(<¸qÑ(@˜Ÿ
™
 1™ØBFÀqÈÀ*Ö!M¸B 2 u¨d°BÒ"7Ð!M�JÐ!MØ×%Ñ% x°¸¸vÐ&FÔGØ×)Ò)¬S°«_ÀÒ-AØ$×+Ñ+¨X°zÐ,BÕCà$×+Ñ+¨W°jÐ,AÔBØ$.¨r¡N°1Ñ$5’Mò6ð  ×#Ñ# \°6Ð$:Ô;Ø & r¡
¨1¡’ð'	.ñ( ð (¨¨Ð,¨|¸C¸RÐ/@Ñ@ˆLØ×Ñ˜Õ&ùò "Ns   Ã)Fc                 óØ  — g }t        |«      dz
  }|dk(  r|j                  |«       |S |dkD  rª|d   \  }}}}|dz
  }t        t        |D �	�
cg c]	  \  }	}
}
}
|	‘Œ c}
}	«      «      D ]m  \  }}g }|d d D ]  }|j                  |dd i f«       Œ ||dz
  k(  r|j                  ||||f«       n|j                  |d   dd i f«       |j                  |«       Œo |S t	        d|z  «      ‚c c}
}	w )Nr   r   r=   FTz$expected 2 control points, found: %d)r    r?   Ú	enumerater   ÚAssertionError)r   r,   Úsub_segmentsr)   rH   rI   rJ   rK   Únum_sub_segmentsrP   Ú_ÚirG   Únew_segmentÚpoints                  r   r>   z*Cu2QuPointPen._split_super_bezier_segmentsœ   s/  € Øˆä�‹K˜!‰OˆØ�Š6à×Ñ Ô'ð( Ðð' �ŠUà-3°B©ZÑ*ˆH�f˜d FØ  1™uÐÜ!*Ü+À6×,J±K°B¸¸1¸aªRÓ,JÓKó"ò 1‘��:ð !�Ø'¨¨˜_ò A�EØ×&Ñ&¨¨u°d¸BÐ'?Õ@ðAàÐ)¨AÑ-Ò.à×&Ñ&¨°&¸$ÀÐ'GÕHð  ×&Ñ&¨
°2©¸¸dÀBÐ'GÔHØ×#Ñ# KÕ0ð1ð Ðô !Ð!GÈ!Ñ!KÓLÐLùó -Ks   ÁC&c           
      ó$  — | j                   }|j                  «        g }| j                  }t        |«      D ]¦  \  }\  }}||v r�||   \  }}	 |	t	        |«      |«      sJ d|›d|› dt	        |«      › �«       ‚|d d }
|dk(  r|
}n"|
D ]  \  }}}} |j
                  |d ||fi |¤Ž Œ |d   \  }}}}|€|dk(  sJ ‚Œƒ |j
                  ||||fi |¤Ž Œšt        d|z  «      ‚ |D ]  \  }}}} |j
                  |d ||fi |¤Ž Œ |j                  «        y )Nzillegal z segment point count: expected z, got r=   r   r8   zunexpected segment type: %r)r:   Ú	beginPathÚ_Cu2QuPointPen__points_requiredrT   r    ÚaddPointrU   ÚendPath)r   rA   r:   Úlast_offcurvesÚpoints_requiredrY   rF   r,   r)   ÚopÚ	offcurvesrP   rI   rJ   rK   s                  r   r@   zCu2QuPointPen._drawPoints¸   st  € Ø�h‰hˆØ�‰ŒØˆØ×0Ñ0ˆÜ)2°8Ó)<ò 	SÑ%ˆAÑ%�˜fØ˜Ñ.Ø'¨Ñ5‘��2Ùœ#˜f›+ qÔ)ð Ø˜|Ð.ð / Ø !˜s &¬¨V«¨ð7óÐ)ð # 3 B˜K�	Ø˜’6ð &/‘Nà4=ò GÑ0˜˜F D¨&Ø$˜Ÿ™ R¨¨v°tÑF¸vÓFðGà+1°"©:Ñ(��F˜D &Ø�:Ø'¨8Ò3Ð3Ð3ð à �C—L‘L  \°6¸4ÑJÀ6ÓJä$Ð%BÀ\Ñ%QÓRÐRð3	Sð4 )7ò 	;Ñ$ˆB�˜˜fØˆC�L‰L˜˜T 6¨4Ñ:°6Ó:ð	;à�‰�r   c                 óX   — | j                   �J ‚| j                  j                  ||«       y r   )ÚcurrentPathr:   ÚaddComponent)r   ÚbaseGlyphNameÚtransformations      r   rg   zCu2QuPointPen.addComponentÛ   s(   € Ø×ÑÐ'Ð'Ð'Ø�‰×Ñ˜m¨^Õ<r   r.   )r/   r0   r1   r2   ÚoperatorÚeqÚger^   r   rR   r>   r@   rg   © r   r   r5   r5   S   sg   „ ñð  �H—K‘KÐ Ø�H—K‘KÐ Ø�h—k‘kÐ"Ø�X—[‘[Ð!ñ	Ðð  ØØó+ò"'òBò8!óF=r   r5   c                   óZ   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zy)ÚCu2QuMultiPena  A filter multi-pen to convert cubic bezier curves to quadratic b-splines
    in a interpolation-compatible manner, using the FontTools SegmentPen protocol.

    Args:

        other_pens: list of SegmentPens used to draw the transformed outlines.
        max_err: maximum approximation error in font units. For optimal results,
            if you know the UPEM of the font, we recommend setting this to a
            value equal, or close to UPEM / 1000.
        reverse_direction: flip the contours' direction but keep starting point.

    This pen does not follow the normal SegmentPen protocol. Instead, its
    moveTo/lineTo/qCurveTo/curveTo methods take a list of tuples that are
    arguments that would normally be passed to a SegmentPen, one item for
    each of the pens in other_pens.
    c                 ó~   — |r|D �cg c]  }t        |d¬«      ‘Œ }}|| _        || _        d | _        d | _        y c c}w )NT)ÚoutputImpliedClosingLine)r   Úpensr   Ú	start_ptsÚcurrent_pts)r   Ú
other_pensr   r   r:   s        r   r   zCu2QuMultiPen.__init__õ   sO   € Ùð &öàô " #ÀÖEðˆJð ð ˆŒ	ØˆŒØˆŒØˆÕùòs   ‡:c                 ó2   — | j                   €t        d«      ‚y )NzmoveTo is required©rt   rU   ©r   s    r   Ú_check_contour_is_openz$Cu2QuMultiPen._check_contour_is_open   s   € Ø×ÑÐ#Ü Ð!5Ó6Ð6ð $r   c                 ó2   — | j                   �t        d«      ‚y )Nz closePath or endPath is requiredrw   rx   s    r   Ú_check_contour_is_closedz&Cu2QuMultiPen._check_contour_is_closed  s   € Ø×ÑÐ'Ü Ð!CÓDÐDð (r   c                 óš   — | j                   �?t        | j                   | j                  «      D ]  \  }} |j                  |Ž  Œ d | _         y y r   )rs   Úziprr   ÚmoveTo)r   rP   r:   s      r   Ú_add_moveTozCu2QuMultiPen._add_moveTo  sG   € Ø�>‰>Ð%Ü˜tŸ~™~¨t¯y©yÓ9ò  ‘��CØ�—
‘
˜B’ð à!ˆD�Nð &r   c                 ó`   — | j                  «        |x| _        | _        | j                  «        y r   )r{   rs   rt   r   )r   Úptss     r   r~   zCu2QuMultiPen.moveTo  s)   € Ø×%Ñ%Ô'Ø,/Ð/ˆŒ˜Ô)Ø×ÑÕr   c                 ó¬   — | j                  «        | j                  «        t        || j                  «      D ]  \  }} |j                  |Ž  Œ || _        y r   )ry   r   r}   rr   ÚlineTort   )r   r�   rP   r:   s       r   rƒ   zCu2QuMultiPen.lineTo  sM   € Ø×#Ñ#Ô%Ø×ÑÔÜ˜3 §	¡	Ó*ò 	‰GˆB�ØˆC�J‰J˜ŠOð	àˆÕr   c                 óN  — | j                  «        t        |d   «      dk(  r$| j                  |D �cg c]  }|d   f‘Œ
 c}«       y | j                  «        g }t	        || j
                  «      D ])  \  }} |j                  |Ž  |j                  |d   f«       Œ+ || _        y c c}w )Nr   r   r=   )	ry   r    rƒ   r   r}   rr   r"   r?   rt   )r   Ú
pointsListr,   rt   r:   s        r   r"   zCu2QuMultiPen.qCurveTo  s    € Ø×#Ñ#Ô%Üˆz˜!‰}Ó Ò"Ø�K‰K°JÖ?¨&˜& ™)šÒ?Ô@ØØ×ÑÔØˆÜ˜z¨4¯9©9Ó5ò 	.‰KˆF�CØˆC�L‰L˜&Ñ!Ø×Ñ  r¡
˜}Õ-ð	.ð 'ˆÕùò @s   ±B"c                 ó  — g }t        | j                  |«      D ]  \  }}|j                  ||z   «       Œ t        || j                  gt        |«      z  «      }g }|D ]  }|j                  |dd  «       Œ | j                  |«       y )Nr   )r}   rt   r?   r   r   r    r"   )r   r…   Úcurvesr   r,   Ú
quadraticsÚ	quadratics          r   Ú_curves_to_quadraticz"Cu2QuMultiPen._curves_to_quadratic&  sˆ   € ØˆÜ"% d×&6Ñ&6¸
Ó"Cò 	/ÑˆJ˜Ø�M‰M˜* vÑ-Õ.ð	/ä(¨°$·,±,°Ä#ÀfÃ+Ñ1MÓNˆ
Øˆ
Ø#ò 	-ˆIØ×Ñ˜i¨¨˜mÕ,ð	-à�‰�jÕ!r   c                 óF   — | j                  «        | j                  |«       y r   )ry   rŠ   )r   r…   s     r   r#   zCu2QuMultiPen.curveTo0  s   € Ø×#Ñ#Ô%Ø×!Ñ! *Õ-r   c                 óš   — | j                  «        | j                  €!| j                  D ]  }|j                  «        Œ d x| _        | _        y r   )ry   rs   rr   Ú	closePathrt   ©r   r:   s     r   r�   zCu2QuMultiPen.closePath4  sC   € Ø×#Ñ#Ô%Ø�>‰>Ð!Ø—y‘yò  �Ø—‘•ð à,0Ð0ˆÔ˜4�>r   c                 óš   — | j                  «        | j                  €!| j                  D ]  }|j                  «        Œ d x| _        | _        y r   )ry   rs   rr   r`   rt   rŽ   s     r   r`   zCu2QuMultiPen.endPath;  sC   € Ø×#Ñ#Ô%Ø�>‰>Ð!Ø—y‘yò �Ø—‘•ðà,0Ð0ˆÔ˜4�>r   c                 ó„   — | j                  «        t        || j                  «      D ]  \  }}|j                  ||«       Œ y r   )r{   r}   rr   rg   )r   Ú	glyphNameÚtransformationsÚtransr:   s        r   rg   zCu2QuMultiPen.addComponentB  s<   € Ø×%Ñ%Ô'Ü˜o¨t¯y©yÓ9ò 	/‰JˆE�3Ø×Ñ˜Y¨Õ.ñ	/r   N)F)r/   r0   r1   r2   r   ry   r{   r   r~   rƒ   r"   rŠ   r#   r�   r`   rg   rm   r   r   ro   ro   à   sD   „ ñó(	 ò7òEò"òò
ò
'ò"ò.ò1ò1ó/r   ro   )rj   ÚfontTools.cu2qur   r   ÚfontTools.pens.basePenr   ÚfontTools.pens.filterPenr   Ú fontTools.pens.reverseContourPenr   ÚfontTools.pens.pointPenr   r	   r   r5   ro   rm   r   r   ú<module>r™      sE   ðó ß CÝ >Ý .Ý >Ý 9Ý :ô8#ˆyô 8#ôvJ=Ð)ô J=÷Ze/ò e/r   