
    ]Mh                     N    d dl mZ d dlmZ d dlmZ d dlZ G d de          ZdS )    )quadratic_to_curves)ContourFilterPen)ReverseContourPenNc                   6     e Zd ZdZ	 	 	 d fd	Zd Zd Z xZS )Qu2CuPena5  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.
    FNc                     |rt          |          }t                                          |           || _        || _        || _        d S )N)r   super__init__	all_cubicmax_errstats)self	other_penr   r   reverse_directionr   	__class__s         W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/pens/qu2cuPen.pyr
   zQu2CuPen.__init__$   sK      	5))44I###"


    c              #   N  K   t          || j        | j                  }| j        J|D ]G}t	          t          |          dz
            }| j                            |d          dz   | j        |<   H|D ]2}t          |          dk    rd|dd          fV  $d|dd          fV  3d S )N)r      r         curveToqCurveTo)r   r   r   r   strlenget)r   qcurvescurvens        r   _quadratics_to_curvezQu2CuPen._quadratics_to_curve3   s      $QOOO:! 9 9E

Q'' $
q! 4 4q 8
1 	. 	.E5zzQ %),,,,,!59-----		. 	.r   c                    g }d }g }|D ]\  }}|dk    rS| j         st          |          dk    r9|d         1|d         t          d          |                    |f|z              nC|r*|                    |                     |                     g }|                    ||f           |r|d         nd }|r(|                    |                     |                     | j         s|}g }|D ]\  }}|dk    r|r|d         d         dk    r|d         d         d         }|d         d         d         }|d         }	|t          j        |	d         |d         z
  |d         |d         z
            rTt          j        |	d         |d         z
  |d         |d         z
            r!|d         d         d d         |z   }
||
f|d<   |                    ||f           |S )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   filterContourzQu2CuPen.filterContour?   s;   
	
 	3 	3HBZ  #&t99q==T"X5I8#-N   !!9,"56666 $%%d&?&?
&K&KLLL!#J!!2t*---$(2RdII 	Ed77
CCDDD~ 	. GJ# . .D##
#z"~a7HJ7V7V$R.+B/C$R.+B/Cq'C LQ#a&#a&3q6/JJ ( LQ#a&#a&3q6/JJ ( #-R."3CRC"84"?*,g
2 !!2t*----r   )FFN)__name__
__module____qualname____doc__r
   r!   r4   __classcell__)r   s   @r   r   r      sp         "      
. 
. 
.* * * * * * *r   r   )fontTools.qu2cur   fontTools.pens.filterPenr    fontTools.pens.reverseContourPenr   r(   r    r   r   <module>r>      s     0 / / / / / 5 5 5 5 5 5 > > > > > > S S S S S S S S S Sr   