
    h                     F    S SK Jr  S SKJr  S SKJr  S SKr " S S\5      rg)    )quadratic_to_curves)ContourFilterPen)ReverseContourPenNc                   B   ^  \ rS rSrSr   SU 4S jjrS rS rSrU =r	$ )Qu2CuPen   a  A filter pen to convert quadratic bezier splines to cubic curves
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 cubic segments.
c                 l   > U(       a  [        U5      n[        TU ]	  U5        X0l        X l        XPl        g )N)r   super__init__	all_cubicmax_errstats)self	other_penr   r   reverse_directionr   	__class__s         I/var/www/html/env/lib/python3.13/site-packages/fontTools/pens/qu2cuPen.pyr   Qu2CuPen.__init__$   s.     ))4I#"
    c              #   R  #    [        XR                  U R                  S9nU R                  bL  U HF  n[	        [        U5      S-
  5      nU R                  R                  US5      S-   U R                  U'   MH     U H&  n[        U5      S:X  a  SUSS  4v   M  SUSS  4v   M(     g 7f)N)r      r         curveToqCurveTo)r   r   r   r   strlenget)r   qcurvescurvens        r   _quadratics_to_curveQu2CuPen._quadratics_to_curve3   s     $QO::!E
Q' $

q! 4q 8

1   E5zQ %),,!59--	 s   B%B'c                 d   / nS n/ nU H  u  pVUS:X  aM  U R                   (       d  [        U5      S:  a-  US   b'  US   c  [        S5      eUR                  U4U-   5        O;U(       a"  UR	                  U R                  U5      5        / nUR                  XV45        U(       a  US   OS nM     U(       a   UR	                  U R                  U5      5        U R                   (       d  Un/ nU H  u  pVUS:X  a  U(       a  US   S   S:X  a  US   S   S   nUS   S   S   nUS   n	Ubr  [        R                  " U	S   US   -
  US   US   -
  5      (       aD  [        R                  " U	S   US   -
  US   US   -
  5      (       a  US   S   S S U-   n
XZ4US'   M  UR                  XV45        M     U$ )Nr   r   z4oncurve-less contours with all_cubic not implementedr   r   )r   r   NotImplementedErrorappendextendr#   mathisclose)r   contour
quadratics	currentPt
newContouropargspt0pt1pt2newArgss              r   filterContourQu2CuPen.filterContour?   s   
	
HBZ3t9q=T"X5I8#-N  !!9,"56%%d&?&?
&KL!#J!!2*-$(RdI   d77
CD~~ GJ##
z"~a7HJ7V$R.+B/C$R.+B/Cq'C LLQ#a&#a&3q6/JJ LLQ#a&#a&3q6/JJ",R."3CR"84"?*,
2 !!2*- $  r   )r   r   r   )FFN)
__name__
__module____qualname____firstlineno____doc__r   r#   r7   __static_attributes____classcell__)r   s   @r   r   r      s'    " 
.* *r   r   )fontTools.qu2cur   fontTools.pens.filterPenr    fontTools.pens.reverseContourPenr   r+   r    r   r   <module>rD      s"     0 5 > S Sr   