
    (ph$                    2   S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
  SSKrSSKJrJrJrJrJrJr  \R&                  " \5      r\
\S   \S   \S	   \S
   4   rSS	SS
S.r\ " S S5      5       r      SS jr    SS jr      SS jr      SS jrg)a-  Compute name information for a given location in user-space coordinates
using STAT data. This can be used to fill-in automatically the names of an
instance:

.. code:: python

    instance = doc.instances[0]
    names = getStatNames(doc, instance.getFullUserLocation(doc))
    print(names.styleNames)
    )annotations)	dataclass)DictLiteralOptionalTupleUnionN)AxisDescriptorAxisLabelDescriptorDesignSpaceDocumentDiscreteAxisDescriptorSimpleLocationDictSourceDescriptorregularbolditaliczbold italic))FF)FT)TF)TTc                  L    \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S	\S
'   Srg)	StatNames,   z4Name data generated from the STAT table information.zDict[str, str]familyNames
styleNameszOptional[str]postScriptFontNamestyleMapFamilyNameszOptional[RibbiStyleName]styleMapStyleName N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       U/var/www/html/venv/lib/python3.13/site-packages/fontTools/designspaceLib/statNames.pyr   r   ,   s#    >%%''//r#   r   c                
  ^ 0 nU R                  5       nUc  [        R                  S5        O=UR                  c  [        R                  S5        OSUR                  0UR                  En0 nU R                  U5      nUb  SUR                  0UR                  EnO[        U R                  U5      nU(       ak  [        S U 5       5      nUR                  S5        U HB  mSR                  U4S jU 5       5      nU(       d  U R                  b  U R                  nXT'   MD     SU;  d  SU;  a  [        UUS0 SS9$ US    S	US    3R                  SS
5      n	[!        X5      u  pUnX:w  a  [#        X5      nUR$                  n0 n[        U5      R'                  UR)                  5       5       HF  mUR+                  TUS   5      nUR+                  TUS   5      nUS-   U-   R-                  5       UT'   MH     [        UUU	UU
S9$ )a  Compute the family, style, PostScript names of the given ``userLocation``
using the document's STAT information.

Also computes localizations.

If not enough STAT data is available for a given name, either its dict of
localized names will be empty (family and style names), or the name will be
None (PostScript name).

Note: this method does not consider info attached to the instance, like
family name. The user needs to override all names on an instance that STAT
information would compute differently than desired.

.. versionadded:: 5.0
Nz7Cannot determine default source to look up family name.zTCannot look up family name, assign the 'familyname' attribute to the default source.enc              3  J   #    U  H  oR                     H  o"v   M     M     g 7fN)
labelNames.0labellanguages      r$   	<genexpr>getStatNames.<locals>.<genexpr>c   s       &,U=M=M=Mfs   !# c              3     >#    U  H>  nUR                   (       a  M  UR                  R                  TUR                  5      v   M@     g 7fr(   )elidabler)   getdefaultNamer*   s     r$   r.   r/   h   s>      %!' >> FE$$((53D3DEE!'s
   A	-A	)r   r   r   r   r   - )findDefaultLOGGERwarning
familyNamelocalisedFamilyNamelabelForUserLocationnamer)   _getAxisLabelsForUserLocationaxessetaddjoinelidedFallbackNamer   replace_getRibbiStylegetStatNamesr   unionkeysr3   strip)docuserLocationr   defaultSourcer   r,   labels	languages	styleNamer   r   regularUserLocationstyleNamesForStyleMapregularStatNamesr   r:   r-   s                   @r$   rF   rF   7   s9   $ #%K030AMPQ		!	!	)b	

 -**
//

 "$J$$\2EEJJ;%*:*:;
 /sxxF &, I MM$%HH %!'% 	
 !S%;%;%G # 6 6I'08$ & ;$j"8#!# ""
 	
 (-.a
40@/ABJJ3PRS-;C-N*&*'A 0 ; ;$**:??+<= __X{4/@A
)--h8Md8ST	)3c)9I)E(L(L(NH% >
 -/+ r#   c                    [        S U  5       S S9nU Vs0 s H  o"R                  UR                  _M     nnU  H*  nUR                  b  M  UR                  X2R                  '   M,     U$ s  snf )z^Returns axis labels sorted by their ordering, with unordered ones appended as
they are listed.c              3  B   #    U  H  oR                   c  M  Uv   M     g 7fr(   axisOrdering)r+   axiss     r$   r.   '_getSortedAxisLabels.<locals>.<genexpr>   s     @$$"3"3$s   	c                    U R                   $ r(   rU   )as    r$   <lambda>&_getSortedAxisLabels.<locals>.<lambda>   s    annr#   )key)sortedr=   
axisLabelsrV   )r?   
sortedAxesrW   sortedLabelss       r$   _getSortedAxisLabelsrb      sw     @$@$J
 0::/9t		4??"z  : $&*ooL#  :s    A+c                  ^ / n[        U 5      nUR                  5       UR                  5       :w  a8  [        R                  SUR                  5        SUR                  5        S35        UR	                  5        HQ  u  pEX   m[        U4S jU 5       S 5      nUc  [        R                  SU ST S35        M@  UR                  U5        MS     U$ )Nz Mismatch between user location 'z' and available labels for 'z'.c              3     >#    U  H\  nUR                   T:X  dE  UR                  c  M"  UR                  c  M1  UR                  Ts=::  a  UR                  ::  d  MT  O  MX  Uv   M^     g 7fr(   )	userValueuserMinimumuserMaximum)r+   lre   s     r$   r.   0_getAxisLabelsForUserLocation.<locals>.<genexpr>   s`      	#A;;)+MM	 
   CammC  D #s   !A'A'A'A'	A'z!Document needs a label for axis 'z', user value ')rb   rH   r8   r9   itemsnextdebugappend)r?   rK   rM   allAxisLabelsaxisNamer_   r,   re   s          @r$   r>   r>      s     )+F(.M|0022.|/@/@/B.C D(--/04	

 !. 3 3 5 *	/3	#	 0
 =LL3H:_YKWYZ MM% ) !6, Mr#   c                   0 nU R                    Vs0 s H  o3R                  U_M     nnSnSnUR                  S5      nUbg  UR                   HW  nUR                  XR
                     :X  d  M!  UR                  UR                  :  d  M=  UR                  X#R
                  '   Sn  O   UR                  S5      =(       d    UR                  S5      nUby  UR                   Hi  nUR                  XR
                     :X  d  M!  [        UR                  5      [        UR                  5      :  d  MO  UR                  X#R
                  '   Sn  O   [        XV4   0 UEUE4$ s  snf )zCompute the RIBBI style name of the given user location,
return the location of the matching Regular in the RIBBI group.

.. versionadded:: 5.0
FwghtTitalslnt)	r?   tagr3   r_   linkedUserValuer=   re   absBOLD_ITALIC_TO_RIBBI_STYLE)	selfrK   rP   rW   axes_by_tagr   r   regular_labelupright_labels	            r$   rE   rE      sM    .2ii8id88T>iK8DF??6"D!__M--ii1HH "++m.K.KK1>1H1H#II. - ??6"=koof&=D!__M--ii1HH //03}7T7T3UU1>1H1H#II. -  &dl3 6
6
6  O 9s   E)rJ   r   rK   r   returnr   )r?   3list[Union[AxisDescriptor, DiscreteAxisDescriptor]]r|   z$Dict[str, list[AxisLabelDescriptor]])r?   r}   rK   r   r|   zlist[AxisLabelDescriptor])rx   r   rK   r   r|   z)Tuple[RibbiStyleName, SimpleLocationDict])r    
__future__r   dataclassesr   typingr   r   r   r   r	   loggingfontTools.designspaceLibr
   r   r   r   r   r   	getLoggerr   r8   RibbiStyleNamerw   r   rF   rb   r>   rE   r   r#   r$   <module>r      s  	 # ! 8 8   
		8	$IFOHM 	  0 0 0Y	Y,>YYx
=)0#
=#$# #L3
3-?3.3r#   