
    }fV                     P   d Z g dZddlmZ ddlmZ d Zd Zdd	Zdd
Z	d Z
ddZddddZddZ G d de          Zd ZddZedk    rXddlZddlZ eej                  dk    r ej         e                        ej         ej                    j                   dS dS )z%Variation fonts interpolation models.)normalizeValuenormalizeLocationsupportScalarpiecewiseLinearMapVariationModel    )noRound   )VariationModelErrorc                     d | D             S )Nc                     g | ]}||S N .0ls     P/var/www/rtfcompare/venv/lib/python3.11/site-packages/fontTools/varLib/models.py
<listcomp>znonNone.<locals>.<listcomp>   s    ,,,!amAmmm    r   lsts    r   nonNoner      s    ,,s,,,,r   c                 4    t          d | D                       S )Nc              3      K   | ]}|d u V  	d S r   r   r   s     r   	<genexpr>zallNone.<locals>.<genexpr>   s&      &&QqDy&&&&&&r   allr   s    r   allNoner      s    &&#&&&&&&r   Nc                      t           fd|D                       S             t          fd|D                       S )Nc              3   $   K   | ]
}|k    V  d S r   r   )r   itemrefs     r   r   zallEqualTo.<locals>.<genexpr>   s'      //43$;//////r   c              3   6   K   | ]} |          k    V  d S r   r   )r   r    mappedmappers     r   r   zallEqualTo.<locals>.<genexpr>   s0      66$v%666666r   r   )r!   r   r$   r#   s   ` `@r   
allEqualTor%      s`    ~////3//////VC[[F66666#666666r   c                     | sdS t          |           }	 t          |          }n# t          $ r Y dS w xY wt          |||          S )NT)r$   )iternextStopIterationr%   )r   r$   itfirsts       r   allEqualr,      sc     t	cBR   tteR////s   % 
33c                 z    t          |           t          |          k    sJ d t          ||           D             S )Nc                     g | ]	\  }}||
S r   r   )r   r   ts      r   r   zsubList.<locals>.<listcomp>,   s!    ///$!QQ/A///r   lenzip)truthr   s     r   subListr4   *   s;    u::S!!!!//#c5//////r   Fc           
      x   |\  }}}||cxk    r|k    sn t          d|dd|dd|d          |st          t          | |          |          } | |k    s||k    rdS | |k     r||k    s| |k    r||k    r| |z
  ||z
  z  S | |k    r||k    s#| |k     r||k    sJ d|  d| d| d| d	            | |z
  ||z
  z  S )zNormalizes value based on a min/default/max triple.

    >>> normalizeValue(400, (100, 400, 900))
    0.0
    >>> normalizeValue(100, (100, 400, 900))
    -1.0
    >>> normalizeValue(650, (100, 400, 900))
    0.5
    z8Invalid axis values, must be minimum, default, maximum: z3.3fz,         zOoops... v=z
, triple=())
ValueErrormaxmin)vtripleextrapolatelowerdefaultuppers         r   r   r   /   sR    #E7EW%%%%%%%%:9: :$9: :-29: :
 
 	
  &Auu%%G||u~~s	G((a'kkew>N>NG%00G 0 0KKEW,,,BBBeBBwBB%BBB -,,G00r   )validatec                   |rt          |                                           t          |                                          k    sKJ t          |                                           t          |                                          z
              i }|                                D ]6\  }}|                     ||d                   }t	          |||          ||<   7|S )a  Normalizes location based on axis min/default/max values from axes.

    >>> axes = {"wght": (100, 400, 900)}
    >>> normalizeLocation({"wght": 400}, axes)
    {'wght': 0.0}
    >>> normalizeLocation({"wght": 100}, axes)
    {'wght': -1.0}
    >>> normalizeLocation({"wght": 900}, axes)
    {'wght': 1.0}
    >>> normalizeLocation({"wght": 650}, axes)
    {'wght': 0.5}
    >>> normalizeLocation({"wght": 1000}, axes)
    {'wght': 1.0}
    >>> normalizeLocation({"wght": 0}, axes)
    {'wght': -1.0}
    >>> axes = {"wght": (0, 0, 1000)}
    >>> normalizeLocation({"wght": 0}, axes)
    {'wght': 0.0}
    >>> normalizeLocation({"wght": -1}, axes)
    {'wght': 0.0}
    >>> normalizeLocation({"wght": 1000}, axes)
    {'wght': 1.0}
    >>> normalizeLocation({"wght": 500}, axes)
    {'wght': 0.5}
    >>> normalizeLocation({"wght": 1001}, axes)
    {'wght': 1.0}
    >>> axes = {"wght": (0, 1000, 1000)}
    >>> normalizeLocation({"wght": 0}, axes)
    {'wght': -1.0}
    >>> normalizeLocation({"wght": -1}, axes)
    {'wght': -1.0}
    >>> normalizeLocation({"wght": 500}, axes)
    {'wght': -0.5}
    >>> normalizeLocation({"wght": 1000}, axes)
    {'wght': 0.0}
    >>> normalizeLocation({"wght": 1001}, axes)
    {'wght': 0.0}
    r	   )r=   )setkeysitemsgetr   )locationaxesr=   rA   outtagr<   r;   s           r   r   r   N   s    N  
8==??##s499;;'7'7777X]]__9M9MPSIIKKQ
 Q
 :
777 Czz|| F FVLLfQi((!!VEEECJr   Tc                    |r|t          d          d}|                                D ]\  }\  }}}	|r8|dk    r||k    s||	k    r |dk     r|	dk    r-|                     |d          }
n|| v sJ | |         }
|
|k    rY|r||         \  }}|
|k     r7||k    r1||k    r||	k     r||
|	z
  ||	z
  z  z  }||k     r||
|z
  ||z
  z  z  }n<||
k     r6||	k    r0||k    r||k     r||
|z
  ||z
  z  z  }||k     r||
|	z
  ||	z
  z  z  }|
|k    s|	|
k    rd} n&|
|k     r||
|z
  ||z
  z  z  }||
|	z
  ||	z
  z  z  }|S )a  Returns the scalar multiplier at location, for a master
    with support.  If ot is True, then a peak value of zero
    for support of an axis means "axis does not participate".  That
    is how OpenType Variation Font technology works.

    If extrapolate is True, axisRanges must be a dict that maps axis
    names to (axisMin, axisMax) tuples.

      >>> supportScalar({}, {})
      1.0
      >>> supportScalar({'wght':.2}, {})
      1.0
      >>> supportScalar({'wght':.2}, {'wght':(0,2,3)})
      0.1
      >>> supportScalar({'wght':2.5}, {'wght':(0,2,4)})
      0.75
      >>> supportScalar({'wght':2.5, 'wdth':0}, {'wght':(0,2,4), 'wdth':(-1,0,+1)})
      0.75
      >>> supportScalar({'wght':2.5, 'wdth':.5}, {'wght':(0,2,4), 'wdth':(-1,0,+1)}, ot=False)
      0.375
      >>> supportScalar({'wght':2.5, 'wdth':0}, {'wght':(0,2,4), 'wdth':(-1,0,+1)})
      0.75
      >>> supportScalar({'wght':2.5, 'wdth':.5}, {'wght':(0,2,4), 'wdth':(-1,0,+1)})
      0.75
      >>> supportScalar({'wght':3}, {'wght':(0,1,2)}, extrapolate=True, axisRanges={'wght':(0, 2)})
      -1.0
      >>> supportScalar({'wght':-1}, {'wght':(0,1,2)}, extrapolate=True, axisRanges={'wght':(0, 2)})
      -1.0
      >>> supportScalar({'wght':3}, {'wght':(0,2,2)}, extrapolate=True, axisRanges={'wght':(0, 2)})
      1.5
      >>> supportScalar({'wght':-1}, {'wght':(0,2,2)}, extrapolate=True, axisRanges={'wght':(0, 2)})
      -0.5
    Nz2axisRanges must be passed when extrapolate is Trueg      ?r6   )	TypeErrorrE   rF   )rG   supportotr=   
axisRangesscalaraxisr>   peakr@   r;   axisMinaxisMaxs                r   r   r      s   D  Nz)LMMMF&-mmoo (3 (3""udE 	s{{t||te||s{{us{{T3''AA8####A99 	)$/GW7{{u//7??te||q5yTE\::Ft^^q5yTE\::F $ 1E!1!1d??ut||q5yTE\::FG^^q5yTE\::F::!FEt88q5yTE\22FFq5yTE\22FFMr   c                       e Zd ZdZddZd Zed             Zeg fd            Zd Z	d	 Z
d
 Zd ZeddZeddZd Zd Zed             Zed             Zd ZeddZeddZdS )r   az  Locations must have the base master at the origin (ie. 0).

    If the extrapolate argument is set to True, then values are extrapolated
    outside the axis range.

      >>> from pprint import pprint
      >>> locations = [       {'wght':100},       {'wght':-100},       {'wght':-180},       {'wdth':+.3},       {'wght':+120,'wdth':.3},       {'wght':+120,'wdth':.2},       {},       {'wght':+180,'wdth':.3},       {'wght':+180},       ]
      >>> model = VariationModel(locations, axisOrder=['wght'])
      >>> pprint(model.locations)
      [{},
       {'wght': -100},
       {'wght': -180},
       {'wght': 100},
       {'wght': 180},
       {'wdth': 0.3},
       {'wdth': 0.3, 'wght': 180},
       {'wdth': 0.3, 'wght': 120},
       {'wdth': 0.2, 'wght': 120}]
      >>> pprint(model.deltaWeights)
      [{},
       {0: 1.0},
       {0: 1.0},
       {0: 1.0},
       {0: 1.0},
       {0: 1.0},
       {0: 1.0, 4: 1.0, 5: 1.0},
       {0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.6666666666666666},
       {0: 1.0,
        3: 0.75,
        4: 0.25,
        5: 0.6666666666666667,
        6: 0.4444444444444445,
        7: 0.6666666666666667}]
    NFc                     t          t          d D                                 t                    k    rt          d           _        ||ng  _        | _        |r                               nd  _        d D                                   j                  }t          |           _
         fdD              _        fd j
        D              _                                          i  _        d S )Nc              3   r   K   | ]2}t          t          |                                                    V  3d S r   )tuplesortedrE   r   s     r   r   z*VariationModel.__init__.<locals>.<genexpr>   s:      ??5		**++??????r   zLocations must be unique.c                 J    g | ] }d  |                                 D             !S )c                 &    i | ]\  }}|d k    ||S r6   r   r   kr;   s      r   
<dictcomp>z6VariationModel.__init__.<locals>.<listcomp>.<dictcomp>  s#    ???tq!a3hhahhhr   rE   r   locs     r   r   z+VariationModel.__init__.<locals>.<listcomp>  s/    UUUC??syy{{???UUUr   )	axisOrder)keyc                 D    g | ]}j                             |          S r   	locationsindexr   r   selfs     r   r   z+VariationModel.__init__.<locals>.<listcomp>  )    CCCA,,Q//CCCr   c                 :    g | ]}                     |          S r   rh   r   r   rg   s     r   r   z+VariationModel.__init__.<locals>.<listcomp>  %    JJJayq11JJJr   )r1   rC   r
   origLocationsrc   r=   computeAxisRangesrO   getMasterLocationsSortKeyFuncrY   rg   mappingreverseMapping_computeMasterSupports
_subModels)rj   rg   rc   r=   keyFuncs   ``   r   __init__zVariationModel.__init__   s&   s??Y?????@@C	NNRR%&ABBB&&/&;&?JT$00;;;PTUU9UUU	44 5 
 
  	w777 DCCCCCCJJJJ4>JJJ##%%%r   c                    d|vr| |fS t          d |D                       }| j                            |          }|2t          t	          || j                  | j                  }|| j        |<   |t	          ||          fS )zReturn a sub-model and the items that are not None.

        The sub-model is necessary for working with the subset
        of items when some are None.

        The sub-model is cached.Nc              3      K   | ]}|d uV  	d S r   r   r   r;   s     r   r   z-VariationModel.getSubModel.<locals>.<genexpr>  s&      11aATM111111r   )rX   rv   rF   r   r4   rp   rc   )rj   rE   rd   subModels       r   getSubModelzVariationModel.getSubModel  s     u;11511111?&&s++%gc43E&F&FWWH#+DOC e,,,,r   c                     i }d | D             }| D ][}|D ]V}|                     |d          }|                     |||f          \  }}t          ||          t          ||          f||<   W\|S )Nc                 @    h | ]}|                                 D ]}|S r   )rD   )r   rb   rQ   s      r   	<setcomp>z3VariationModel.computeAxisRanges.<locals>.<setcomp>(  s-    DDDCDD4DDDDr   r   )rF   r:   r9   )rg   rO   allAxesrb   rQ   valuerS   rT   s           r   rq   z VariationModel.computeAxisRanges%  s    
DD9DDD 	L 	LC L La((#->>$#G#G #&ug#6#6E78K8K#K
4  L r   c                 L   i | vrt          d          i }| D ]|}t          |          dk    rt          t          |                    }||         }||vrdh||<   |||         vsJ d|d|d|            ||                             |           }d } |||          }|S )NzBase master not found.r	   r6   zValue "z" in axisPoints["z"] -->  c                       d  fd}|S )Nc                 &    | dk     rdn	| dk    rdndS )Nr   r	   r   )r;   s    r   signzJVariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.signB  s     UUrra!ee:r   c           	          t                     }fd                                 D             } fdD             }|                    fdt                                                     D                        |t          |           t          fd|D                       t          |          t           fd|D                       t           fd|D                       fS )Nc                 6    g | ]\  }}|v 	||         v |S r   r   )r   rQ   r   
axisPointss      r   r   z]VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<listcomp>G  sA       #ez))ez$7G.G.G .G.G.Gr   c                     g | ]}|v |	S r   r   r   rQ   rb   s     r   r   z]VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<listcomp>L  s    IIITS[[t[[[r   c                     g | ]}|v|	S r   r   r   rQ   rc   s     r   r   z]VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<listcomp>N  s#    RRRdD	<Q<QT<Q<Q<Qr   c              3   N   K   | ]}|v r                     |          nd V   dS )i   Nrm   r   s     r   r   z\VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<genexpr>S  sR          261B1B	---     r   c              3   :   K   | ]} |                   V  d S r   r   )r   rQ   rb   r   s     r   r   z\VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<genexpr>X  s@        ,0SY     r   c              3   B   K   | ]}t          |                   V  d S r   )absr   s     r   r   z\VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.key.<locals>.<genexpr>[  s>        +/CI     r   )r1   rE   extendrY   rD   rX   )rb   rankonPointAxesorderedAxesrc   r   r   s   `   r   rd   zIVariationModel.getMasterLocationsSortKeyFunc.<locals>.getKey.<locals>.keyE  sd   3xx   '*yy{{  
 JIII	III""RRRRfSXXZZ&8&8RRR   %%%    $/     +&&     4?         3>     r   r   )r   rc   rd   r   s   `` @r   getKeyz<VariationModel.getMasterLocationsSortKeyFunc.<locals>.getKeyA  s>    ; ; ;      6 Jr   )r
   r1   r(   r'   add)rg   rc   r   rb   rQ   r   r   rets           r   rr   z,VariationModel.getMasterLocationsSortKeyFunc0  s    Y%&>???
 
	( 
	(C3xx1}}S		??DIE:%%$'5
4 Z-----;@55$$$

S .--t  ''''	 	 	B fZ++
r   c                      fd|D             } fd|D              _         d  j         D              fdD              _        fd j        D              _        i  _        |S )Nc                      g | ]
}|         S r   r   )r   idxmaster_lists     r   r   z1VariationModel.reorderMasters.<locals>.<listcomp>h  s    888K$888r   c                 *    g | ]}j         |         S r   )rp   )r   r   rj   s     r   r   z1VariationModel.reorderMasters.<locals>.<listcomp>i  s!    III#d05IIIr   c                 J    g | ] }d  |                                 D             !S )c                 &    i | ]\  }}|d k    ||S r\   r   r]   s      r   r_   z<VariationModel.reorderMasters.<locals>.<listcomp>.<dictcomp>k  s#    666daQ#XXQXXXr   r`   ra   s     r   r   z1VariationModel.reorderMasters.<locals>.<listcomp>j  s<     
 
 
;>66ciikk666
 
 
r   c                 D    g | ]}j                             |          S r   rf   ri   s     r   r   z1VariationModel.reorderMasters.<locals>.<listcomp>m  rk   r   c                 :    g | ]}                     |          S r   rm   rn   s     r   r   z1VariationModel.reorderMasters.<locals>.<listcomp>n  ro   r   )rp   rs   rg   rt   rv   )rj   r   rs   new_listrg   s   ``  @r   reorderMasterszVariationModel.reorderMasterse  s     9888888IIIIIII
 
BFBT
 
 
	 DCCCCCCJJJJ4>JJJr   c                 X   g | _         |                                 }t          |          D ]i\  }}t          |                                          }|d |         D ]}t          |                                          |k    r)d}|                                D ]:\  }\  }}	}
||         d         |	k    s|||         d         cxk     r|
k     sn d} n;|s}i }d}|                                D ]g}||         d         }||v sJ ||         \  }}}
||
}}||k     r|}||z
  ||z
  z  }n||k     r|}||z
  |
|z
  z  }nO||k    ri }|}||k    r|||f||<   h|                                D ]
\  }}|||<   | j                             |           k|                                  d S )NTr	   Fr   )supports_locationsToRegions	enumeraterC   rD   rE   append_computeDeltaWeights)rj   regionsiregionlocAxesprev_regionrelevantrQ   r>   rR   r@   bestAxes	bestRatiovallocVnewLowernewUpperratior<   s                      r   ru   z%VariationModel._computeMasterSupportsr  s5   **,,"7++ 2	) 2	)IAv&++--((G&rr{ .* .*{''))**g5528,,..  .D.5$#D)!,44 ;t#4Q#7????%????#(  	',,.. D DD%d+A.C6>>>>)/&E4).hHTzz#&!$t =#&!$t = !y((#%$)		))*2D()C$,NN$4$4 * *LD&#)F4LL*M  ((((!!#####r   c           	         | j         }i }i }|D ]j}|                                D ]S\  }}t          ||                    ||                    ||<   t	          ||                    ||                    ||<   Tkg }|D ]V}i }	|                                D ](\  }
}|dk    rd|||
         f|	|
<   ||
         |df|	|
<   )|                    |	           W|S )Nr   )rg   rE   r:   rF   r9   r   )rj   rg   minVmaxVr   r^   r;   r   rb   r   rQ   r   s               r   r   z"VariationModel._locationsToRegions  s	   N	  	1 	1A		 1 11a!Q00Qa!Q00Q1  	# 	#CF!iikk 9 9
d!88$%tT$Z#8F4LL$(Ja#8F4LLNN6""""r   c                     g | _         t          | j                  D ]Z\  }}i }t          | j        d |                   D ]\  }}t	          ||          }|r|||<   | j                             |           [d S r   )deltaWeightsr   rg   r   r   r   )rj   r   rb   deltaWeightjrM   rP   s          r   r   z#VariationModel._computeDeltaWeights  s    // 	2 	2FAsK'bqb(9:: , ,
7&sG44 ,%+KN$$[1111	2 	2r   roundc                   t          |          t          | j                  k    s+J t          |          t          | j                  f            | j        }g }t          | j                  D ]k\  }}|||                  }|                                D ]%\  }}	|	dk    r|||         z  }|||         |	z  z  }&|                     ||                     l|S )Nr	   )r1   r   rt   r   rE   r   )
rj   masterValuesr   rs   rI   r   weightsdeltar   weights
             r   	getDeltaszVariationModel.getDeltas  s    <  C(9$:$::::!""=
::: %#D$566 	% 	%JAw ,E$]]__ - -	6Q;;SVOEESVf_,EEJJuuU||$$$$
r   c                n    |                      |          \  }}|                    ||          |j        fS )Nr   )r}   r   r   )rj   rE   r   models       r   getDeltasAndSupportsz#VariationModel.getDeltasAndSupports  s6    ''..uuE22ENBBr   c                 .      fd j         D             S )zReturn scalars for each delta, for the given location.
        If interpolating many master-values at the same location,
        this function allows speed up by fetching the scalars once
        and using them with interpolateFromMastersAndScalars().c                 J    g | ]}t          |j        j                    S ))r=   rO   )r   r=   rO   )r   rM   rb   rj   s     r   r   z-VariationModel.getScalars.<locals>.<listcomp>  sH     
 
 
  W$*:t  
 
 
r   )r   )rj   rb   s   ``r   
getScalarszVariationModel.getScalars  s8    

 
 
 
 
  =	
 
 
 	
r   c                 T                          |          t          t          t           j                                      D ]8\  }}|                                D ]\  }}|xx         |         |z  z  cc<   9 fdt          t                              D             S )a  Return multipliers for each master, for the given location.
        If interpolating many master-values at the same location,
        this function allows speed up by fetching the scalars once
        and using them with interpolateFromValuesAndScalars().

        Note that the scalars used in interpolateFromMastersAndScalars(),
        are *not* the same as the ones returned here. They are the result
        of getScalars().c                 6    g | ]}j         |                  S r   )rs   )r   r   rI   rj   s     r   r   z3VariationModel.getMasterScalars.<locals>.<listcomp>  s$    ===s4<?#===r   )r   reversedlistr   r   rE   ranger1   )rj   targetLocationr   r   r   r   rI   s   `     @r   getMasterScalarszVariationModel.getMasterScalars  s     oon--"4	$2C(D(D#E#EFF 	* 	*JAw$]]__ * *	6A#a&6/)* >====U3s88__===
r   c                     d}t          |           t          |          k    sJ t          | |          D ]\  }}|s||z  }||}||z  }|S )aV  Interpolate from values and scalars coefficients.

        If the values are master-values, then the scalars should be
        fetched from getMasterScalars().

        If the values are deltas, then the scalars should be fetched
        from getScalars(); in which case this is the same as
        interpolateFromDeltasAndScalars().
        Nr0   )valuesscalarsr;   r   rP   contributions         r   interpolateFromValuesAndScalarsz.VariationModel.interpolateFromValuesAndScalars  st     6{{c'll**** 11 	" 	"ME6  6>Ly \!r   c                 8    t                               | |          S )z>Interpolate from deltas and scalars fetched from getScalars().)r   r   )deltasr   s     r   interpolateFromDeltasAndScalarsz.VariationModel.interpolateFromDeltasAndScalars  s     ==fgNNNr   c                 X    |                      |          }|                     ||          S )z)Interpolate from deltas, at location loc.)r   r   )rj   rb   r   r   s       r   interpolateFromDeltasz$VariationModel.interpolateFromDeltas  s)    //#&&33FGDDDr   c                X    |                      |          }|                     ||          S )z0Interpolate from master-values, at location loc.)r   r   )rj   rb   r   r   r   s        r   interpolateFromMastersz%VariationModel.interpolateFromMasters  s+    '',,33L'JJJr   c                \    |                      ||          }|                     ||          S )zInterpolate from master-values, and scalars fetched from
        getScalars(), which is useful when you want to interpolate
        multiple master-values with the same location.r   )r   r   )rj   r   r   r   r   s        r    interpolateFromMastersAndScalarsz/VariationModel.interpolateFromMastersAndScalars#  s/     E::33FGDDDr   )NF)__name__
__module____qualname____doc__rx   r}   staticmethodrq   rr   r   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s       + +Z   ,- - -    \ ;= 2 2 2 \2h  6$ 6$ 6$p  ,	2 	2 	2 07     " 4; C C C C C

 

 

  "   \, O O \OE E E
 BI K K K K K
 PW E E E E E E Er   r   c                     |                                 }|s S  |v r|          S t          |          } |k     r ||         z   |z
  S t          |          } |k    r ||         z   |z
  S t           fd|D                       }t           fd|D                       }||         }||         }|||z
   |z
  z  ||z
  z  z   S )Nc              3   (   K   | ]}|k     |V  d S r   r   r]   s     r   r   z%piecewiseLinearMap.<locals>.<genexpr>8  '      %%!q1uuAuuuu%%r   c              3   (   K   | ]}|k    |V  d S r   r   r]   s     r   r   z%piecewiseLinearMap.<locals>.<genexpr>9  r   r   )rD   r:   r9   )r;   rs   rD   r^   abvavbs   `       r   r   r   +  s    <<>>D DyyqzD		A1uu71:~!!D		A1uu71:~!!%%%%t%%%%%A%%%%t%%%%%A	B	BbQU#q1u---r   c                   
 ddl m} ddl}|                    dt          j                  }|                    dddd	
           |                    d          }|                    dddt                     |                    ddddd           |	                    |           }  || j
                   ddlm} | j        rddlm}  |            }|                    | j                   d |j        D             }t#          d            ||           |                                 t#          d           d |j        D             } ||           nJd t'          t)          d          t)          d           d!z             D             

fd"| j        D             }t-          |          }	t#          d#            ||	j                   t#          d$            ||	j                   dS )%z*Normalize locations on a given designspacer   )configLoggerNzfonttools varLib.models)descriptionz
--loglevelLEVELINFOz Logging level (defaults to INFO))metavarr?   helpT)requiredz-dz--designspaceDESIGNSPACE)r   typez-lz--locationsLOCATION+zFMaster locations as comma-separate coordinates. One must be all zeros.)r   nargsr   )level)pprint)DesignSpaceDocumentc                     g | ]	}|j         
S r   rG   r   ss     r   r   zmain.<locals>.<listcomp>c      000q
000r   zOriginal locations:zNormalized locations:c                     g | ]	}|j         
S r   r   r  s     r   r   zmain.<locals>.<listcomp>h  r  r   c                 ,    g | ]}t          |          S r   )chr)r   cs     r   r   zmain.<locals>.<listcomp>k  s    >>>1A>>>r   AZr	   c                     g | ]<}t          t          d  |                    d          D                                 =S )c              3   4   K   | ]}t          |          V  d S r   )floatr{   s     r   r   z"main.<locals>.<listcomp>.<genexpr>m  s(      ;;E!HH;;;;;;r   ,)dictr2   split)r   r  rH   s     r   r   zmain.<locals>.<listcomp>l  sQ     
 
 
BCDT;;aggcll;;;<<==
 
 
r   zSorted locations:z	Supports:)	fontToolsr   argparseArgumentParsermainr   add_argumentadd_mutually_exclusive_groupstr
parse_argsloglevelr   designspacefontTools.designspaceLibr   readsourcesprint	normalizer   ordrg   r   r   )argsr   r  parsergroupr   r   doclocsr   rH   s             @r   r  r  ?  sf   &&&&&&OOO$$!L %  F /	     ///>>E	t_m#NNN	U     T""DLt}%%%% 
@@@@@@!!##!"""00CK000#$$$t%&&&00CK000t>>c#hhC1 = =>>>
 
 
 
GK~
 
 
 4  E	

F5?	+
F5>r   __main__r   )F)TFN)r   __all__fontTools.misc.roundToolsr   errorsr
   r   r   r%   r,   r4   r   r   r   objectr   r   r  r   doctestsysr1   argvexittestmodfailedr   r   r   <module>r0     s   + +   . - - - - - ' ' ' ' ' '- - -' ' '7 7 7 70 0 0 00 0 0
1 1 1 1>/U / / / / /dN N N NbWE WE WE WE WEV WE WE WEt
. . .(5 5 5 5p z
s38}}qCH_W_%&&&&& r   