+
    f7iBF  c                   s    ^ RI t ] P                  t^ RIt^RIHt	H
t
 RR.t^dt]! R4      t] P                  ] P                   ] P"                  ! ] P$                  4      ] P&                  ! ] P(                  ] P(                  ] P$                  R7      R 4       4       4       4       t] P                  ] P&                  ! ] P(                  ] P$                  R	7      ] P&                  ! ] P$                  ] P$                  R
7      R 4       4       4       t] P                  ] P                   ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      R 4       4       4       4       t] P                  ] P                   ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      R 4       4       4       4       t] P                  ] P                   ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      R 4       4       4       t] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  ] P4                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P$                  ] P$                  ] P$                  ] P4                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      R 4       4       4       4       t] P                  ] P                   ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  R7      R 4       4       4       4       t] P                  ] P                   ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      R 4       4       4       4       t] P                  ] P                   ] P"                  ! ] P(                  4      ] P&                  ! ] P$                  ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  R7      R 4       4       4       4       4       t] P                  ] P                   ] P"                  ! ] P(                  4      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P$                  R7      R 4       4       4       4       4       t] P                  ] P"                  ! ] P4                  4      ] P&                  ! ] P$                  ] P(                  ] P(                  ] P(                  ] P(                  R7      ] P&                  ! ] P(                  ] P(                  R7      R  4       4       4       4       t ] P                  ] P                   ] P&                  ! ] P$                  R!7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  ] P(                  R"7      R# 4       4       4       4       t!] P                  ] P&                  ! ] P4                  ] P$                  R$7      ] P&                  ! ] P4                  R%7      ] P&                  ! ] P4                  R&7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  R'7      ] P&                  ! ] P(                  ] P(                  ] P(                  ] P(                  ] P(                  R(7      R) 4       4       4       4       4       4       t"] P&                  ! ] P$                  R*7      ] P&                  ! ] P4                  R+7      ] P&                  ! ] P4                  R&7      R/R, l4       4       4       t#] P&                  ! ] P4                  ] P4                  ] P4                  R-7      ] P&                  ! ] P4                  R&7      R/R. l4       4       t$R#   ]]3 d    ^ RIH t   E	Lzi ; i)0i    N)cython)ErrorApproxNotFoundErrorcurve_to_quadraticcurves_to_quadraticZNaNZv1Zv2Zresultc                sj    WP                  4       ,          P                  p\        V4      R8  d   RpV# )zReturn the dot product of two vectors.

Args:
    v1 (complex): First vector.
    v2 (complex): Second vector.

Returns:
    double: Dot product.
gV瞯<g        )Z	conjugaterealabsr   s   && </usr/lib64/python3.14/site-packages/fontTools/cu2qu/cu2qu.pydotr	   %   s0     <<>!''F 6{UM    )zden)zrzic                sb    V P                   pV P                  p\        W!,          W1,          4      # )aL  Divide complex by real using Python's method (two separate divisions).

This ensures bit-exact compatibility with Python's complex division,
avoiding C's multiply-by-reciprocal optimization that can cause 1 ULP differences
on some platforms/compilers (e.g. clang on macOS arm64).

https://github.com/fonttools/fonttools/issues/3928
)r   imagcomplex)r   r   r   r   s   &&  r   _complex_div_by_realr   ?   s'     
B	
B28RX&&r
   )abcd)_1_2_3_4c                 s    Tp\        VR 4      V,           p\        W,           R 4      V,           pW,           V,           V,           pWEWg3#       @)r   )r   r   r   r   r   r   r   r      &&&&    r   calc_cubic_pointsr   P   sF     
B	a	%	)B	aeS	)B	.B	
QB2>r
   )p0p1p2p3c                 s    W,
          R ,          pW!,
          R ,          V,
          pT pW6,
          V,
          V,
          pWuWF3# r    )r   r   r    r!   r   r   r   r   r   r   calc_cubic_parametersr#   ^   s=     
CA	C!A
A

QA:r
   c           
     sh   V^8X  d   \        \        WW#4      4      # V^8X  d   \        \        WW#4      4      # V^8X  dq   \        WW#4      w  rV\        \        V^ ,          V^,          V^,          V^,          4      \        V^ ,          V^,          V^,          V^,          4      ,           4      # V^8X  dq   \        WW#4      w  rV\        \        V^ ,          V^,          V^,          V^,          4      \        V^ ,          V^,          V^,          V^,          4      ,           4      # \        WW#V4      # )a  Split a cubic Bezier into n equal parts.

Splits the curve into `n` equal parts by curve time.
(t=0..1/n, t=1/n..2/n, ...)

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.

Returns:
    An iterator yielding the control points (four complex values) of the
    subcurves.
)Zitersplit_cubic_into_twosplit_cubic_into_three_split_cubic_into_n_gen)r   r   r    r!   nr   r      &&&&&  r   split_cubic_into_n_iterr)   l   s   , 	Av(899Av*22:;;Av#BB3 1qtQqT1Q48"1Q41qtQqT:;
 	
 	Av#BB3"1Q41qtQqT:$QqT1Q41qt<=
 	

 #22155r
   )r   r   r    r!   r'   )dtdelta_2delta_3i)a1b1c1d1c              #   s  "   \        WW#4      w  rVrx^V,          p	W,          p
W,          p\        V4       F  pW,          pW,          pW[,          p^V,          V,          V,           V
,          p^V,          V,          V,           ^V,          V,          ,           V	,          pW],          V,          Wn,          ,           W},          ,           V,           p\        VVVV4      x  K  	  R# 5i)i   N)r#   ranger   )r   r   r    r!   r'   r   r   r   r   r*   r+   r,   r-   Zt1Zt1_2r.   r/   r0   r1   s   &&&&&              r   r&   r&      s      'rr6JA!	
QBgGlG1XVw[!ebj1n'!ebj1nq1ut|+r1Vd]QX%.2BB// s   C&C()midderiv3c                s    V ^W,           ,          ,           V,           R,          pW2,           V,
          V ,
          R,          pW V,           R,          WE,
          V3WDV,           W#,           R,          V33# )ad  Split a cubic Bezier into two equal parts.

Splits the curve into two equal parts at t = 0.5

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.

Returns:
    tuple: Two cubic Beziers (each expressed as a tuple of four complex
    values).
      ?      ?r"   )r   r   r    r!   r3   r4   s   &&&&  r   r$   r$      se    * RW"e
+CglR5(F	2g_clC0	FlRWOR0 r
   )mid1deriv1mid2deriv2c                s   ^V ,          ^V,          ,           ^V,          ,           V,           R,          pV^V,          ,           ^V ,          ,
          R,          pV ^V,          ,           ^V,          ,           ^V,          ,           R,          p^V,          ^V,          ,
          V ,
          R,          pV ^V ,          V,           R,          WE,
          V3WDV,           Wg,
          V3WfV,           V^V,          ,           R,          V33# )av  Split a cubic Bezier into three equal parts.

Splits the curve into three equal parts at t = 1/3 and t = 2/3

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.

Returns:
    tuple: Three cubic Beziers (each expressed as a tuple of four complex
    values).
r   gh/?r"   )r   r   r    r!   r7   r8   r9   r:   r   r   r%   r%      s    : FR"Wq2v%*v6D1r6kAF"v.FRK"r'!AF*v6D"fq2vo"v.F	a"frkS $-6	f}dmT2	f}rAF{c126 r
   )tr   r   r    r!   )_p1_p2c                s    WV,
          R,          ,           pWCV,
          R,          ,           pWVV,
          V ,          ,           # )aT  Approximate a cubic Bezier using a quadratic one.

Args:
    t (double): Position of control point.
    p0 (complex): Start point of curve.
    p1 (complex): First handle of curve.
    p2 (complex): Second handle of curve.
    p3 (complex): End point of curve.

Returns:
    complex: Location of candidate control point on quadratic curve.
g      ?r"   )r;   r   r   r    r!   r<   r=   r(   r   cubic_approx_controlr>      s5    0 R3
C
R3
C)q  r
   )abcdphc                s   W,
          pW2,
          pVR,          p \        W`V,
          4      \        We4      ,          pY%T,          ,           #   \         d.    Y8X  d   Y8X  g   Y#8X  d   Tu # \        \        \        4      u # i ; i)aU  Calculate the intersection of two lines.

Args:
    a (complex): Start point of first line.
    b (complex): End point of first line.
    c (complex): Start point of second line.
    d (complex): End point of second line.

Returns:
    complex: Location of intersection if one present, ``complex(NaN,NaN)``
    if no intersection was found.
y              ?)r	   ZZeroDivisionErrorr   NAN)r   r   r   r   r?   r@   rA   rB   r   r   calc_intersectrD     sv    $ 
B	
B
RA	!q5MCJ& Av:  !
 6qvHsC  !s   "A B-BB)	tolerancer   r   r    r!   c                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.
Tr5   Fr6   )r   cubic_farthest_fit_inside)r   r   r    r!   rE   r3   r4   r(   r   rF   rF   8  s    : 2w)B9 4 RW"e
+C
3x)glR5(F$
"WOS\3 W W
#Cv3
VWr
   )rE   )q1c0r0   c2c3c                s   \        V ^ ,          V ^,          V ^,          V ^,          4      p\        P                  ! VP                  4      '       d   R# V ^ ,          pV ^,          pW2V,
          R,          ,           pWBV,
          R,          ,           p\	        ^ WP^,          ,
          W`^,          ,
          ^ V4      '       g   R# W2V3# )a  Approximate a cubic Bezier with a single quadratic within a given tolerance.

Args:
    cubic (sequence): Four complex numbers representing control points of
        the cubic Bezier curve.
    tolerance (double): Permitted deviation from the original curve.

Returns:
    Three complex numbers representing control points of the quadratic
    curve if it fits within the given tolerance, or ``None`` if no suitable
    curve could be calculated.
NUUUUUU?)rD   mathZisnanr   rF   )cubicrE   rG   rH   rJ   r0   rI   s   &&     r   cubic_approx_quadraticrN   b  s    0 
a%(E!HeAh	?Bzz"''	qB	qB	Bw5!	!B	Bw5!	!B$Q1Xr!H}aSS2:r
   )r'   rE   )r-   )all_quadratic)rH   r0   rI   rJ   )q0rG   next_q1q2r1   c           	     s\   V^8X  d   \        W4      # V^8X  d
   VR8X  d   V # \        V ^ ,          V ^,          V ^,          V ^,          V4      p\        V4      p\        ^ V^ ,          V^,          V^,          V^,          4      pV ^ ,          pRpV ^ ,          V.p	\	        ^V^,           4       F  p
Vw  rrTpTpW8  df   \        V4      p\        W^,
          ,          V^ ,          V^,          V^,          V^,          4      pV	P                  V4       VV,           R,          pMTpTpW~,
          p\        V4      V8  gP   \        VVVV,
          R,          ,           V,
          VVV,
          R,          ,           V,
          VV4      '       d   K   R# 	  V	P                  V ^,          4       V	# )a  Approximate a cubic Bezier curve with a spline of n quadratics.

Args:
    cubic (sequence): Four complex numbers representing control points of
        the cubic Bezier curve.
    n (int): Number of quadratic Bezier curves in the spline.
    tolerance (double): Permitted deviation from the original curve.

Returns:
    A list of ``n+2`` complex numbers, representing control points of the
    quadratic spline if it fits within the given tolerance, or ``None`` if
    no suitable spline could be calculated.
Fy                r6   NrK   )rN   r)   Znextr>   r2   Zappendr   rF   )rM   r'   rE   rO   ZcubicsZ
next_cubicrQ   rR   r1   spliner-   rH   r0   rI   rJ   rP   rG   Zd0s   &&&&              r   cubic_approx_splinerT     s   : 	Av%e77Av-5($U1XuQxq58QOF fJ"	:a=*Q-A
1G 
qB	BAh F1a!e_# 5fJ*UZ]JqM:a=*UV-G MM'"w,#%BB Wr7Y&?"r'e$$r)"r'e$$r)'
 '
 9 : MM%(Mr
   )max_err)r'   c                s
   V  Uu. uF  p\        V!  NK  	  p p\        ^\        ^,           4       F<  p\        WW4      pVf   K  V Uu. uF  qfP                  VP
                  3NK  	  upu # 	  \        V 4      hu upi u upi )a  Approximate a cubic Bezier curve with a spline of n quadratics.

Args:
    cubic (sequence): Four 2D tuples representing control points of
        the cubic Bezier curve.
    max_err (double): Permitted deviation from the original curve.
    all_quadratic (bool): If True (default) returned value is a
        quadratic spline. If False, it's either a single quadratic
        curve or a single cubic curve.

Returns:
    If all_quadratic is True: A list of 2D tuples, representing
    control points of the quadratic spline if it fits within the
    given tolerance, or ``None`` if no suitable spline could be
    calculated.

    If all_quadratic is False: Either a quadratic curve (if length
    of output is 3), or a cubic curve (if length of output is 4).
)r   r2   MAX_NrT   r   r   r   )curverU   rO   rA   r'   rS   ss   &&&    r   r   r     sz    0 #((%QWa[%E(1eai $UwF.45fVVQVV$f55	 ! e
$$ ) 6s   A;	 B )llast_ir-   c                s   V  UUu. uF  q3 Uu. uF  p\        V!  NK  	  upNK  	  p pp\        V 4      pR.V,          p^ ;rx^p	 \        W,          WV,          V4      p
V
f   V	\        8X  d   MaV	^,          p	TpK8  WV&   V^,           V,          pW8X  g   KT  V U
Uu. uF)  q Uu. uF  qP                  VP
                  3NK  	  upNK+  	  upp
# \        V 4      hu upi u uppi u upi u upp
i )a  Return quadratic Bezier splines approximating the input cubic Beziers.

Args:
    curves: A sequence of *n* curves, each curve being a sequence of four
        2D tuples.
    max_errors: A sequence of *n* floats representing the maximum permissible
        deviation from each of the cubic Bezier curves.
    all_quadratic (bool): If True (default) returned values are a
        quadratic spline. If False, they are either a single quadratic
        curve or a single cubic curve.

Example::

    >>> curves_to_quadratic( [
    ...   [ (50,50), (100,100), (150,100), (200,50) ],
    ...   [ (75,50), (120,100), (150,75),  (200,60) ]
    ... ], [1,1] )
    [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]

The returned splines have "implied oncurve points" suitable for use in
TrueType ``glif`` outlines - i.e. in the first spline returned above,
the first quadratic segment runs from (50,50) to
( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).

Returns:
    If all_quadratic is True, a list of splines, each spline being a list
    of 2D tuples.

    If all_quadratic is False, a list of curves, each curve being a quadratic
    (length 3), or cubic (length 4).

Raises:
    fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation
    can be found for all curves with the given parameters.
N)r   ZlenrT   rV   r   r   r   )ZcurvesZ
max_errorsrO   rW   rA   rY   ZsplinesrZ   r-   r'   rS   rX   s   &&&         r   r   r     s    N 9??uE*Eqw{E*F? 	FAfqjGNF	A
$VYa=-P>EzFAF
UaK;ELMW6v6v!ffaff%v6WMM
f
%%+ +?& 7Ms-   C CC C+% C&C+C &C+)T)%r    ZAttributeErrorZImportErrorZfontTools.miscZcompiledZCOMPILEDrL   Zerrorsr   Z
Cu2QuErrorr   Z__all__rV   ZfloatrC   ZcfuncZinlineZreturnsZdoubleZlocalsr   r	   r   r   r#   r)   Zintr&   r$   r%   r>   rD   rF   rN   rT   r   r   r"   r
   r   <module>r[      s4  $& ??  <  !6
7El &..V^^FMMJ K   , V]]3&--FMM2' 3 4 ' 6>>V^^v~~V~~&..V^^ W   ~~&..V^^ 6>>V^^v~~V W   ~~&..V^^"6  
"6J ~~~~~~~~jj 6>>V^^v~~V}}fmmV]]fjj ~~&..V^^0 W0  ~~&..V^^ 6>>&..9 :  . ~~~~~~~~	 	>>	>>	  4 mm~~~~~~~~ 6>>v~~6! 7    !$ 6>>V^^v~~V&..V^^v~~W X W    
: 

mm~~~~~~~~ 6>>&..9W :  W@ '~~~~~~~~~~ (  4 v}}5VZZ(~~&..V^^ ~~~~NN~~~~= )  6 =@ v}}%VZZ(% )  &%@ FJJ&**=VZZ(:& ) >:&K 	$ &%%&s   e. .f f