)EjNddlmZddlmZddlmZddlZGddeZdS))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. FNc|rt|}t|||_||_||_dS)N)rsuper__init__ all_cubicmax_errstats)self other_penr r reverse_directionr __class__s IC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/pens/qu2cuPen.pyr zQu2CuPen.__init__$sK  5))44I ###"  c#NKt||j|j}|jJ|D]G}t t |dz }|j|ddz|j|<H|D]2}t |dkrd|ddfV$d|ddfV3dS)N)r rcurveToqCurveTo)rr r r strlenget)rqcurvescurvens r_quadratics_to_curvezQu2CuPen._quadratics_to_curve3s$Q OOO : ! 9 9E Q'' $ q! 4 4q 8 1  . .E5zzQ %),,,,,!59-----  . .rcg}d}g}|D]\}}|dkrS|jst|dkr9|d1|dtd||f|znC|r*|||g}|||f|r|dnd}|r(||||js|}g}|D]\}}|dkr|r|dddkr|ddd}|ddd}|d} |t j| d|dz |d|dz rTt j| d|dz |d|dz r!|dddd|z} || f|d<|||f|S)Nrrz4oncurve-less contours with all_cubic not implementedrr)r rNotImplementedErrorappendextendr!mathisclose) rcontour quadratics currentPt newContouropargspt0pt1pt2newArgss r filterContourzQu2CuPen.filterContour?s;    3 3HBZ #&t99q==T"X5I8#-N!!9,"56666$%%d&?&? &K&KLLL!#J!!2t*---$(2RdII  E   d77 CC D D D~ . GJ# . .D## #z"~a7HJ7V7V$R.+B/C$R.+B/Cq'C LQ#a&#a&3q6/JJ( LQ#a&#a&3q6/JJ(#-R."3CRC"84"?*,g 2 !!2t*----r)FFN)__name__ __module__ __qualname____doc__r r!r4 __classcell__)rs@rrrsp  "       . . .*******rr)fontTools.qu2curfontTools.pens.filterPenr fontTools.pens.reverseContourPenrr(rrrr>s 0/////555555>>>>>> SSSSSSSSSSr