+
    f7i 0  c                   sv    ^ RI t ] P                  t^ RIHt ^ RIH	t	 ^ RI
t
^ RIHtHtHt R.t] P                   ] P"                  ! ] P$                  4      ] P&                  ! ] P(                  ] P*                  ] P*                  ] P*                  ] P*                  R7      ] P&                  ! ] P*                  ] P*                  R7      R	 4       4       4       4       t] P&                  ! ] P*                  ] P*                  ] P*                  ] P*                  R
7      R 4       t] P                   ] P&                  ! ] P$                  ] P$                  ] P$                  ] P(                  ] P(                  ] P(                  ] P(                  ] P*                  ] P*                  ] P*                  ] P*                  R7      R 4       4       t] P&                  ! ] P$                  ] P$                  ] P$                  ] P*                  ] P*                  ] P*                  R7      R 4       t]]]]3,          ]3,          t] P&                  ! ] P$                  ] P$                  R7      R,R R ll4       t]	! R. R-O4      t] P&                  ! R./ R] P$                  bR] P$                  bR] P$                  bR] P$                  bR] P$                  bR] P$                  bR] P$                  bR] P(                  bR] P(                  bR] P(                  bR] P(                  bR ] P(                  bR!] P$                  bR] P$                  bR"] P$                  bR#] P*                  bR$] P*                  bR%] P*                  bR&] P*                  bR'] P*                  bR(] P*                  b R,R) l4       tR* t] R+8X  d
   ]! 4        R# R#   ]]3 d    ^ RIH t   ELi ; i)/    N)cython)splitCubicAtTC)
namedtuple)ListTupleUnionquadratic_to_curves)	tolerancep0p1p2p3)midderiv3c                s   \        V4      V8:  d   \        V4      V8:  d   R# V ^W,           ,          ,           V,           R,          p\        V4      V8  d   R# W2,           V,
          V ,
          R,          p\        W V,           R,          WV,
          WT4      ;'       d"    \        WUV,           W#,           R,          W44      # )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.
Tg      ?F      ?)abscubic_farthest_fit_inside)r	   r
   r   r   r   r   r   s   &&&&&  </usr/lib64/python3.14/site-packages/fontTools/qu2cu/qu2cu.pyr   r   (   s    : 2w)B9 4 RW"e
+C
3x)glR5(F$
"WOS\3 W W
#Cv3
VW    r	   r
   r   Zp1_2_3c                sX    VR,          pV V R,          V,           VR,          V,           V3# )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                s    RpRp^.p\        ^V4       F  pWV,           ,          pWV,           ^,
          ,          pV^ ,          V^,          8X  g   Q h\        V^,          V^ ,          ,
          4      \        V^,          V^,          ,
          4      ,          p	W9,          pWC,          pVP                  V4       K  	  VRR  U
u. uF  qV,          NK  	  pp
W,          ^ ,          pW,          ^,          pWV,           ^,
          ,          ^,          pWV,           ^,
          ,          ^,          pYV,
          V'       d
   V^ ,          M^,          ,           pYV,
          V'       d   ^VR,          ,
          M^,          ,           pWW3pW3# u up
i )z}Give a cubic-Bezier spline, reconstruct one cubic-Bezier
that has the same endpoints and tangents and approxmates
the spline.g      ?N)ranger   append)curvesr   r   r   r   tsr   ZckZc_beforer   r   r	   r
   r   r   curves   &&&             r   merge_curvesr$   e   sS   ( JI
B1a[AI!)a-( !u###BqEBqEM"S!x{)B%CC
	
		)  "$CR	)Ai--B	)	q	B	q	B		A	q	!B		A	q	!B 
BwB2a5A.	.B	Bw2A2J15	5BRE9 
*s   F)countnum_offcurvesioff1off2onc                 s   \        V 4      p^ p\        V 4      ^,
          p\        ^V4       FY  pW,          pW^,           ,          pWVV,
          R,          ,           pVP                  V^,           V,           V4       V^,          pK[  	  V# )r    r   )listlenr   Zinsert)pqr%   r&   r'   r(   r)   r*   s   &       r   add_implicit_on_curvesr/      sy     	QAEFQJM1m$tQxD[C''	Q#
 % Hr   )cost
is_complexc                s    V ^8  d   QhR\         \         \        ,          ,          R\        R\        R\         \        \        R3,          ,          /# )i   quadsmax_err	all_cubicZreturn.)r   PointfloatZboolr   )Zformats   "r   __annotate__r7      sG     6 6U66 6 
%s

	6r   c                s   \        V ^ ,          ^ ,          4      \        J pV'       g2   V  UUUu. uF!  qD UUu. uF  w  rV\        WV4      NK  	  uppNK#  	  p pppV ^ ,          ^ ,          .p^.p^p	V  F  pVR,          V^ ,          8X  g   Q h\        \        V4      ^,
          4       F.  p
V	^,          p	VP	                  V	4       VP	                  V	4       K0  	  \        V4      R,          pVP                  4        VP                  V4       V	^,          p	VP	                  V	4       K  	  \        WxW4      pV'       g<   V Uu. uF/  p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      NK1  	  ppV# u uppi u upppi u upi )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.

    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
:i   NNc              3   sP   "   T F  qP                   VP                  3x  K  	  R # 5iN)ZrealZimag).0Zcs   & r   	<genexpr>Z&quadratic_to_curves.<locals>.<genexpr>   s     8%Q(%s   $&r   )
Ztypecomplexr   r,   r    r/   ZpopZextendspline_to_curvestuple)r2   r3   r4   r1   r-   ZxZyr.   costsr0   r'   Zqqr!   r#   s   &&&           r   r   r      sD   F eAhqk"g-J:?@%Qa0aFQ'!-a0%@	q!ACEDu!}}s1vz"AAIDLLLL # $A&r*				T  a;FFLMfU%%8%8%%8%88fMM+ 1@( Ns"   	F E:F F%F:F Solutionerroris_cubicr'   jr   r   i_sol_countj_sol_countZthis_sol_countr   erri_sol_errorj_sol_errorr4   r%   r	   r
   r   r   vuc           
     sV	   \        V 4      ^8  g   Q R4       h\        ^ \        V 4      ^,
          ^4       Uu. uF  p\        WV^,            !  NK  	  pp\        4       p\        ^\        V4      4       F  pWT^,
          ,          ^,          pWT,          ^ ,          pWT,          ^,          p	\	        W,
          4      \	        W,
          4      ,           V\	        W,
          4      ,           8  g   K{  VP                  V4       K  	  \        ^ ^ ^ R4      .p
\        \        V4      ^,          ^,           ^ ^R4      p^ p\        ^\        V4      ^,           4       EF.  pTp\        W4       EF  pW,          P                  W,          P                  ppV'       ge   V^V,          ^,
          ,          V^V,          ,          ,
          ^,           pVV,           pTp\        VVWN,
          R4      pVV8  d   TpV^8:  d   K   \        W^WN,
          4      w  pp\        . TOTO5!  p. p^ p\        T4       F[  w  ppY^T,           ,          p\	        T^,          T^,          ,
          4      p\        TT4      pTT8  d    MTP                  T4       K]  	  TT8  d   EK0  \        T4       Fx  w  ppY^T,           ,          p\        ;QJ d    . R \!        TT4       4       F  NK  	  5M! R \!        TT4       4       4      w  rxp	p\#        YxT	TT4      '       d   Ko  T^,           p M	  TT8  d   EK  T^,           p\        TT4      p\        TTYN,
          R4      pTT8  d   TpT^8X  g   EK   M	  V
P                  V4       WF9   g   EK,  TpEK1  	  . p. p \        V
4      ^,
          pV'       dR   W,          P$                  W,          P&                  p"p!VP                  V4       V P                  V"4       VV!,          pKY  . p#^ p\)        \+        \!        VV 4      4      4       Ft  w  pp"V"'       d*   V#P                  \        W^WN,
          4      ^ ,          4       M;\        W4       F,  pV#P                  V V^,          V^,          ^,            4       K.  	  TpKv  	  V## u upi   \         d     EKA  i ; i)a.  
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).
z+quadratic spline requires at least 3 pointsFc              3   s6   "   T F  w  rW,
          x  K  	  R # 5ir8   r   )r9   rH   rI   s   &  r   r:   Z#spline_to_curves.<locals>.<genexpr>T  s     &L9Kquu9Ks   T)r,   r   r   Zsetr   Zaddr?   
num_pointsr@   r$   ZZeroDivisionErrorr   Z	enumerateZmaxr    r=   Zzipr   start_indexrA   Zreversedr+   )$r.   r>   r   r4   r'   Zelevated_quadraticsZforcedr	   r
   r   ZsolsZ
impossibler   Zbest_solrB   rD   rG   Z
this_countrC   rF   Zi_solr#   r"   Zreconstructed_iterZreconstructedr@   r   ZreconstZorigrE   r   ZsplitsZcubicr%   rA   r!   s$   &&&&                                r   r<   r<      s   B q6Q;EEE; 383q6A:q2I2IQ1Q<(2I  
 UF1c-./ Q'* #A& #A&rw<#bg,&S\)AAJJqM 0 Q1e$%D#12Q6:Aq%HJE1c-.23uA'+w'9'947==K"1q519-a!e<q@
)J6) k15%H8#$H?()<G	r
 "0!<!<!<M E'(:;
7*q51'!*tAw./E39$$$W- < y  (6
7*q51!&&LWd9K&L&LWd9K&L!LB0RKK%ME 7 y  &/Kk51K[+qudCEx ay !| 	H;EE 4J FED	AA
'--tw/?/?xaX	U
F	AS%7 898MM,':quEaHI1[aAA	23 ! : MSN % s   R;RR('R(c                  s.   ^ RI Hp  ^ RIHp RpV^,          pV ! 4       pV! WB4      p\	        RW#3,          4       \	        R\        V4      ,          4       \        V.V4      p\	        R\        V4      ,          4       \	        RV4       \	        RV4       R	# )
r    )generate_curve)curve_to_quadraticg?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):N)ZfontTools.cu2qu.benchmarkrL   ZfontTools.cu2qurM   Zprintr,   r   )rL   rM   r   Zreconstruct_tolerancer#   Z
quadraticsr!   s          r   mainrN     s    82I%ME#E5J	1Y4VV 

7#j/
IJ */DEF	
9CK
GH	
U#	
#V,r   Z__main__)r   F)rJ   r@   rK   rA   r   )!r   ZAttributeErrorZImportErrorZfontTools.miscZcompiledZCOMPILEDZfontTools.misc.bezierToolsr   Zcollectionsr   ZmathZtypingr   r   r   Z__all__ZcfuncZreturnsZintZlocalsZdoubler;   r   r   r$   r/   r6   r5   r   r?   r<   rN   Z__name__r   r   r   <module>rO      sz  && ?? 5 "   !
! 

mm~~~~~~~~ 6>>&..9W :  W@ ~~~~~~>>	

 
**jjjj}}mm
--mm~~~~~~~~$ $N 
****jj		~~

 	eE5L!7*+ 	zz6	6r j"TU  jjjj jj **	
 

 

 :: mm 	 --   jj ZZ **  ~~!" ~~#$ ~~%& ~~'( nn)* nn+.v/.vr-$ zF  	$ &%%&s   N% %N87N8