
    h'K                       S r SSKJr  SSKrSSKrSSKrSSKJrJrJ	r	J
r
JrJrJr  SSKJrJrJrJrJrJrJrJrJr  SSKJrJr  SSKJrJrJrJrJ r J!r!J"r"  \RF                  " \$5      r%\\\\/\&4   r'        SS jr(S	S	\(4         SS
 jjr)SS\(4         SS jjr*    SS jr+              SS jr,SS jr-      SS jr.      SS jr/g)zAllows building all the variable fonts of a DesignSpace version 5 by
splitting the document into interpolable sub-space, then into each VF.
    )annotationsN)AnyCallableDictIteratorListTuplecast)	AxisDescriptorAxisMappingDescriptorDesignSpaceDocumentDiscreteAxisDescriptorInstanceDescriptorRuleDescriptorSimpleLocationDictSourceDescriptorVariableFontDescriptor)	StatNamesgetStatNames)ConditionSetRangeRegiongetVFUserRegionlocationInRegionregionInRegionuserRegionToDesignRegionc                    UR                   =(       d    UR                  R                  S5      nUR                  =(       d    UR                  R                  S5      nU SU S3$ )zDefault callable to synthesize an instance filename
when makeNames=True, for instances that don't specify an instance name
in the designspace. This part of the name generation can be overriden
because it's not specified by the STAT table.
en-z.ttf)
familyNamefamilyNamesget	styleName
styleNames)docinstance	statNamesr    r#   s        P/var/www/html/env/lib/python3.13/site-packages/fontTools/designspaceLib/split.pydefaultMakeInstanceFilenamer)   )   sY     $$G	(=(=(A(A$(GJ""Di&:&:&>&>t&DI\9+T**    Tc           
   #  4  #    / n0 nU R                    H~  n[        US5      (       a#  [        [        U5      nUR	                  U5        M7  [        [
        U5      n[        UR                  UR                  UR                  5      XVR                  '   M     [        R                  " U Vs/ s H  ofR                  PM     sn6 nU HD  n[        XH5       V	V
s0 s H  u  pU	R                  U
_M     nn	n
[        U 0 UEUESUUUS9nX4v   MF     gs  snf s  sn
n	f 7f)a  Split the given DS5 into several interpolable sub-designspaces.
There are as many interpolable sub-spaces as there are combinations of
discrete axis values.

E.g. with axes:
    - italic (discrete) Upright or Italic
    - style (discrete) Sans or Serif
    - weight (continuous) 100 to 900

There are 4 sub-spaces in which the Weight axis should interpolate:
(Upright, Sans), (Upright, Serif), (Italic, Sans) and (Italic, Serif).

The sub-designspaces still include the full axis definitions and STAT data,
but the rules, sources, variable fonts, instances are trimmed down to only
keep what falls within the interpolable sub-space.

Args:
  - ``makeNames``: Whether to compute the instance family and style
    names using the STAT data.
  - ``expandLocations``: Whether to turn all locations into "full"
    locations, including implicit default axis values where missing.
  - ``makeInstanceFilename``: Callable to synthesize an instance filename
    when makeNames=True, for instances that don't specify an instance name
    in the designspace. This part of the name generation can be overridden
    because it's not specified by the STAT table.

.. versionadded:: 5.0
valuesTkeepVFs	makeNamesexpandLocationsmakeInstanceFilenameN)axeshasattrr
   r   appendr   r   minimummaximumdefaultname	itertoolsproductr,   zip_extractSubSpace)r%   r/   r0   r1   discreteAxesinterpolableUserRegionaxisvalueCombinationsr,   discreteAxisvaluediscreteUserLocationsubDocs                r(   splitInterpolablerE   6   s!    D L%'4"" .5D%-D051"99-  "))L+QLDKKL+QR# (+<'@ 
'@# u$'@ 	  
 ">%>)=>+!5
 #** $ ,R 
s   B'D)D>DD.*DFc           
   #     #    U R                  5        HK  n[        X5      n[        U USUUUS9n0 UR                  EUR                  EUl        UR                  U4v   MM     g7f)a  Convert each variable font listed in this document into a standalone
designspace. This can be used to compile all the variable fonts from a
format 5 designspace using tools that can only deal with 1 VF at a time.

Args:
  - ``makeNames``: Whether to compute the instance family and style
    names using the STAT data.
  - ``expandLocations``: Whether to turn all locations into "full"
    locations, including implicit default axis values where missing.
  - ``makeInstanceFilename``: Callable to synthesize an instance filename
    when makeNames=True, for instances that don't specify an instance name
    in the designspace. This part of the name generation can be overridden
    because it's not specified by the STAT table.

.. versionadded:: 5.0
Fr-   N)getVariableFontsr   r<   libr8   )r%   r/   r0   r1   vfvfUserRegionvfDocs          r(   splitVariableFontsrL   y   si     . ""$&s/ +!5
 ,uyy+BFF+	ggun %s   A!A#c                p    0 n[        U 5       H$  u  p#[        U5       H  u  pESUl        XQU'   M     M&     U$ )zConvert each variable font listed in this document into a standalone
format 4 designspace. This can be used to compile all the variable fonts
from a format 5 designspace using tools that only know about format 4.

.. versionadded:: 5.0
z4.1)rE   rL   formatVersion)r%   vfs	_locationrD   vfNamerK   s         r(   convert5to4rR      sB     C.s3	/7MF"'EK 8 4 Jr*   c                 ^ ^^ [        5       nU U4S jnT R                   GH5  nXR                     n	[        U	[        5      (       d  M)  [        US5      (       d  M<  [        [        U5      nUR                  [        UR                  UR                  UR                  UR                  [        U	R                  UR                  5      U	R                  =(       d    UR                  [        U	R                   UR                   5      UR"                   V
Vs/ s H/  u  pU	R                  U
s=::  a  U	R                   ::  d  M(  O  M,  X4PM1     snn
S S S9
5        GM8     / =Ul        nUR                   Vs1 s H  oR                  iM     snmT R$                   GH  n['        U4S jUR(                  R+                  5        5       5      (       d  M8  ['        U4S jUR,                  R+                  5        5       5      (       d-  [.        R1                  SUR(                  UR,                  5        M  [3        5       nUR5                  UR(                  R+                  5       5        UR5                  UR,                  R+                  5       5        T R                   H  nUR                  U;  a  M  XR                     n	U	R                  UR                  :w  dC  U	R                  b  U	R                  UR                  :w  d  U	R                   UR                   :w  d  M  [.        R1                  SUR                  5        M     UR7                  [9        UR(                  UR,                  S95        GM     [;        T U5      n[=        T R>                  U5      Ul        T R@                  Ul         T RB                   H  n[E        T RG                  URH                  5      U5      (       d  M/  URK                  [M        URN                  URP                  URR                  UR                  [U        X" U5      5      URV                  URX                  URZ                  UR\                  UR^                  UR`                  S	95        M     URc                  5       nT Rc                  5       nUb  Ub  URd                  Ul2        U(       a  T Rg                  5        H  n[i        T U5      n[k        UU5      (       d  M"  URm                  [o        UR                  URN                  URp                   Vs/ s H)  n[        UUR                     [        5      (       d  M'  UPM+     snURr                  S
95        M     T Rt                   GH)  n[E        URw                  T 5      U5      (       d  M&  U(       Ga  [y        T URw                  T 5      5      nURX                  =(       d    URz                  R}                  S5      nURZ                  =(       d    UR~                  R}                  S5      nUR                  [        S0 SURN                  =(       d
    U" T UU5      _SURP                  _SURR                  _SUR                  =(       d    U SU 3_ST(       a  0 OUR                  _S[U        X" U5      5      _SU_SU_SUR                  =(       d    UR                  _SUR                  =(       d    UR                  R}                  S5      _SUR                  =(       d    UR                  _SURd                  =(       d    URz                  _SUR                  =(       d    UR~                  _SUR                  =(       d    UR                  _SUR                  =(       d    0 _SURr                  _65        GM3  UR                  [        S0 SURN                  _SURP                  _SURR                  _SUR                  _ST(       a  0 OUR                  _S[U        X" U5      5      _SURX                  _SURZ                  _SUR                  _SUR                  _SUR                  _SURd                  _SUR                  _SUR                  _SUR                  _SURr                  _65        GM,     T Rr                  Ul9        U$ s  snn
f s  snf s  snf )Nc                L   > T(       a  U R                  T5      $ U R                  $ N)getFullDesignLocationdesignLocation)objectr%   r0   s    r(   maybeExpandDesignLocation3_extractSubSpace.<locals>.maybeExpandDesignLocation   s#    //44(((r*   r5   )
tagr8   
labelNameshiddenr5   r7   r6   mapaxisOrdering
axisLabelsc              3  ,   >#    U  H	  oT;   v   M     g 7frU    .0r?   
subDocAxess     r(   	<genexpr>#_extractSubSpace.<locals>.<genexpr>   s     O2N$:%2N   c              3  ,   >#    U  H	  oT;   v   M     g 7frU   rb   rc   s     r(   rf   rg      s     P2O$:%2Orh   zPIn axis mapping from input %s, some output axes are not in the variable-font: %szALimiting axis ranges used in <mapping> elements not supported: %s)inputLocationoutputLocation)filenamepathfontr8   rW   	layerNamer    r#   muteKerningmuteInfomutedGlyphNames)r8   rl   axisSubsetsrH   r   rl   rm   rn   r8    userLocationrW   r    r#   postScriptFontNamestyleMapFamilyNamestyleMapStyleNamelocalisedFamilyNamelocalisedStyleNamelocalisedStyleMapFamilyNamelocalisedStyleMapStyleNamerH   rb   )Jr   r2   r8   
isinstancer   r3   r
   r   addAxisr[   r\   r]   maxr5   r7   minr6   r^   axisMappingsallrj   keysrk   LOGGERerrorsetupdater4   r   r   _subsetRulesBasedOnConditionsrulesrulesProcessingLastsourcesr   map_backwardrW   	addSourcer   rl   rm   rn   _filterLocationro   r    r#   rp   rq   rr   findDefaultry   rG   r   r   addVariableFontr   rs   rH   	instancesgetFullUserLocationr   r!   r"   r$   addInstancer   ru   rv   rw   styleMapFamilyNamesrx   rz   r{   r|   )r%   
userRegionr.   r/   r0   r1   rD   rY   r?   rangeuserdesignmappingsmappingmappingAxesdesignRegionsource	vfDefault
oldDefaultrI   rJ   
axisSubsetr&   r'   r    r#   re   s   `   `                     @r(   r<   r<      s    !"F) 99%eU##i(@(@ -DNN#;;t||<!MM9T\\t||< -1HH,4LD ==DAEMMA 'A ',4 "&## : &('F((.4))4J##O'2G2G2L2L2NOOOP'2H2H2M2M2OPPPLLb%%&&
 e70055787116689HHDyy+yy)E-MM-%--4<<2O==DLL0WII   	!%33&55	
; $P ,C<L0LIFL!$!8!8F ++ 0 01F1F GTT[[[[[[. 9& A  !**!,, **".. & 6 6	
	 . ""$I"J!7(2(F(F	% &&(B*33LlJ77&&*WW!# /1nn%.<
)*Z__*EuM '.<%
 FF	 )" MM < <S A:NN$S(*F*Fs*KLI!,,O	0E0E0I0I$0OJ **Li.B.B.F.Ft.LI" %.. F+C9E " "	
 "EZL)*E (7H<Q<Q $3"$=h$G$  * ( (0'B'B (4 33 (0'B'B (? 4488>  '/&@&@ '3 22#$ )1(D(D )- ,,'( (0'B'B (, +++, 190T0T 15 44/0 08/R/R 034 !5> " %..! " "	
 (7H<Q<Q $3"$=h$G$  (22 '00 (0'B'B (0'B'B '/&@&@ )1(D(D (0'B'B  190T0T!" 08/R/R#$ !%O "| FJMU 5h%s$   'b0?b0b02b6&b;b;c                    0 nU  H\  nUR                  S5      UR                  S5      pC[        Ub  UO[        R                  * Ub  UO[        R                  5      XS   '   M^     U$ )Nr5   r6   r8   )r"   r   mathinf)conditionSetc	conditionr5   r6   s        r(   _conditionSetFromr     sa    A!	$==3Y]]95M$*G	*G 
F
 " Hr*   c           	     `   / nU  GH$  n[        UR                  / UR                  S9nUR                   H  n[	        U5      n/ nSnUR                  5        H  u  pX;  a  M  [        U
[        [        45      (       a  XU	   ;   a  M1  SnM5  XU	   ;   a  M?  Xi   R                  U
5      nUb+  UR                  U	UR                  UR                  S.5        M  SnM     U(       a  M  UR                  R                  U5        M     UR                  (       d  GM  UR                  U5        GM'     U$ )N)r8   conditionSetssubsFT)r8   r5   r6   )r   r8   r   r   r   itemsr}   floatintintersectionr4   r5   r6   )r   r   newRulesrulenewRuleconditionsetcsnewConditionsetdiscardConditionsetselectionNameselectionValuer   s               r(   r   r     s4   $ &(H"0"499#
 !..L"<0B46O"'1=1C1C1E- *nucl;;%M):: /3+ &M)::')'8'E'En'U'3+22,9/;/C/C/;/C/C!" 37/; 2F< '&%%,,_=G /H    OOG$S V Or*   c                    UR                  5        VVs0 s H'  u  p#X ;   d  M  [        X   [        5      (       d  M%  X#_M)     snn$ s  snnf rU   )r   r}   r   )r   locationr8   rB   s       r(   r   r     sN     $>>++KD 	",Z-=u"E 	+  s   AAA)r%   r   r&   r   r'   r   returnstr)
r%   r   r/   boolr0   r   r1   MakeInstanceFilenameCallabler   z8Iterator[Tuple[SimpleLocationDict, DesignSpaceDocument]])
r%   r   r/   r   r0   r   r1   r   r   z)Iterator[Tuple[str, DesignSpaceDocument]])r%   r   r   zDict[str, DesignSpaceDocument])r%   r   r   r   r.   r   r/   r   r0   r   r1   r   r   r   )r   zList[Dict[str, Any]]r   r   )r   List[RuleDescriptor]r   r   r   r   )r   r   r   Dict[str, float]r   r   )0__doc__
__future__r   r9   loggingr   typingr   r   r   r   r   r	   r
   fontTools.designspaceLibr   r   r   r   r   r   r   r   r   "fontTools.designspaceLib.statNamesr   r   fontTools.designspaceLib.typesr   r   r   r   r   r   r   	getLogger__name__r   r   r   r)   rE   rL   rR   r<   r   r   r   rb   r*   r(   <module>r      s   #    C C C
 
 
 G   
		8	$',i8#=  

+	
+(:
+GP
+
+  9T	@+	@+@+ @+ 7	@+
 >@+J !9T	"	"" " 7	"
 /"J	#"U	UU 	U
 U U 7U Up>>/5>>B r*   