o
    l^Uf*                     @   s   d dl mZ ddlZedZedZedZedZedZ	ed	Z
ed
Zdd Zde	fde	fde	fde
fde
fde	fde	ffZdd ZdefddZdS )   )EllipticalArc    NZMmZzLlHhVvCcSsQqTtAaZAaZ
MZLHVCSQTAz([MmZzLlHhVvCcSsQqTtAa])z\[-+]?(?:(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][-+]?[0-9]+)?|(?:\.[0-9]+(?:[eE][-+]?[0-9]+)?))z^[01]z[, 	]c                 c   s    d }t | D ]@}|tv r|tv r|nd }|V  q|r=z	t|E d H  W q ty< } ztd| | d|d }~ww t|D ]}|V  qBqd S )NzInvalid arc command: '')
COMMAND_REsplitCOMMANDSARC_COMMANDS_tokenize_arc_arguments
ValueErrorFLOAT_REfindall)pathdefZarc_cmdxetoken r   <lib/python3.10/site-packages/fontTools/svgLib/path/parser.py_tokenize_path"   s$   r   rxryzx-axis-rotationzlarge-arc-flagz
sweep-flagr   yc           	      c   s    dd t | D }|std|  d|  d}|r_| }t| \}}||}|s8td| d|| \}}||| V  ||d  }|rR|| |dkrYd}n|d	7 }|s|dkrktd|  dd S )
Nc                 S   s   g | ]}|r|qS r   r   ).0sr   r   r   
<listcomp>@   s    z+_tokenize_arc_arguments.<locals>.<listcomp>zNot enough arguments: 'r   r   zInvalid argument for 'z' parameter:    r   )	SEPARATOR_REr   r
   reversepopARC_ARGUMENT_TYPESsearchspanappend)	ZarcdefZraw_argsiargnamepatternmatchjkr   r   r   r	   ?   s0   

r	   )r   r   c              	   C   sL  t | }tt| }|  d}d}d}t|d}|r|d tv r1|}	| }|tv }
| }n|du rEt	d| t
|  t
| f |}	|dkr}| }| }t|t|d  }|
rb|}n||7 }|durn|  ||j|jf |}d}n|dkr||kr||j|jf |  |}d}d}n|dkr| }| }t|t|d  }|
s||7 }||j|jf |}n|d	kr| }t||jd  }|
s||j7 }||j|jf |}n|d
kr| }|jt|d  }|
s||jd 7 }||j|jf |}n|dkrht| t| d  }t| t| d  }t| t| d  }|
sO||7 }||7 }||7 }||j|jf|j|jf|j|jf |}|}n/|dkr|	dvru|}n|| | }t| t| d  }t| t| d  }|
s||7 }||7 }||j|jf|j|jf|j|jf |}|}n|dkrt| t| d  }t| t| d  }|
s||7 }||7 }||j|jf|j|jf |}|}n|dkr4|	dvr|}n|| | }t| t| d  }|
s!||7 }||j|jf|j|jf |}|}nc|dkrtt| }tt| }t| }tt| }tt| }t| t| d  }|
st||7 }|r|||||||j|jf n||||||||}|| |}|s|dur|  dS dS )aJ  Parse SVG path definition (i.e. "d" attribute of <path> elements)
    and call a 'pen' object's moveTo, lineTo, curveTo, qCurveTo and closePath
    methods.

    If 'current_pos' (2-float tuple) is provided, the initial moveTo will
    be relative to that instead being absolute.

    If the pen has an "arcTo" method, it is called with the original values
    of the elliptical arc curve commands:

        pen.arcTo(rx, ry, rotation, arc_large, arc_sweep, (x, y))

    Otherwise, the arcs are approximated by series of cubic Bezier segments
    ("curveTo"), one every 90 degrees.
    NarcToz-Unallowed implicit command in %s, position %sMy              ?LZHVCSZCSQTZQTA)complexlistr   r   hasattrr   r   	UPPERCASEupperr
   lenr   floatZendPathZmoveTorealimagZlineToZ	closePathZcurveToZqCurveToabsboolintr)   Zdraw)r   ZpenZcurrent_posZ	arc_classelementsZ	start_posZcommandZlast_controlZ
have_arcToZlast_commandZabsoluter   r   posZcontrol1Zcontrol2endZcontrolr   r   ZrotationZ	arc_largeZ	arc_sweeparcr   r   r   
parse_path_   s  

















	
  
ArE   )rD   r   resetr   r   r8   compiler   r   ZBOOL_REr   r   r   r	   rE   r   r   r   r   <module>   s,   	


 