L iFddlmZddlmZddlmZddlZGddeZy))quadratic_to_curves)ContourFilterPen)ReverseContourPenNc6eZdZdZ dfd ZdZdZxZS)Qu2CuPena5A 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. ch|r t|}t| |||_||_||_y)N)rsuper__init__ all_cubicmax_errstats)self other_penr r reverse_directionr __class__s ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/pens/qu2cuPen.pyr zQu2CuPen.__init__$s4 ))4I #"  c#LKt||j|j}|jJ|D]E}t t |dz }|jj |ddz|j|<G|D]#}t |dk(r d|ddfd|ddf%yw)N)r rcurveToqCurveTo)rr r r strlenget)rqcurvescurvens r_quadratics_to_curvezQu2CuPen._quadratics_to_curve3s$Q O :: ! 9E Q' $ q! 4q 8 1  9 .E5zQ %),,!59--  .sB"B$cg}d}g}|D]\}}|dk(rE|jst|dkDr+|d&|d td|j|f|zn7|r"|j |j |g}|j||f|r|dnd}|r |j |j ||js|}g}|D]\}}|dk(r|r|dddk(r|ddd}|ddd}|d} |ft j| d|dz |d|dz r>t j| d|dz |d|dz r|dddd|z} || f|d<|j||f|S)Nrrz4oncurve-less contours with all_cubic not implementedrr)r rNotImplementedErrorappendextendr!mathisclose) rcontour quadratics currentPt newContouropargspt0pt1pt2newArgss r filterContourzQu2CuPen.filterContour?s    3HBZ3t9q=T"X5I8#-N!!9,"56%%d&?&? &KL!#J!!2t*-$(RdI 3    d77 C D~~ GJ# .D# z"~a7HJ7V$R.+B/C$R.+B/Cq'C LLQ#a&#a&3q6/J LLQ#a&#a&3q6/J",R."3CR"84"?*,g 2 !!2t*- . r)FFN)__name__ __module__ __qualname____doc__r r!r4 __classcell__)rs@rrrs" "  .*rr)fontTools.qu2curfontTools.pens.filterPenr fontTools.pens.reverseContourPenrr(rrrr>s" 05> SSr