a
    w=ic)                     @   sd   d Z ddlZddlmZ dgZG dd deZdd Zdd	 Zed
kr`ddl	Z	ee	j
dd  dS )z~Pen calculating area, center of mass, variance and standard-deviation,
covariance and correlation, and slant, of glyph shapes.    N)
MomentsPenStatisticsPenc                   @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )r   a  Pen calculating area, center of mass, variance and
	standard-deviation, covariance and correlation, and slant,
	of glyph shapes.

	Note that all the calculated values are 'signed'. Ie. if the
	glyph shape is self-intersecting, the values are not correct
	(but well-defined). As such, area will be negative if contour
	directions are clockwise.  Moreover, variance might be negative
	if the shapes are self-intersecting in certain ways.Nc                 C   s   t j| |d |   d S )Nglyphset)r   __init___StatisticsPen__zero)selfr    r	   m/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/pens/statisticsPen.pyr      s    zStatisticsPen.__init__c                 C   s   t |  |   d S )N)r   
_closePath_StatisticsPen__updater   r	   r	   r
   r      s    
zStatisticsPen._closePathc                 C   s:   d| _ d| _d| _d| _d| _d| _d| _d| _d| _d S )Nr   )	meanXmeanY	varianceX	varianceYstddevXstddevY
covariancecorrelationslantr   r	   r	   r
   Z__zero   s    zStatisticsPen.__zeroc                 C   s  | j }|s|   d S | j|  | _}| j|  | _}| j| |d   | _}| j| |d   | _	}t
t|d | | _}t
t|d | | _}| j| ||   | _}|| dkrtd}	n|||  }	t|	dkr|	nd| _|dkr|| ntd}
t|
dkr|
nd| _d S )N   g      ?r   NaNgMbP?)arear   momentXr   momentYr   momentXXr   momentYYr   mathcopysignabsr   r   momentXYr   floatr   r   )r   r   r   r   r   r   r   r   r   r   r   r	   r	   r
   Z__update(   s"    
zStatisticsPen.__update)N)__name__
__module____qualname____doc__r   r   r   r   r	   r	   r	   r
   r   	   s
   

c           
      C   s   ddl m} ddlm} td| |D ]b}t  td| | | }t| d}|||d| }|| dD ]}	td	|	t||	f  qlq&d S )
Nr   )TransformPen)Scaleupemzglyph:r   g      ?)r   r   r   r   r   r!   r   r   r   r   r   r   r   r   r   z%s: %g)ZfontTools.pens.transformPenr'   ZfontTools.misc.transformr(   printr   Zdrawgetattr)
r   r)   glyphsr'   r(   Z
glyph_nameZglyphpenZtransformeritemr	   r	   r
   _testJ   s    



r/   c                 C   sX   | sd S | d | dd   }}ddl m} ||}|s>| }t| |d j| d S )Nr      )TTFonthead)ZfontTools.ttLibr1   ZgetGlyphOrderr/   ZgetGlyphSetZ
unitsPerEm)argsfilenamer,   r1   Zfontr	   r	   r
   mainZ   s    r5   __main__r0   )r&   r   ZfontTools.pens.momentsPenr   __all__r   r/   r5   r#   sysargvr	   r	   r	   r
   <module>   s   A
