Ë
    ÚÍ:j=3  ã                   ó”  — 	 d dl Z e j                  Zd dlmZ d dlm	Z	 d dl
Z
d dlmZmZmZ dgZe j                    e j"                  e j$                  «       e j&                  e j(                  e j*                  e j*                  e j*                  e j*                  ¬«       e j&                  e j*                  e j*                  ¬«      d	„ «       «       «       «       Z e j&                  e j*                  e j*                  e j*                  e j*                  ¬
«      d„ «       Ze j                    e j&                  e j$                  e j$                  e j$                  e j(                  e j(                  e j(                  e j(                  e j*                  e j*                  e j*                  e j*                  ¬«      d„ «       «       Z e j&                  e j$                  e j$                  e j$                  e j*                  e j*                  e j*                  ¬«      d„ «       Zeeeef   ef   Zd„ Zd„ Zd„ Z e j&                  e j$                  e j$                  ¬«      	 	 d3deee      dededeeedf      fd„«       Z  e	dg d¢«      Z! e j&                  d4i de j$                  “de j$                  “de j$                  “de j$                  “d e j$                  “d!e j$                  “d"e j$                  “d#e j(                  “d$e j(                  “d%e j(                  “d&e j(                  “d'e j(                  “de j$                  “d(e j$                  “d)e j$                  “d*e j*                  “d+e j*                  “d,e j*                  “d-e j*                  “d.e j*                  “d/e j*                  “Žd3d0„«       Z"d1„ Z#e$d2k(  r e#«        yy# eef$ r
 d dlm Z  Y �ŒÀw xY w)5é    N)Úcython)ÚsplitCubicAtTC)Ú
namedtuple)ÚListÚTupleÚUnionÚquadratic_to_curves)Ú	toleranceÚp0Úp1Úp2Úp3)ÚmidÚderiv3c                 óü   — t        |«      |k  rt        |«      |k  ry| d||z   z  z   |z   dz  }t        |«      |kD  ry||z   |z
  | z
  dz  }t        | | |z   dz  ||z
  ||«      xr t        |||z   ||z   dz  ||«      S )a�  Check if a cubic Bezier lies within a given distance of the origin.

    "Origin" means *the* origin (0,0), not the start of the curve. Note that no
    checks are made on the start and end positions of the curve; this function
    only checks the inside of the curve.

    Args:
        p0 (complex): Start point of curve.
        p1 (complex): First handle of curve.
        p2 (complex): Second handle of curve.
        p3 (complex): End point of curve.
        tolerance (double): Distance from origin.

    Returns:
        bool: True if the cubic Bezier ``p`` entirely lies within a distance
        ``tolerance`` of the origin, False otherwise.
    Té   g      À?Fç      à?)ÚabsÚcubic_farthest_fit_inside)r   r   r   r   r
   r   r   s          új/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/fontTools/qu2cu/qu2cu.pyr   r   (   s©   € ô: ˆ2ƒw�)Ò¤ B£¨9Ò 4Øð ��R˜"‘W‘Ñ Ñ" eÑ
+€CÜ
ˆ3ƒx�)ÒØØ�2‰g˜‰l˜RÑ 5Ñ(€FÜ$Ø
ˆR�"‰W˜‰O˜S 6™\¨3°	óò Wä
# C¨¨v©¸¸R¹À3±ÈÈIÓ
VðWó    ©r   r   r   Úp1_2_3c                 ó0   — |dz  }| | dz  |z   |dz  |z   |fS )zAGiven a quadratic bezier curve, return its degree-elevated cubic.gUUUUUUå?gUUUUUUÕ?© r   s       r   Úelevate_quadraticr   R   s5   € ð �5‰\€Fà
Ø	ˆu‰˜Ñ	Ø	ˆu‰˜Ñ	Ø
ð	ð r   )ÚstartÚnÚkÚ
prod_ratioÚ	sum_ratioÚratioÚtr   r   r   r   c                 óè  — d}d}dg}t        d|«      D ]f  }| ||z      }| ||z   dz
     }|d   |d   k(  sJ ‚t        |d   |d   z
  «      t        |d   |d   z
  «      z  }	||	z  }||z  }|j                  |«       Œh |dd D �
cg c]  }
|
|z  ‘Œ	 }}
| |   d   }| |   d   }| ||z   dz
     d   }| ||z   dz
     d   }|||z
  |r|d   ndz  z   }|||z
  |rd|d   z
  ndz  z   }||||f}||fS c c}
w )z…Give a cubic-Bezier spline, reconstruct one cubic-Bezier
    that has the same endpoints and tangents and approxmates
    the spline.g      ð?é   r   r   é   Néÿÿÿÿ)Úranger   Úappend)Úcurvesr   r   r    r!   Útsr   ÚckÚc_beforer"   r#   r   r   r   r   Úcurves                   r   Úmerge_curvesr/   e   sq  € ð( €JØ€IØ
ˆ€BÜ�1�a‹[ò 
ˆØ�E˜A‘IÑˆØ˜% !™) a™-Ñ(ˆð �!‰u˜ ™Ò#Ð#Ð#Ü�B�q‘E˜B˜q™E‘MÓ"¤S¨°!©°xÀ±{Ñ)BÓ%CÑCˆà�eÑˆ
Ø�ZÑˆ	Ø
�	‰	�)Õð
ð "$ C R Ö	)˜Aˆ!ˆi‹-Ð	)€BÐ	)à	�‰�qÑ	€BØ	�‰�qÑ	€BØ	�˜‘	˜A‘Ñ	˜qÑ	!€BØ	�˜‘	˜A‘Ñ	˜qÑ	!€Bð 
ˆr�B‰w¡B˜2˜aš5¨AÑ.Ñ	.€BØ	ˆr�B‰w©2˜A  2¡šJ°1Ñ5Ñ	5€Bà��R˜Ð€Eà�"ˆ9Ðùò 
*s   ÂC/)ÚcountÚnum_offcurvesÚiÚoff1Úoff2Úonc                 óÈ   — t        | «      }d}t        | «      dz
  }t        d|«      D ]7  }| |   }| |dz      }|||z
  dz  z   }|j                  |dz   |z   |«       |dz  }Œ9 |S )Nr   r&   r%   r   )ÚlistÚlenr(   Úinsert)ÚpÚqr0   r1   r2   r3   r4   r5   s           r   Úadd_implicit_on_curvesr<   š   s„   € ô 	ˆQ‹€AØ€EÜ˜“F˜Q‘J€MÜ�1�mÓ$ò ˆØ�‰tˆØ��Q‘‰xˆØ�T˜D‘[ CÑ'Ñ'ˆØ	�‰��Q‘˜‘ Ô#Ø�‰
‰ðð €Hr   c                 ó$   — t        d|›d| ›�«      ‚)Nz1Quadratic splines must connect end-to-start; got z then ©Ú
ValueError)ÚpointÚprevious_points     r   Ú_raise_incompatible_pointrB   ²   s"   € Ü
Ø
;¸NÐ;MÈVÐTYÐS\Ð]óð r   c                 ó6   — t        | «      dk  rt        d«      ‚y )Nr   z0Quadratic splines must contain at least 3 points)r8   r?   )Úsplines    r   Ú_validate_spline_lengthrE   ¸   s   € Ü
ˆ6ƒ{�Q‚ÜÐKÓLÐLð r   c                 ó$   — | dk  rt        d«      ‚y )Nr   z!max_err must be greater than zeror>   )Úmax_errs    r   Ú_validate_positive_tolerancerH   ½   s   € Ø�!‚|ÜÐ<Ó=Ð=ð r   )ÚcostÚ
is_complexÚquadsrG   Ú	all_cubicÚreturn.c                 óÐ  — | sg S t        |«       | D ]  }t        |«       Œ t        | d   d   «      t        u }|s0| D ���cg c]!  }|D ��cg c]  \  }}t        ||«      ‘Œ c}}‘Œ# } }}}| d   d   g}dg}	d}
| D ]§  }|d   |d   k7  rt	        |d   |d   «       t        t        |«      dz
  «      D ])  }|
dz  }
|	j                  |
«       |	j                  |
«       Œ+ t        |«      dd }|	j                  «        |j                  |«       |
dz  }
|	j                  |
«       Œ© t        ||	||«      }|s|D �cg c]  }t        d„ |D «       «      ‘Œ }}|S c c}}w c c}}}w c c}w )aÇ  Converts a connecting list of quadratic splines to a list of quadratic
    and cubic curves.

    A quadratic spline is specified as a list of points.  Either each point is
    a 2-tuple of X,Y coordinates, or each point is a complex number with
    real/imaginary components representing X,Y coordinates.

    The first and last points are on-curve points and the rest are off-curve
    points, with an implied on-curve point in the middle between every two
    consequtive off-curve points.

    Returns:
        The output is a list of tuples of points. Points are represented
        in the same format as the input, either as 2-tuples or complex numbers.
        If ``quads`` is empty, returns an empty list.

        Each tuple is either of length three, for a quadratic curve, or four,
        for a cubic curve.  Each curve's last point is the same as the next
        curve's first point.

    Args:
        quads: quadratic splines

        max_err: absolute error tolerance; defaults to 0.5

        all_cubic: if True, only cubic curves are generated; defaults to False

    Raises:
        ValueError: if an input spline has fewer than 3 points, or if adjacent
        splines do not connect end-to-start.
    r   r%   r'   r&   Nc              3   óL   K  — | ]  }|j                   |j                  f–— Œ y ­w©N)ÚrealÚimag)Ú.0Úcs     r   ú	<genexpr>z&quadratic_to_curves.<locals>.<genexpr>  s   è ø€ Ò8¨Q˜Ÿ™ §¡Ô(Ñ8ùs   ‚"$)rH   rE   ÚtypeÚcomplexrB   r(   r8   r)   r<   ÚpopÚextendÚspline_to_curvesÚtuple)rK   rG   rL   rD   rJ   r:   ÚxÚyr;   ÚcostsrI   r2   Úqqr*   r.   s                  r   r	   r	   Â   s}  € ñP Øˆ	Ü  Ô)Øò (ˆÜ Õ'ð(ô �e˜A‘h˜q‘kÓ"¤gÐ-€JÙØ:?×@Ð@°Q¨a×0¡F Q¨”'˜!˜Q•-Õ0Ð@ˆÒ@à	ˆq‰�!‰ˆ€AØˆC€EØ€DØò ˆØˆR‰5�A�a‘DŠ=Ü% a¨¡d¨A¨b©EÔ2Ü”s˜1“v ‘zÓ"ò 	ˆAØ�A‰IˆDØ�L‰L˜ÔØ�L‰L˜Õð	ô $ AÓ& q rÐ*ˆØ�	‰	ŒØ	�‰�ŒØ�‰	ˆØ�‰�TÕðô ˜a ¨°Ó;€FáØFLÖM¸U”%Ñ8°%Ô8Õ8ÐMˆÐMØ€Mùó- 1ùÔ@ùò* Ns   Á
EÁEÁ!EÄ9E#ÅEÚSolution)Ú
num_pointsÚerrorÚstart_indexÚis_cubicr2   Újr   r   Úi_sol_countÚj_sol_countÚthis_sol_countr
   Úerrrb   Úi_sol_errorÚj_sol_errorrd   r0   r   r   r   r   ÚvÚuc           
      ó0  — t        | «      dk\  sJ d«       ‚t        dt        | «      dz
  d«      D �cg c]  }t        | ||dz    Ž ‘Œ }}t        «       }t        dt        |«      «      D ]^  }||dz
     d   }||   d   }||   d   }	t	        ||z
  «      t	        |	|z
  «      z   |t	        |	|z
  «      z   kD  sŒN|j                  |«       Œ` t        dddd«      g}
t        t        |«      dz  dz   ddd«      }d}t        dt        |«      dz   «      D �]”  }|}t        ||«      D �]f  }|
|   j                  |
|   j                  }}|s<|d|z  dz
     |d|z     z
  dz   }||z   }|}t        ||||z
  d«      }||k  r|}|dk  rŒ`	 t        ||||z
  «      \  }}t        g |¢|¢­Ž }g }d}t        |«      D ]E  \  }}|||z      }t	        |d   |d   z
  «      }t        ||«      }||kD  r n|j                  |«       ŒG ||kD  rŒÞt        |«      D ]D  \  }}|||z      }t        d„ t!        ||«      D «       «      \  }}}	}t#        |||	||«      rŒ?|dz   } n ||kD  r�Œ7|dz   }t        ||«      }t        ||||z
  d«      }||k  r|}|dk(  s�Œg n |
j                  |«       ||v s�Œ“|}�Œ— g }g } t        |
«      dz
  }|rH|
|   j$                  |
|   j&                  }"}!|j                  |«       | j                  |"«       ||!z  }|rŒHg }#d}t)        t+        t!        || «      «      «      D ]Z  \  }}"|"r#|#j                  t        ||||z
  «      d   «       n.t        ||«      D ]  }|#j                  | |dz  |dz  dz    «       Œ! |}Œ\ |#S c c}w # t        $ r Y �Œtw xY w)	aF  
    q: quadratic spline with alternating on-curve / off-curve points.

    costs: cumulative list of encoding cost of q in terms of number of
      points that need to be encoded.  Implied on-curve points do not
      contribute to the cost. If all points need to be encoded, then
      costs will be range(1, len(q)+1).
    r   z+quadratic spline requires at least 3 pointsr   r&   r%   Fc              3   ó,   K  — | ]  \  }}||z
  –— Œ y ­wrP   r   )rS   rl   rm   s      r   rU   z#spline_to_curves.<locals>.<genexpr>p  s   è ø€ Ò&L±°°A q¨1¥uÑ&Lùs   ‚T)r8   r(   r   Úsetr   Úaddr`   ra   rb   r/   ÚZeroDivisionErrorr   Ú	enumerateÚmaxr)   r[   Úzipr   rc   rd   Úreversedr7   )$r;   r^   r
   rL   r2   Úelevated_quadraticsÚforcedr   r   r   ÚsolsÚ
impossibler   Úbest_solre   rg   rk   Ú
this_countrf   rj   Úi_solr.   r+   Úreconstructed_iterÚreconstructedrb   r   ÚreconstÚorigri   r   ÚsplitsÚcubicr0   rd   r*   s$                                       r   rZ   rZ     s`  € ôB ˆq‹6�QŠ;ÐEÐEÓEˆ;ô 38¸¼3¸q»6ÀA¹:ÀqÓ2IöØ-.Ô˜1˜Q  Q¡˜<Ò(ðÐð ô
 ‹U€FÜ�1”cÐ-Ó.Ó/ò ˆØ   Q¡Ñ'¨Ñ*ˆØ  Ñ# AÑ&ˆØ  Ñ# AÑ&ˆÜˆr�B‰w‹<œ#˜b 2™g›,Ñ&¨´S¸¸b¹³\Ñ)AÓAØ�J‰J�q�Mðô �Q˜˜1˜eÓ$Ð%€DÜœ#Ð1Ó2°QÑ6¸Ñ:¸A¸qÀ%ÓH€JØ€EÜ�1”cÐ-Ó.°Ñ2Ó3ó BˆØˆÜ�u˜a“ó <	ˆAØ'+¨A¡w×'9Ñ'9¸4À¹7¿=¹=˜ˆKáà" 1 q¡5¨1¡9Ñ-°°a¸!±e±Ñ<¸qÑ@�
Ø)¨JÑ6�Ø)�Ü  ¨k¸1¸q¹5À%ÓH�Ø˜8Ò#Ø$�Hà ’?àðÜ(Ð)<¸aÀÀQÁÓG‘	��rô
 "0Ð!<°Ð!<¸Ò!<ÐØˆMð ˆEÜ'Ð(:Ó;ò .‘
��7Ø*¨1¨q©5Ñ1�Ü˜' !™* t¨A¡wÑ.Ó/�Ü˜E 3›�Ø˜9Ò$ÙØ×$Ñ$ WÕ-ð.ð �yÒ àô (¨Ó6ò ‘
��7Ø*¨1¨q©5Ñ1�Ü!&Ñ&L¼¸WÀdÓ9KÔ&LÓ!L‘��B˜˜Bä0°°R¸¸RÀÕKØ%¨™M�EÙðð �yÒ áð &¨™/ˆKÜ˜k¨5Ó1ˆKÜ˜[¨+°q¸1±u¸dÓCˆEØ�xÒØ �à˜aÔáðy<	ð| 	�‰�HÔØ�‹;ØŠEðEBðJ €FØ€EÜˆD‹	�A‰€AÙ
Ø˜q™'×-Ñ-¨t°A©w×/?Ñ/?ˆxˆØ�‰�aÔØ�‰�XÔØ	ˆU‰
ˆò	 ð
 €FØ	€AÜ¤¤S¨°Ó%7Ó 8Ó9ò ‰ˆˆ8ÙØ�M‰Mœ,Ð':¸A¸qÀ1¹uÓEÀaÑHÕIä˜1˜a“[ò 4�Ø—‘˜a  A¡¨¨A©°©	Ð2Õ3ð4à‰ðð €MùòSøôN %ò Úðús   ±NÆNÎ	NÎNc                  ó  — ddl m}  ddlm} d}|dz  } | «       } |||«      }t	        d||fz  «       t	        dt        |«      z  «       t        |g|«      }t	        dt        |«      z  «       t	        d	|«       t	        d
|«       y )Nr   )Úgenerate_curve)Úcurve_to_quadraticgš™™™™™©?r%   z'cu2qu tolerance %g. qu2cu tolerance %g.z+One random cubic turned into %d quadratics.z-Those quadratics turned back into %d cubics. zOriginal curve:zReconstructed curve(s):)ÚfontTools.cu2qu.benchmarkr…   ÚfontTools.cu2qur†   Úprintr8   r	   )r…   r†   r
   Úreconstruct_tolerancer.   Ú
quadraticsr*   s          r   ÚmainrŒ   ž  sŒ   € Ý8Ý2à€IØ%¨™MÐÙÓ€EÙ# E¨9Ó5€JÜ	Ø1°YÐ@UÐ4VÑVôô 
Ð
7¼#¸j»/Ñ
IÔJÜ  * Ð/DÓE€FÜ	Ð
9¼CÀ»KÑ
GÔHÜ	Ð
˜UÔ#Ü	Ð
# VÕ,r   Ú__main__)r   Fr   )%r   ÚAttributeErrorÚImportErrorÚfontTools.miscÚcompiledÚCOMPILEDÚfontTools.misc.bezierToolsr   Úcollectionsr   ÚmathÚtypingr   r   r   Ú__all__ÚcfuncÚreturnsÚintÚlocalsÚdoublerW   r   r   r/   r<   ÚfloatÚPointrB   rE   rH   Úboolr	   r`   rZ   rŒ   Ú__name__r   r   r   ú<module>r¡      sã  ðð&&Ûð �?‰?€å 5Ý "Û ÷ñ ð !Ð
!€ð ‡�Ø€‡��—
‘
ÓØ€‡�Ø�m‰mØ‡~�~Ø‡~�~Ø‡~�~Ø‡~�~ôð €‡��6—>‘>¨&¯.©.Ô9ñWó :óó ó ðWð@ €‡�Ø‡~�~Ø‡~�~Ø‡~�~Ø�>‰>ô	ñ
óð
ð ‡�Ø€‡�Ø
�*‰*Ø‡j�jØ‡j�jØ�}‰}Ø�m‰mØ
�-‰-Ø‡m�mØ‡~�~Ø‡~�~Ø‡~�~Ø‡~�~ôñ$óó ð$ðN €‡�Ø
�*‰*Ø—*‘*Ø‡j�jØ	�‰Ø	�‰Ø‡~�~ôñ
óð
ð 	ˆe�E˜5�LÑ! 7Ð*Ñ+€òòMò
>ð
 €‡�Ø	�‰Ø�z‰zôð ØñBØ��U‘ÑðBàðBð ðBð 
ˆ%��s�
Ñ
Ñò	Bó	ðBñJ �jÒ"TÓU€ð €‡�ò Ø‡j‚jðà‡j‚jðð ‡j‚jðð �*Š*ð	ð
 —
’
ðð —
’
ðð —:’:ðð �mŠmðð 	�Šðð �-Š-ðð —’ðð —’ðð �jŠjðð �ZŠZðð �*Š*ðð  ‡~‚~ð!ð" ‡~‚~ð#ð$ ‡~‚~ð%ð& ‡~‚~ð'ð( ‡n‚nð)ð* ‡n‚nð+ò.vó/ð.vòr-ð$ ˆzÒÙ…Fð øðw 	˜Ð$ò &ç%Ð%ð&ús   ‚N6 Î6OÏO