
    h|!                        S SK Jr  S SKJr  \4S jr " S S\5      rS
S jr\S:X  aa  S SK	r	\
" \	R                  5      S	:X  a/  S SKr\	R                  " \R                  " 5       R                  5        \	R                  " \" 5       5        gg)    )Callable)BasePenc                 :   ^ SR                  U4S jU  5       5      $ )N c              3   4   >#    U  H  nT" U5      v   M     g 7fN ).0intoss     K/var/www/html/env/lib/python3.13/site-packages/fontTools/pens/svgPathPen.py	<genexpr> pointToString.<locals>.<genexpr>   s     (RDGGRs   )join)ptr   s    `r   pointToStringr      s    88(R(((    c                   h    \ rS rSrSr\4S\\/\4   4S jjrS r	S r
S rS rS	 rS
 rS rS rSrg)
SVGPathPen	   aU  Pen 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   c                 t    [         R                  " X5        / U l        S U l        S U l        S U l        X l        g r   )r   __init__	_commands_lastCommand_lastX_lastY_ntos)selfglyphSetr   s      r   r   SVGPathPen.__init__+   s2    ( 
r   c                 \    U R                   S:X  a  U R                  R                  S5        gg)zi
>>> pen = SVGPathPen(None)
>>> pen.moveTo((0, 0))
>>> pen.moveTo((10, 10))
>>> pen._commands
['M10 10']
MN)r   r   popr   s    r   _handleAnchorSVGPathPen._handleAnchor3   s)     #NNr" $r   c                     U R                  5         S[        XR                  5      -  nU R                  R	                  U5        SU l        Uu  U l        U l        g)z
>>> 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']
zM%sr"   N)r&   r   r   r   appendr   r   r   )r   r   ts      r   _moveToSVGPathPen._moveTo>   sK    " 	]2zz23a #% T[r   c                    Uu  p#X R                   :X  a  X0R                  :X  a  gX R                   :X  a  SnU R                  U5      nOeX0R                  :X  a  SnU R                  U5      nOBU R                  S:X  a  SnS[	        XR                  5      -   nOSn[	        XR                  5      nSnU(       a
  Xd-  nX@l        Xe-  nU R
                  R                  U5        Uu  U l         U l        g)ae  
# 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']
NVHr"   r   L )r   r   r   r   r   r   r)   )r   r   xycmdptsr*   s          r   _lineToSVGPathPen._lineToU   s    H [[ 0++C**Q-C++C**Q-C#%Cb**55C CJJ/CHA #	a #% T[r   c                    SnU[        XR                  5      S-   -  nU[        X R                  5      S-   -  nU[        X0R                  5      -  nU R                  R                  U5        SU l        Uu  U l        U l        g)zs
>>> pen = SVGPathPen(None)
>>> pen.curveTo((10, 20), (30, 40), (50, 60))
>>> pen._commands
['C10 20 30 40 50 60']
Cr   Nr   r   r   r)   r   r   r   )r   pt1pt2pt3r*   s        r   _curveToOneSVGPathPen._curveToOne   st     	]3

+c11	]3

+c11	]3

++a #& T[r   c                     Uc   eSnU[        XR                  5      S-   -  nU[        X R                  5      -  nU R                  R                  U5        SU l        Uu  U l        U l        g)a'  
>>> 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']
NQr   r:   )r   r;   r<   r*   s       r   _qCurveToOneSVGPathPen._qCurveToOne   sf     	]3

+c11	]3

++a #& T[r   c                 d    U R                   R                  S5        SU l        S=U l        U l        g)zH
>>> pen = SVGPathPen(None)
>>> pen.closePath()
>>> pen._commands
['Z']
ZN)r   r)   r   r   r   r%   s    r   
_closePathSVGPathPen._closePath   s,     	c"$((dkr   c                 .    SU l         S=U l        U l        g)zC
>>> pen = SVGPathPen(None)
>>> pen.endPath()
>>> pen._commands
[]
N)r   r   r   r%   s    r   _endPathSVGPathPen._endPath   s     !$((dkr   c                 8    SR                  U R                  5      $ )Nr1   )r   r   r%   s    r   getCommandsSVGPathPen.getCommands   s    wwt~~&&r   )r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__strr   floatr   r&   r+   r6   r>   rB   rF   rI   rL   __static_attributes__r	   r   r   r   r   	   sP    B AD x'= 	#&.@&D''(	))'r   r   Nc                   ^ U c  SSK nUR                  SS n SSKJn  SSKnUR                  SSS9nUR                  SS	S
S9  UR                  SSSSS9  UR                  SSSS9  UR                  SS[        SS9  UR                  SSSSS9  UR                  U 5      nUR                  b  [        UR                  5      OSnU" UR                  US9nUR                  nUR                  n	0 n
UR                  R                  5        H9  nUR                  S5      nUS   R!                  5       n[#        US   5      nXU'   M;     US   nUR$                  UR&                  nnUR)                  U
S9nUS    R+                  5       mU	b  Ub  [-        S!5      eU	c  S"R/                  U4S# jU 5       5      n	U	R                  5       n	SnSnU	 HN  nUU   n[1        U5      nUR3                  U5        UR5                  5       nUS$UUU4-  -  nUUR6                  -  nMP     [9        S%5        [9        S&UUU-
  4-  5        [9        USS'9  [9        S(5        g))z-Generate per-character SVG from font and textNr      )TTFontzfonttools pens.svgPathPenzGenerate SVG from text)descriptionfontzfont.ttfz
Font file.)metavarhelptext?zText string.)r[   nargsr\   z-yz<number>z1Face index into a collection to open. Zero based.z--glyphsz(whitespace-separated list of glyph namesz*Glyphs to show. Exclusive with text option)r[   typer\   z--variationszAXIS=LOCr1   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.)r[   defaultr\   )
fontNumber=hhea)locationcmapz)Options --glyphs and --text are exclusiver   c              3   @   >#    U  H  nT[        U5         v   M     g 7fr   )ord)r
   urf   s     r   r   main.<locals>.<genexpr>  s     51$s1v,s   z?<g transform="translate(%d %d) scale(1 -1)"><path d="%s"/></g>
z&<?xml version="1.0" encoding="UTF-8"?>z?<svg width="%d" height="%d" xmlns="http://www.w3.org/2000/svg">)endz</svg>)sysargvfontTools.ttLibrX   argparseArgumentParseradd_argumentrS   
parse_argsr3   intrZ   r]   glyphs
variationssplitstriprT   ascentdescentgetGlyphSetgetBestCmap
ValueErrorr   r   drawrL   widthprint)argsrl   rX   ro   parseroptionsrb   rZ   r]   rt   re   tag_vfieldstagvrd   rx   ry   glyphsetsr~   gglyphpencommandsrf   s                            @r   mainr      s    |xx|&$$#1I % F 
F
cO
@  
 :9	   L	   %G#*99#8WYYaJ',,:6D<<D^^FH##))+S!Qioo&)	 , <Dkk4<<GF2H<##%Dd.DEE~555\\^F
AE"

3??$	OS
 
 	
 	  

23	I&7"
#	$ 
!	(Or   __main__rW   r   )typingr   fontTools.pens.basePenr   rS   r   r   r   rN   rl   lenrm   doctestexittestmodfailedr	   r   r   <module>r      sw     *  )G' G'TXv z
388}"))*HHTV r   