)Ej"ddlmZddlmZefdZGddeZd dZedkrXddl Z e e j d kr&ddl Z e j e jje j edSdS) )Callable)BasePencFdfd|DS)N c3.K|]}|VdSN).0intoss KC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/pens/svgPathPen.py z pointToString..s+((DDGG(((((()join)ptr s `r pointToStringrs* 88((((R((( ( ((rcdeZdZdZefdeegeffdZdZdZ dZ dZ dZ d Z d Zd Zd S) SVGPathPenaPen to draw SVG path d commands. Args: glyphSet: a dictionary of drawable glyph objects keyed by name used to resolve component references in composite glyphs. ntos: a callable that takes a number and returns a string, to customize how numbers are formatted (default: str). :Example: .. code-block:: >>> pen = SVGPathPen(None) >>> pen.moveTo((0, 0)) >>> pen.lineTo((1, 1)) >>> pen.curveTo((2, 2), (3, 3), (4, 4)) >>> pen.closePath() >>> pen.getCommands() 'M0 0 1 1C2 2 3 3 4 4Z' Note: Fonts have a coordinate system where Y grows up, whereas in SVG, Y grows down. As such, rendering path data from this pen in SVG typically results in upside-down glyphs. You can fix this by wrapping the data from this pen in an SVG group element with transform, or wrap this pen in a transform pen. For example: .. code-block:: python spen = svgPathPen.SVGPathPen(glyphset) pen= TransformPen(spen , (1, 0, 0, -1, 0, 0)) glyphset[glyphname].draw(pen) print(tpen.getCommands()) r cvtj||g|_d|_d|_d|_||_dSr)r__init__ _commands _lastCommand_lastX_lastY_ntos)selfglyphSetr s r rzSVGPathPen.__init__+s=x(((    rcT|jdkr|jddSdS)z >>> pen = SVGPathPen(None) >>> pen.moveTo((0, 0)) >>> pen.moveTo((10, 10)) >>> pen._commands ['M10 10'] MN)rrpoprs r _handleAnchorzSVGPathPen._handleAnchor3s6   # # N  r " " " " " $ #rc|dt||jz}|j|d|_|\|_|_dS)aV >>> pen = SVGPathPen(None) >>> pen.moveTo((0, 0)) >>> pen._commands ['M0 0'] >>> pen = SVGPathPen(None) >>> pen.moveTo((10, 0)) >>> pen._commands ['M10 0'] >>> pen = SVGPathPen(None) >>> pen.moveTo((0, 10)) >>> pen._commands ['M0 10'] zM%srN)r#rrrappendrrr)rrts r _moveTozSVGPathPen._moveTo>s\"  ]2tz22 3 a   #%  T[[[rc|\}}||jkr ||jkrdS||jkrd}||}n`||jkrd}||}n=|jdkrd}dt ||jz}nd}t ||j}d}|r ||z }||_||z }|j||\|_|_dS)aU # duplicate point >>> pen = SVGPathPen(None) >>> pen.moveTo((10, 10)) >>> pen.lineTo((10, 10)) >>> pen._commands ['M10 10'] # vertical line >>> pen = SVGPathPen(None) >>> pen.moveTo((10, 10)) >>> pen.lineTo((10, 0)) >>> pen._commands ['M10 10', 'V0'] # horizontal line >>> pen = SVGPathPen(None) >>> pen.moveTo((10, 10)) >>> pen.lineTo((0, 10)) >>> pen._commands ['M10 10', 'H0'] # basic >>> pen = SVGPathPen(None) >>> pen.lineTo((70, 80)) >>> pen._commands ['L70 80'] # basic following a moveto >>> pen = SVGPathPen(None) >>> pen.moveTo((0, 0)) >>> pen.lineTo((10, 10)) >>> pen._commands ['M0 0', ' 10 10'] NVHrrL)rrrrrrr%)rrxycmdptsr&s r _lineTozSVGPathPen._lineToUsH1   T[ 0 0 F $+  C**Q--CC $+  C**Q--CC  # % %C b$*555CCCDJ//C   $ HA #D  S a   #%  T[[[rcd}|t||jdzz }|t||jdzz }|t||jz }|j|d|_|\|_|_dS)z >>> pen = SVGPathPen(None) >>> pen.curveTo((10, 20), (30, 40), (50, 60)) >>> pen._commands ['C10 20 30 40 50 60'] CrNrrrr%rrr)rpt1pt2pt3r&s r _curveToOnezSVGPathPen._curveToOnes  ]3 + +c 11 ]3 + +c 11 ]3 + ++ a   #&  T[[[rc|Jd}|t||jdzz }|t||jz }|j|d|_|\|_|_dS)aw >>> pen = SVGPathPen(None) >>> pen.qCurveTo((10, 20), (30, 40)) >>> pen._commands ['Q10 20 30 40'] >>> from fontTools.misc.roundTools import otRound >>> pen = SVGPathPen(None, ntos=lambda v: str(otRound(v))) >>> pen.qCurveTo((3, 3), (7, 5), (11, 4)) >>> pen._commands ['Q3 3 5 4', 'Q7 5 11 4'] NQrr4)rr5r6r&s r _qCurveToOnezSVGPathPen._qCurveToOness  ]3 + +c 11 ]3 + ++ a   #&  T[[[rcd|jdd|_dx|_|_dS)zp >>> pen = SVGPathPen(None) >>> pen.closePath() >>> pen._commands ['Z'] ZN)rr%rrrr"s r _closePathzSVGPathPen._closePaths4 c"""$(( dkkkrc0d|_dx|_|_dS)zk >>> pen = SVGPathPen(None) >>> pen.endPath() >>> pen._commands [] N)rrrr"s r _endPathzSVGPathPen._endPaths!$(( dkkkrc6d|jS)Nr,)rrr"s r getCommandszSVGPathPen.getCommandsswwt~&&&rN)__name__ __module__ __qualname____doc__strrfloatrr#r'r1r8r;r>r@rBr rr rr sBADx '= # # #&&&.@&@&@&D ' ' ''''( ) ) ))))'''''rrNcN|ddl}|jdd}ddlm}ddl}|dd}|dd d |d d d d|ddd |ddtd|dddd||}|j t|j nd}||j |}|j }|j } i} |jD]K} | d} | d} t#| d}|| | <L|d}|j|j}}|| }|d | |t-d!| !d"fd#|D} | } d}d}| D]W}||}t1|}|||}|d$|||fzz }||jz }Xt9d%t9d&|||z fzt9|d't9d(dS))z-Generate per-character SVG from font and textNr)TTFontzfonttools pens.svgPathPenzGenerate SVG from text) descriptionfontzfont.ttfz Font file.)metavarhelptext?z Text string.)rNnargsrOz-yzz1Face index into a collection to open. Zero based.z--glyphsz(whitespace-separated list of glyph namesz*Glyphs to show. Exclusive with text option)rNtyperOz --variationszAXIS=LOCr,zList of space separated locations. A location consist in the name of a variation axis, followed by '=' and a number. E.g.: wght=700 wdth=80. The default is the location of the base master.)rNdefaultrO) fontNumber=hhea)locationcmapz)Options --glyphs and --text are exclusiverc3BK|]}t|VdSr)ord)r urYs r rzmain..s-551$s1vv,555555rz? z&z?)endz)sysargvfontTools.ttLibrKargparseArgumentParser add_argumentrG parse_argsr.intrMrPglyphs variationssplitstriprHascentdescent getGlyphSet getBestCmap ValueErrorrrdrawrBwidthprint)argsr^rKraparseroptionsrUrMrPrfrXtag_vfieldstagvrWrjrkglyphsetsrpgglyphpencommandsrYs @r mainrs5 | x|&&&&&&OOO  $ $#1I%F  FFF cOOO   @  :  9   L %%G#*9#8WYaJ 6',: 6 6 6D rs******))))G'G'G'G'G'G'G'G'TXXXXv zJJJ s38}}"")*** CHTTVVr