
    ]Mh|!                        d dl mZ d dlmZ efdZ G d de          Zd
dZedk    rXd dl	Z	 e
e	j                  d	k    r&d dlZ e	j         ej                    j                    e	j         e                       dS dS )    )Callable)BasePenc                 F    d                     fd| D                       S )N c              3   .   K   | ]} |          V  d S N ).0intoss     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/pens/svgPathPen.py	<genexpr>z pointToString.<locals>.<genexpr>   s+      ((DDGG((((((    )join)ptr   s    `r   pointToStringr      s*    88((((R((((((r   c                   d    e Zd ZdZefdeegef         fdZd Zd Z	d Z
d Zd Zd	 Zd
 Zd ZdS )
SVGPathPena  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                 v    t          j        | |           g | _        d | _        d | _        d | _        || _        d S r   )r   __init__	_commands_lastCommand_lastX_lastY_ntos)selfglyphSetr   s      r   r   zSVGPathPen.__init__+   s=    x((( 


r   c                 T    | j         dk    r| j                            d           dS dS )z
        >>> pen = SVGPathPen(None)
        >>> pen.moveTo((0, 0))
        >>> pen.moveTo((10, 10))
        >>> pen._commands
        ['M10 10']
        MN)r   r   popr   s    r   _handleAnchorzSVGPathPen._handleAnchor3   s6     ##Nr""""" $#r   c                     |                                   dt          || j                  z  }| j                            |           d| _        |\  | _        | _        dS )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']
        zM%sr   N)r#   r   r   r   appendr   r   r   )r   r   ts      r   _moveTozSVGPathPen._moveTo>   s\    " 	]2tz223a   #% T[[[r   c                    |\  }}|| j         k    r|| j        k    rdS || j         k    rd}|                     |          }n`|| j        k    rd}|                     |          }n=| j        dk    rd}dt	          || j                  z   }nd}t	          || j                  }d}|r||z  }|| _        ||z  }| j                            |           |\  | _         | _        dS )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']
        NVHr   r   L )r   r   r   r   r   r   r%   )r   r   xycmdptsr&   s          r   _lineTozSVGPathPen._lineToU   s   H 1T[ 0 0F$+C**Q--CC$+C**Q--CC#%%Cb$*555CC CDJ//C 	$HA #D	Sa   #% T[[[r   c                    d}|t          || j                  dz   z  }|t          || j                  dz   z  }|t          || j                  z  }| j                            |           d| _        |\  | _        | _        dS )z
        >>> 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   _curveToOnezSVGPathPen._curveToOne   s     	]3
++c11	]3
++c11	]3
+++a   #& T[[[r   c                     |J d}|t          || j                  dz   z  }|t          || j                  z  }| j                            |           d| _        |\  | _        | _        dS )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']
        NQr   r4   )r   r5   r6   r&   s       r   _qCurveToOnezSVGPathPen._qCurveToOne   ss     	]3
++c11	]3
+++a   #& T[[[r   c                 d    | j                             d           d| _        dx| _        | _        dS )zp
        >>> pen = SVGPathPen(None)
        >>> pen.closePath()
        >>> pen._commands
        ['Z']
        ZN)r   r%   r   r   r   r"   s    r   
_closePathzSVGPathPen._closePath   s4     	c"""$((dkkkr   c                 0    d| _         dx| _        | _        dS )zk
        >>> pen = SVGPathPen(None)
        >>> pen.endPath()
        >>> pen._commands
        []
        N)r   r   r   r"   s    r   _endPathzSVGPathPen._endPath   s     !$((dkkkr   c                 6    d                     | j                  S )Nr,   )r   r   r"   s    r   getCommandszSVGPathPen.getCommands   s    wwt~&&&r   N)__name__
__module____qualname____doc__strr   floatr   r#   r'   r1   r8   r;   r>   r@   rB   r	   r   r   r   r   	   s         B AD  x'=    	# 	# 	#& & &.@& @& @&D' ' '' ' '(	) 	) 	)) ) )' ' ' ' 'r   r   Nc                 N   | ddl }|j        dd         } ddlm} ddl}|                    dd          }|                    dd	d
           |                    dddd           |                    ddd           |                    ddt          d           |                    dddd           |                    |           }|j	        t          |j	                  nd} ||j        |          }|j        }|j        }	i }
|j                                        D ]K}|                    d          }|d                                         }t#          |d                   }||
|<   L|d         }|j        |j        }}|                    |
          }|d                                          |	|t-          d!          |	!d"                    fd#|D                       }	|	                                }	d}d}|	D ]W}||         }t1          |          }|                    |           |                                }|d$|||fz  z  }||j        z  }Xt9          d%           t9          d&|||z
  fz             t9          |d'           t9          d(           dS ))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.)rN   nargsrO   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)rN   typerO   z--variationszAXIS=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.)rN   defaultrO   )
fontNumber=hhea)locationcmapz)Options --glyphs and --text are exclusiver   c              3   B   K   | ]}t          |                   V  d S r   )ord)r
   urY   s     r   r   zmain.<locals>.<genexpr>  s-      551$s1vv,555555r   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.ttLibrK   argparseArgumentParseradd_argumentrG   
parse_argsr.   intrM   rP   glyphs
variationssplitstriprH   ascentdescentgetGlyphSetgetBestCmap
ValueErrorr   r   drawrB   widthprint)argsr^   rK   ra   parseroptionsrU   rM   rP   rf   rX   tag_vfieldstagvrW   rj   rk   glyphsetsrp   gglyphpencommandsrY   s                            @r   mainr      s5    |


x|&&&&&&OOO$$#1I %  F 
FFF
cOOO
@    
 :9	     L	     %%G#*9#8WYaJ6',:666D<D^FH#))++  S!!Qioo&)<Dk4<GF22H<##%%Dd.DEEE~555555555\\^^F
AE  ""

3??$$	OS
 
 	
 		
2333	I&7"
#	$   
!	(OOOOOr   __main__rJ   r   )typingr   fontTools.pens.basePenr   rG   r   r   r   rC   r^   lenr_   doctestexittestmodfailedr	   r   r   <module>r      s         * * * * * *  ) ) ) )G' G' G' G' G' G' G' G'TX X X Xv zJJJ
s38}}"")***CHTTVV r   