Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªjš3ã@s dZddlmZddlmZdddddd gZGd d„deƒZGd d„dƒZGd d„deƒZ Gd d„deeƒZ Gdd„de ƒZ Gdd„de ƒZ Gdd„de ƒZdd„Zdd „ZGdd„deƒZedk�redƒZejdƒejd ƒejd!d"d#d$ƒejƒedƒZejd%d&d'd(dƒejƒdS))aÛfontTools.pens.basePen.py -- Tools and base classes to build pen objects. The Pen Protocol A Pen is a kind of object that standardizes the way how to "draw" outlines: it is a middle man between an outline and a drawing. In other words: it is an abstraction for drawing outlines, making sure that outline objects don't need to know the details about how and where they're being drawn, and that drawings don't need to know the details of how outlines are stored. The most basic pattern is this: outline.draw(pen) # 'outline' draws itself onto 'pen' Pens can be used to render outlines to the screen, but also to construct new outlines. Eg. an outline object can be both a drawable object (it has a draw() method) as well as a pen itself: you *build* an outline using pen methods. The AbstractPen class defines the Pen protocol. It implements almost nothing (only no-op closePath() and endPath() methods), but is useful for documentation purposes. Subclassing it basically tells the reader: "this class implements the Pen protocol.". An examples of an AbstractPen subclass is fontTools.pens.transformPen.TransformPen. The BasePen class is a base implementation useful for pens that actually draw (for example a pen renders outlines using a native graphics engine). BasePen contains a lot of base functionality, making it very easy to build a pen that fully conforms to the pen protocol. Note that if you subclass BasePen, you _don't_ override moveTo(), lineTo(), etc., but _moveTo(), _lineTo(), etc. See the BasePen doc string for details. Examples of BasePen subclasses are fontTools.pens.boundsPen.BoundsPen and fontTools.pens.cocoaPen.CocoaPen. Coordinates are usually expressed as (x, y) tuples, but generally any sequence of length 2 will do. é)ÚTuple)ÚLogMixinÚ AbstractPenÚNullPenÚBasePenÚPenErrorÚdecomposeSuperBezierSegmentÚdecomposeQuadraticSegmentc@seZdZdZdS)rz#Represents an error during penning.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú;/tmp/pip-build-_d5lkt3n/fonttools/fontTools/pens/basePen.pyr/sc@sªeZdZeeefddœdd„Zeeefddœdd„Zeeefddœdd „Zeeefddœd d „Zdd œd d„Z dd œdd„Z e eeeeeeefddœdd„Z dS)rN)ÚptÚreturncCst‚dS)z…Begin a new sub path, set the current point to 'pt'. You must end each sub path with a call to pen.closePath() or pen.endPath(). N)ÚNotImplementedError)ÚselfrrrrÚmoveTo5szAbstractPen.moveTocCst‚dS)z4Draw a straight line from the current point to 'pt'.N)r)rrrrrÚlineTo;szAbstractPen.lineTo)ÚpointsrcGst‚dS)aCDraw a cubic bezier with an arbitrary number of control points. The last point specified is on-curve, all others are off-curve (control) points. If the number of control points is > 2, the segment is split into multiple bezier segments. This works like this: Let n be the number of control points (which is the number of arguments to this call minus 1). If n==2, a plain vanilla cubic bezier is drawn. If n==1, we fall back to a quadratic segment and if n==0 we draw a straight line. It gets interesting when n>2: n-1 PostScript-style cubic segments will be drawn as if it were one curve. See decomposeSuperBezierSegment(). The conversion algorithm used for n>2 is inspired by NURB splines, and is conceptually equivalent to the TrueType "implied points" principle. See also decomposeQuadraticSegment(). N)r)rrrrrÚcurveTo?szAbstractPen.curveTocGst‚dS)a Draw a whole string of quadratic curve segments. The last point specified is on-curve, all others are off-curve points. This method implements TrueType-style curves, breaking up curves using 'implied points': between each two consequtive off-curve points, there is one implied point exactly in the middle between them. See also decomposeQuadraticSegment(). The last argument (normally the on-curve point) may be None. This is to support contours that have NO on-curve points (a rarely seen feature of TrueType outlines). N)r)rrrrrÚqCurveToTszAbstractPen.qCurveTo)rcCsdS)zkClose the current sub path. You must call either pen.closePath() or pen.endPath() after each sub path. Nr)rrrrÚ closePatheszAbstractPen.closePathcCsdS)z}End the current sub path, but don't close it. You must call either pen.closePath() or pen.endPath() after each sub path. Nr)rrrrÚendPathkszAbstractPen.endPath)Ú glyphNameÚtransformationrcCst‚dS)zìAdd a sub glyph. The 'transformation' argument must be a 6-tuple containing an affine transformation, or a Transform object from the fontTools.misc.transform module. More precisely: it should be a sequence containing 6 numbers. N)r)rrrrrrÚ addComponentqs zAbstractPen.addComponent) r r r rÚfloatrrrrrrÚstrrrrrrr3sc@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)rzA pen that does nothing. cCsdS)Nr)rrrrrrƒszNullPen.moveTocCsdS)Nr)rrrrrr†szNullPen.lineTocGsdS)Nr)rrrrrr‰szNullPen.curveTocGsdS)Nr)rrrrrrŒszNullPen.qCurveTocCsdS)Nr)rrrrr�szNullPen.closePathcCsdS)Nr)rrrrr’szNullPen.endPathcCsdS)Nr)rrrrrrr•szNullPen.addComponentN) r r r r rrrrrrrrrrrr~sc@seZdZdZdS)Ú LoggingPenzHA pen with a `log` property (see fontTools.misc.loggingTools.LogMixin) N)r r r r rrrrr ™sr c@seZdZdZdS)ÚMissingComponentErrorzGIndicates a component pointing to a non-existent glyph in the glyphset.N)r r r r rrrrr!Ÿsr!cs,eZdZdZdZ‡fdd„Zdd„Z‡ZS)ÚDecomposingPenaù Implements a 'addComponent' method that decomposes components (i.e. draws them onto self as simple contours). It can also be used as a mixin class (e.g. see ContourRecordingPen). You must override moveTo, lineTo, curveTo and qCurveTo. You may additionally override closePath, endPath and addComponent. By default a warning message is logged when a base glyph is missing; set the class variable ``skipMissingComponents`` to False if you want to raise a :class:`MissingComponentError` exception. Tcstt|ƒjƒ||_dS)zƒ Takes a single 'glyphSet' argument (dict), in which the glyphs that are referenced as components are looked up by their name. N)Úsuperr"Ú__init__ÚglyphSet)rr%)Ú __class__rrr$³szDecomposingPen.__init__c Csfddlm}y|j|}Wn2tk rL|js8t|ƒ‚|jjd|ƒYnX|||ƒ}|j|ƒdS)zA Transform the points of the base glyph and draw it onto self. r)Ú TransformPenz,glyph '%s' is missing from glyphSet; skippedN) ZfontTools.pens.transformPenr'r%ÚKeyErrorÚskipMissingComponentsr!ÚlogÚwarningZdraw)rrrr'ZglyphZtPenrrrrºs  zDecomposingPen.addComponent)r r r r r)r$rÚ __classcell__rr)r&rr"£s  r"csŠeZdZdZd‡fdd„ Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Z‡ZS) rzÖBase class for drawing pens. You must override _moveTo, _lineTo and _curveToOne. You may additionally override _closePath, _endPath, addComponent and/or _qCurveToOne. You should not override any other methods. Ncstt|ƒj|ƒd|_dS)N)r#rr$Ú_BasePen__currentPoint)rr%)r&rrr$ÒszBasePen.__init__cCst‚dS)N)r)rrrrrÚ_moveToØszBasePen._moveTocCst‚dS)N)r)rrrrrÚ_lineToÛszBasePen._lineTocCst‚dS)N)r)rÚpt1Úpt2Úpt3rrrÚ _curveToOneÞszBasePen._curveToOnecCsdS)Nr)rrrrÚ _closePathãszBasePen._closePathcCsdS)Nr)rrrrÚ_endPathæszBasePen._endPathc Cst|j\}}|\}}|\}}|d||} |d||} |d||} |d||} |j| | f| | f|ƒdS)zºThis method implements the basic quadratic curve type. The default implementation delegates the work to the cubic curve function. Optionally override with a native implementation. gUUUUUUå?N)r-r3) rr0r1Zpt0xZpt0yZpt1xZpt1yZpt2xZpt2yZmid1xZmid1yZmid2xZmid2yrrrÚ _qCurveToOneés zBasePen._qCurveToOnecCs|jS)zfReturn the current point. This is not part of the public interface, yet is useful for subclasses. )r-)rrrrÚ_getCurrentPointùszBasePen._getCurrentPointcCs|jƒd|_dS)N)r4r-)rrrrrÿszBasePen.closePathcCs|jƒd|_dS)N)r5r-)rrrrrszBasePen.endPathcCs|j|ƒ||_dS)N)r.r-)rrrrrrs zBasePen.moveTocCs|j|ƒ||_dS)N)r/r-)rrrrrr s zBasePen.lineTocGs¨t|ƒd}|dkst‚|dkr6|j|Ž|d|_nn|dkrp|j}x^t|ƒD]\}}}||||ƒ||_qNWn4|dkr„|j|Žn |dkrœ|j|dƒntdƒ‚dS)Nérézcan't get there from hereéÿÿÿÿ)ÚlenÚAssertionErrorr3r-rrr)rrÚnr3r0r1r2rrrrs       zBasePen.curveToc Gs¾t|ƒd}|dkst‚|ddkrv|d\}}|d\}}d||d||f}||_|j|ƒ|dd…|f}|dkr¬|j}x4t|ƒD]\} } || | ƒ| |_qŽWn|j|dƒdS)Nr8rr9gà?r:éþÿÿÿr:)r;r<r-r.r6r r) rrr=ÚxÚyÚnxÚnyZimpliedStartPointr6r0r1rrrr,s        zBasePen.qCurveTo)N)r r r r r$r.r/r3r4r5r6r7rrrrrrr,rr)r&rrÊsc Cs:t|ƒd}|dkst‚g}|ddd}}}xìtd|dƒD]Ú}t|d||dƒ}xÀtd|ƒD]²}||} ||d} ||d} | d| | d| d| d| | d| df} |dkrÎ| }qdd|d| dd|d| df}|j|||fƒ| dd}}}qdWq@W|j||d|dfƒ|S) a¸Split the SuperBezier described by 'points' into a list of regular bezier segments. The 'points' argument must be a sequence with length 3 or greater, containing (x, y) coordinates. The last point is the destination on-curve point, the rest of the points are off-curve points. The start point should not be supplied. This function returns a list of (pt1, pt2, pt3) tuples, which each specify a regular curveto-style bezier segment. r8rNr9égà?r>r:)r;r<ÚrangeÚminÚappend) rr=ZbezierSegmentsr0r1r2ÚiZ nDivisionsÚjZfactorZtemp1Ztemp2ÚtemprrrrIs(    c Cs’t|ƒd}|dkst‚g}xZt|dƒD]J}||\}}||d\}}d||d||f}|j|||fƒq*W|j|d|dfƒ|S)a½Split the quadratic curve segment described by 'points' into a list of "atomic" quadratic segments. The 'points' argument must be a sequence with length 2 or greater, containing (x, y) coordinates. The last point is the destination on-curve point, the rest of the points are off-curve points. The start point should not be supplied. This function returns a list of (pt1, pt2) tuples, which each specify a plain quadratic bezier segment. r8rgà?r9r>r:)r;r<rDrF) rr=Z quadSegmentsrGr?r@rArBZ impliedPtrrrr ks   c@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú_TestPenz,Test class that prints PostScript to stdout.cCstd|d|dfƒdS)Nz %s %s movetorr8)Úprint)rrrrrr.ƒsz_TestPen._moveTocCstd|d|dfƒdS)Nz %s %s linetorr8)rK)rrrrrr/…sz_TestPen._lineToc Cs4td|d|d|d|d|d|dfƒdS)Nz%s %s %s %s %s %s curvetorr8)rK)rZbcp1Zbcp2rrrrr3‡sz_TestPen._curveToOnecCs tdƒdS)NZ closepath)rK)rrrrr4Šsz_TestPen._closePathN)r r r r r.r/r3r4rrrrrJ�s rJÚ__main__Nédé2éKé<é)rr)rrM)rNrO)rPrN)rNrQ)rr)rr)rrM)rMrM)rMr)r ÚtypingrZfontTools.misc.loggingToolsrÚ__all__Ú Exceptionrrrr r(r!r"rrr rJr ZpenrrrrrrrrrÚ%s.  K'"