+
    f7i{  c                   sr   R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t
 ^ RIHtHt ^ RIHtHt ^ RIHtHt ^ RIHtHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIH t  ^ RI!H"t"H#t#H$t$ ^ RI%H&t&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t- ^ RI.H/t/H0t0 ^ RI1H2t2H3t3 ^ RI4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t; ^ RI<H=t=H>t>H?t? ^ RI@tA^ RIBtB^ RICHDtD ^ RIEHFtF ^ RIGHHtH ^RIIHJtJHKtK ]BP                  ! R4      tMRtNR  R! ltOR" tPR# tQ]?! R$. R^O4      tRR_R& ltSR' tTR( tUR) R* ltVR+ tW]?! R,. R2O4      tX]X! R-R.R/R0R1R^ R27      tY]X! R3R4R5R6R7R8^R27      tZR9 t[R: t\R; t]R< t^R= t_R> t`R? taR@ tb]?! RA. R`O4      tcRB tdRaRC lteRaRDR%/RE lltf^2^RF^^K^RG^^d^RH^^}^^^^^	/	tgRI thRJ RK ltiRL . R%RM R%RN3RO RP lltjRQ . R%R%RN3RR ltkRS 3RT ltlRU 3RV ltm ! RW RX]n4      toRY tpRbRZRN/R[ lltqRcR\ ltr]sR]8X  dd   ^ RIttt]u! ]tP                  4      ^8  d   ]tP                  ! ]r! 4       4       ^ RIxtx]tP                  ! ]xP                  ! 4       P                  4       R# R# )da  
Module for dealing with 'gvar'-style font variations, also known as run-time
interpolation.

The ideas here are very similar to MutatorMath.  There is even code to read
MutatorMath .designspace files in the varLib.designspace module.

For now, if you run this file on a designspace file, it tries to find
ttf-interpolatable files for the masters and build a variable-font from
them.  Such ttf-interpolatable and designspace files can be generated from
a Glyphs source, eg., using noto-source as an example:

    .. code-block:: sh

        $ fontmake -o ttf-interpolatable -g NotoSansArabic-MM.glyphs

Then you can make a variable-font this way:

    .. code-block:: sh

        $ fonttools varLib master_ufo/NotoSansArabic.designspace

API *will* change in near future.
)List)Vector)noRoundotRound)floatToFixed)Tagtostr)TTFontnewTable)AxisNamedInstance)GlyphCoordinatesdropImpliedOnCurvePointsUSE_MY_METRICS)Program)TupleVariation)otTables)OTTableWriter)buildermodelsvarStore)VariationMergerCOLRVariationMerger)MVAR_ENTRIES)iup_delta_optimize)addFeatureVariations)DesignSpaceDocumentInstanceDescriptor)splitInterpolablesplitVariableFonts)buildVFStatTable)buildColrV1)unbuildColrV1)partial)OrderedDictdefaultdict
namedtupleN)deepcopy)pformat)	fullmatch)VarLibErrorVarLibValidationErrorzfontTools.varLibz1com.github.fonttools.varLib.featureVarsFeatureTagc                s:    V ^8  d   QhR\         \        ,          /# )   	instances)r    r   format   "@/usr/lib64/python3.14/site-packages/fontTools/varLib/__init__.py__annotate__r0   J   s     Z ZT*<%= Z    c           	     s   V'       g   Q h\        V\        4      '       g   Q h\        P                  R4       \	        R4      pV R,          p\
        ;QJ d'    R \        VRR4       4       F  '       g   K   RM	  RM! R \        VRR4       4       4      pRpV'       d
   RV,           pVP                  4        F  p\        4       p\        VP                  4      Vn        VP                  VP                  VP                  uVn        Vn        Vn        VP%                  VP&                  V RVR	7      Vn        \+        VP,                  4      Vn        VP0                  P3                  V4       K  	  VP0                   Uu/ uF  qP                  VP                   bK  	  p	pV EF  p
V
P4                  P7                  4        UUu/ uF  w  rW9   g   K  WbK  	  pppR
V
P8                  9  dP   V
P:                  '       g   \=        RV R24      h\?        V
P8                  4      p\A        V
P:                  4      VR
&   MV
P8                  pV
PB                  p\E        4       pVP7                  4        UUu/ uF0  w  ppVV,          P                  VV,          PG                  V4      bK2  	  uppVn$        VPK                  VRVR7      pVR9   d   VPH                  V	8X  d	   VVn&        MVP%                  VRVRR7      Vn&        Ve#   \A        V4      pVPO                  WR7      Vn(        VPR                  P3                  V4       EK  	  RV 9  g   Q hW0R&   V# u upi u uppi u uppi )z
Add 'fvar' table to font.

axes is an ordered dictionary of DesignspaceAxis objects.

instances is list of dictionary objects with 'location', 'stylename',
and possibly 'postscriptfontname' entries.
zGenerating fvarfvarnamec              3   s>   "   T F  qP                   ^8H  x  K  	  R# 5i   N)Z
platformID).0Znr   & r/   	<genexpr>Z_add_fvar.<locals>.<genexpr>^   s     P0O"==A%0Os   ZnamesTFi   )	minNameIDmacenzInstance at location 'z' must have a default English style name ('stylename' attribute on the instance element or a stylename element with an 'xml:lang="en"' attribute).)windowsr:   )r<   r:   r9   )	platforms ))i   r5   i	  ))r5       r?   >   r*   i   )*
isinstancer"   loginfor   anygetattrvaluesr	   r   tagaxisTagminimumdefaultmaximumZminValuedefaultValueZmaxValueZaddMultilingualName
labelNames
axisNameIDintZhiddenflagsaxesappendlocationitemslocalisedStyleName	styleNamer)   dictr   ZpostScriptFontNamer
   map_backwardcoordinatesZfindMultilingualNamesubfamilyNameIDZaddNameZpostscriptNameIDr+   )fontrP   r+   r2   Z	nameTableZmacNamesr=   aaxisZdefault_coordinatesZinstancer3   valuerX   rT   ZpsnameZinstkvrY   s   &&&                 r/   	_add_fvarr`   J   s    K4dK((((HHFDVI sP	7B0OPsssP	7B0OPPH !I 9,	[[]v155z IIIIII 	8t($-
 $77LL$#8 8 
 ]
		  HLyyQyt<<):)::yQ ,4+<+<+B+B+D
+DKDKDK+D 	 
 x222%%%+,[M :N N 
 "&h&A&A!B',X-?-?'@t$!)!<!<,,=H=N=N=P
=PTQDGKKa--a00=P
 $88( 9 
 g%$*:*:>Q*Q $3D #,#@#@"Dh# $A $D  6]F$-$5$5f$5$RD!d#S V LKa R
&
s   ?M
MM06Mc                sz  aa V'       g   Q h\        V\        4      '       g   Q h\        P                  R4       \	        R4      pRp/ pVP                  4        EF  oRRRRRR/;qtP                  SP                  &   SP                  SP                  SP                  3p\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      p	WSP                  &   SP                  '       g   K  \        SP                  4      p
V
 Uu. uF  q^ ,          NK  	  ppV
 Uu. uF  q^,          NK  	  ppSP                  \        V4      8w  d'   \        RSP                    RSP                   R	24      hSP                  \#        V4      8w  d'   \        RSP                    R
SP                   R24      hSP                  V9  d'   \        RSP                    RSP                   R24      h\%        \'        V4      4      \%        V4      8w  d   \        RSP                    R24      h\        V4      V8w  d   \        RSP                    R24      hV Uu. uF  p\(        P*                  ! W4      NK  	  ppV Uu. uF  p\(        P*                  ! W4      NK  	  pp\,        ;QJ d%    R \/        W4       4       F  '       d   K   RM	  RM! R \/        W4       4       4      '       d   EK  RpVP1                  \/        W4      4       RV9   d   VR,          R8X  g   Q hRV9  g   VR,          R8X  g   Q hRV9  d   EK  VR,          R8X  d   EK  Q h	  V'       Ed   RpV UUUu. uFp  pVP2                  P5                  4        UUu/ uFF  w  ppVV,          P                  \(        P*                  ! WVV,          P                  ,          4      bKH  	  uppNKr  	  ppppV UUUu. uFp  pVP6                  P5                  4        UUu/ uFF  w  ppVV,          P                  \(        P*                  ! WVV,          P                  ,          4      bKH  	  uppNKr  	  pppp\%        V4      \%        V4      8X  g   Q h\8        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       g%   VP;                  ^ / 4       VP;                  ^ / 4       \(        P<                  ! VV4      p\>        P@                  ! V4      pVPC                  V4       / oV F  p. p\/        VV4       F[  w  ppVV9  d   VPE                  ^ 4       K   VV,          VPG                  V^ 4      ,
          pVPE                  \I        V^4      4       K]  	  VPK                  V4      ^,          SV&   K  	  VPM                  4       pVPO                  4       pSP5                  4        UUu/ uF  w  ppVVV,          bK  	  uppo\P        PR                  ! V3R lV 4       4      p^Vn*        \V        PX                  ! 4       Vn-        VVPZ                  n.        VVPZ                  n/        RV 9  g   Q hV'       g   \        P                  R4       RpV# W@R&   V# u upi u upi u upi u upi u uppi u upppi u uppi u upppi u uppi )zU
Add 'avar' table to font.

axes is an ordered dictionary of AxisDescriptor objects.
zGenerating avaravarF      ?g        c              3   sF   <"   T F  pSP                  V4      x  K  	  R # 5iN)map_forward)r6   r_   r\      & r/   r8   _add_avar.<locals>.<genexpr>   s     EAD,,Q//s   !zAxis 'z6': there must be a mapping for the axis minimum value z/ and it must be the lowest input mapping value.z6': there must be a mapping for the axis maximum value z0 and it must be the highest input mapping value.z6': there must be a mapping for the axis default value Z.zO': All axis mapping input='...' values must be unique, but we found duplicates.z4': mapping output values must be in ascending order.c              3   s.   "   T F  w  rW8H  x  K  	  R # 5irc   r>   r6   r^   r_      &  r/   r8   rf      s     2/$!qv/s   Tc              3   s   "   T FU  p\         ;QJ d*    R  VP                  4        4       F  '       d   K   RM	  RM! R  VP                  4        4       4      x  KW  	  R# 5i)c              3   s0   "   T F  w  rV^ 8H  x  K  	  R# 5ir?   Nr>   rg   rh   r/   r8   Z&_add_avar.<locals>.<genexpr>.<genexpr>  s     6+$!qAv+s   FTN)allrS   )r6   locr7   r/   r8   rf     s:     Q.3336#))+63336#))+666.s   AA+Ac              3   s6   <"   T F  pSV,          x  K  	  R # 5irc   r>   )r6   tvarIdxesre   r/   r8   rf   "  s     1Px!(1++xs   zNo need for avarN      )0r@   r"   rA   rB   r   rE   ZsegmentsrF   rH   rI   rJ   ZtupleZmapsortedminr)   r3   maxlenZsetr   ZnormalizeValuerj   zipupdateZinputLocationrS   ZoutputLocationrC   ZinsertVariationModelr   OnlineVarStoreBuildersetModelrQ   getfl2fistoreMastersfinishoptimizer   buildDeltaSetIndexMapZmajorVersionotra   tableZ	VarIdxMapVarStore)rZ   rP   ZmappingsaxisTagsra   ZinterestingZvals_triplesZcurveZkeys_tripleZvals_triplerS   ZitemkeysZvalsr_   mappingr3   ZinputLocationsZoutputLocationsmodelstoreBuilderrF   ZmasterValuesZvoZvistoreZ	optimizedr\   r]   Z	varIdxMaprm   s   &&&&                       `  @r/   	_add_avarr      s    K4dK((((HHFDKL ,0sCc*JJdhh'||T\\4<<@eEEeeEEE!,TXXxxxtxx $)*EDQE*$)*EDQE*
 <<3t9$' $&UW  <<3t9$' $&VX  <<t#' $a) 
 s4y>SY&' $3 3 
 $<4'#WX  @DDt!%%a5tD?CDt!%%a5tD32#d/23332#d/222S_%e|c
c 1115 E$K4$7775 E$K4$777} B x $

 $  '44::<<GD! T
 5 5ad4jnn9U VV< $ 	 
 $

 $  '55;;==GD! T
 5 5ad4jnn9U VV= $ 	 
 >"c/&:::: sQ.QsssQ.QQQ!!!R(""1b)%%nh?55h?e$CLo~>Bb= ''*sGbffS!n,##E!RL1 ? )55lCAFHSM  ##%NN$	>Fnn>NO>N{tUD)E**>NO111Px1PP	WWY
(

#

#$ K VKO +*@ ED"

< PsP   Z	$ZZ;Z%"Z#AZZ#%"Z0AZ*Z0Z7Z#*Z0c                 s    R V 9   d   R# ^RI Hp V R,          pVP                   Uu. uF$  p\        VP                  VP
                  R7      NK&  	  ppV! W4       R# u upi )STATN)buildStatTabler2   )rF   r3   )ZotlLib.builderr   rP   rV   rG   rM   )rZ   r   Z	fvarTabler[   rP   s   &    r/   	_add_statr   3  sO    
 ~/VI<ENNKNqDQYYQ\\2NDK4 Ls   *A_MasterDataTc                 s   V^ 8  d   \        R4      h\        P                  R4       RV 9  g   Q h\        R4      ;qPR&   V R,          pVP                  ^ ,          pV Uu. uFB  p\        VR,          VR,          P                  \        VP                  R4      RR4      4      NKD  	  p	pV P                  4        EF  p
\        P                  R	V
4       V	 Uu. uF3  pVP                  P                  WP                  VP                  4      NK5  	  ppW,          ^,          P                  ^ 8w  d0   V Uu. uF#  pVe   V^,          P                  ^ 8w  d   TMRNK%  	  ppVP!                  V4      w  rV Uu. uF  q^ ,          NK  	  ppV Uu. uF  q^,          NK  	  ppV^ ,          p\"        P$                  ! V4      '       g    \        P'                  R
V
,          4       EK+  ?. VP(                  V
&   VP+                  V\-        \.        P0                  \2        R7      R7      pVP4                  p\7        V4      \7        V4      8X  g   Q hV^ ,          pVP8                  p\;        \=        VR,          VR,          4      4       EF2  w  pw  pp\>        ;QJ d&    R VP@                   4       F  '       d   K   RM	  RM! R VP@                   4       4      '       d   KZ  \C        VV4      pV'       d   \E        VVVVR7      pRV9   d   \C        VV4      p\G        VPI                  4       4      pVPK                  V4      w  pp\7        V4      \7        V4      ,           pVPK                  V4      w  pp\7        V4      \7        V4      ,           pVV8  d   TpVP(                  V
,          PM                  V4       EK5  	  EK  	  R# u upi u upi u upi u upi u upi )r?   z&`tolerance` must be a positive number.zGenerating gvargvarglyfhmtxvmtxmetricsNzbuilding gvar for glyph '%s'z+glyph %s has incompatible masters; skippingroundr5   NNc              3   *   "   T F	  q^ 8H  x  K  	  R# 5iri   r>   r6   r_   r7   r/   r8   Z_add_gvar.<locals>.<genexpr>}  s     /;a6;   FT)	tolerance)'
ValueErrorrA   rB   r   reverseMappingr   r   rD   rx   getGlyphOrderdebugr   Z_getCoordinatesAndControlshMetricsvMetricsZnumberOfContoursgetSubModelr   allEqualwarning
variationsZ	getDeltasr!   r   Z	__round__r   supportsrr   endPts	enumeraters   rj   Zarrayr   r   ro   r   compilerQ   ) rZ   masterModelmaster_ttfsr   r|   r   r   ZdefaultMasterIndexmZmaster_datasglyphZallDataZdr   Z	allCoordsZallControlsZcontroldeltasr   Z
origCoordsr   ideltasupportvarZ	delta_optZvar_opt	axis_tagsZ	tupleDataZauxDataZunoptimized_lenZoptimized_lens    &&&&&                           r/   	_add_gvarr   E  sf   1}ABBHH"6**D<<D$33A6 	 A 	fIqy(('!%%-D*Q	
 	   ##%		0%8 "
! FF--eZZL! 	 

 &q)::a?
 ! A ]qt'<'<'AtK   
 %009#*+7aqTT7	+%,-WttW-a.{++KKEMN "$W%5%?%?uM ! 
 >>6{c(m+++ AY
#,SXb\-J#KAws/5;;/sss/5;;/// %0C.:v	 9$,Wi@G &!I *-Y)?&Iw&))ns7|&CO)0)C&Iw$'	NS\$AM$6%OOE"))#.1 $LM &
 ,-s    AO9O5)O7OOc                 s    R F  pW9   g   K  W K  	  V R,          pR F  p\        W#^ 4       K  	  ^Vn        V R,          P                  4        R# )cvarmaxpr   N)r   cvt fpgmprep)ZmaxTwilightPointsZ
maxStorageZmaxFunctionDefsZmaxInstructionDefsZmaxStackElementsZmaxSizeOfInstructions)setattrZmaxZonesZremoveHinting)rZ   rF   r   Zattrs   &   r/   _remove_TTHintingr     sR    /;	 0 <D 	A DML r1   c           	      s  a \         P                  R 4       RV 9  g   Q hR F  pV Uu. uF  qCV9   g   K  WC,          P                  NK  	  ppV'       g   K6  \        V P	                  V4      RR4      o\
        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       g   K  \         P                  RV,          4       \        V 4        R# 	  V R,          pV Uu. uF  qDR,          NK  	  ppVP                  P                  4        F  w  rV U
u. uF  p
\        V
P	                  V4      RR4      NK!  	  pp
\        V4      '       g   KC  V	P                  V4       \        V	RR4      o\
        ;QJ d    V3R	 lV 4       F  '       g   K   RM	  RM! V3R	 lV 4       4      '       g   K  \         P                  R
V,          4       \        V 4        R# 	  V Uu. uF(  pRV9   d   \        VR,          P                  4      MRNK*  	  pp\        P                  ! V4      pV'       g   R# \        P                  ! R V 4       4      '       g#   \         P                  R4       \        V 4       R# . pVP!                  V\"        R7      w  r\%        \'        VR,          VR,          4      4       Fb  w  pw  pp\(        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   KE  \+        VV4      pVP-                  V4       Kd  	  V'       d!   \/        R4      ;pV R&   ^Vn        VVn        R# R# u upi u upi u up
i u upi )zMerging TT hintingr   programNc              3   s,   <"   T F	  qS8g  x  K  	  R # 5irc   r>   r6   Zpgmfont_pgmre   r/   r8   #_merge_TTHinting.<locals>.<genexpr>  s     3(3h(   TFz:Masters have incompatible %s tables, hinting is discarded.r   c              3   s@   <"   T F  q'       g   K  VS8g  x  K  	  R # 5irc   r>   r   re   r/   r8   r     s     :(3csh(s   	zMMasters have incompatible glyph programs in glyph '%s', hinting is discarded.r   c              3   s8   "   T F  p\        V4      x  K  	  R # 5irc   )rr   )r6   Zcr7   r/   r8   r     s     7;a3q66;s   z;Masters have incompatible cvt tables, hinting is discarded.r   r   c              3   r   ri   r>   r   r7   r/   r8   r     s     %u!Avur   )r   r   )rA   rB   r   rD   rx   rC   r   r   glyphsrS   Zexpandr   rE   r   ZnonNoner   getDeltasAndSupportsr   r   rs   rj   r   rQ   r   versionr   )rZ   r   r   rF   r   Zall_pgmsZ	font_glyfmaster_glyfsr3   r   r   Zall_cvsZnonNone_cvsr   r   r   r   r   r   r   r   r   s   &&&                  @r/   _merge_TTHintingr     s   HH!"  ,7DKq!8NAFNNKD488C=)T:33(33333(333KKLsR d#   VI'23{!fII{L3 ''--/IUVGDHHTNIt<V8}}Y5)T23:(:333:(:::KK_
 d# 0" KVV+Q6Q;vai&&'D@+GV..)K??7;777QR$J"77u 8 F  )VBZ")FGE73%u%333%u%%%We,#	  H &v..tF|$ o E 4V  Ws   MM/M%%M/.M!c                $    V ^8  d   QhR\         /# )r*   return)Zboolr,   r.   r/   r0   r0     s      	r1   c                 s4   V P                  V4      pVe   VP                  4       '       dm   \        VP                  4      V8X  dS   V FL  w  rVVP                  V,          pVP                  V8w  d    R# VP
                  \        ,          '       d   KK   R# 	  R# )NTF)rx   isCompositerr   
components	glyphNamerO   r   )master_glyf
glyph_nameflagged_componentsexpected_num_componentsZmaster_glyphr   Z
base_glyphcomps   &&&&    r/   %_has_inconsistent_use_my_metrics_flagr     s     ??:.L 	 $$&&''(,CC/MA**1-D~~+  JJ// 0 r1   c           	     s  aaa V R,          pV Uu. uF  pRV9   g   K  VR,          NK  	  ppV'       g   R# VP                  4        EFo  oVS,          pVP                  4       '       g   K%  \        VP                  4       UUu. uF1  w  rgVP                  \
        ,          '       g   K$  WgP                  3NK3  	  uppoS'       g   K  \        VP                  4      o\        ;QJ d!    VVV3R lV 4       F  '       g   K   RM	  RM! VVV3R lV 4       4      '       g   K  S UU	u. uF  w  rV	NK	  	  p
pp	\        P                  RS\        V
4      ^8  d   RMR\        V
4      ^8  d   T
MV
^ ,          4       S F4  w  rhVP                  V,          ;P                  \
        ( ,          un        K6  	  EKr  	  R# u upi u uppi u up	pi )	a2  Clear USE_MY_METRICS on composite components if inconsistent across masters.

If a composite glyph's component has USE_MY_METRICS set differently among
the masters, the flag is removed from the variable font's glyf table so that
advance widths are not determined by that single component's phantom points.
r   Nc              3   s@   <"   T F  p\        VSSS4      x  K  	  R # 5irc   )r   )r6   r   r   r   r   s   & r/   r8   Z;_unset_inconsistent_use_my_metrics_flags.<locals>.<genexpr>%  s1      
  , 2Z);=T   ,s   TFznComposite glyph '%s' has inconsistent USE_MY_METRICS flags across masters; clearing the flag on component%s %ss )r   r   r   r   rO   r   r   rr   rC   rA   rB   )vfmaster_fontsr   r   r   r   r   r   Z_r3   Z
comp_namesr   r   r   s   &&         @@@r/   (_unset_inconsistent_use_my_metrics_flagsr     s    f:D'3C|!v{IAfII|LCiik
Z   "" %U%5%56
6

^++  Q6

 "
 #&e&6&6"73 
  ,	
333 
  ,	
 
 
 /AA.@71$.@JAHH?:*!*o1
z!} +  #))n_<) +E " D
& Bs   	F>F>!G+G*G	_MetricsFieldsHVARr   ZLsbMapZRsbMapZAdvWidthMap)tableTag
metricsTagsb1sb2
advMappingvOrigMappingZphantomIndexVVARr   ZTsbMapZBsbMapZAdvHeightMapZVOrgMapc                 T    \        \        WW#\        4      p\        W\        V4       R # rc   )r!   _get_advance_metricsHVAR_FIELDS
_add_VHVARrZ   r   r   r   getAdvanceMetrics   &&&& r/   	_add_HVARr   Y  %    d t{,=>r1   c                 r   rc   )r!   r   VVAR_FIELDSr   r   r   r/   	_add_VVARr   `  r   r1   c                 s   VP                   pW@9  g   Q hV P                  4       p\        P                  R V,           4       \	        V4      p\        \        V4      pV! 4       ;qn        RVn        V! 4       w  rV
'       d   RpM+\        P                  ! R V	P                  4        4       4      pRpV'       d   \        \        V	P                  4       4      4      ^,          R,          p\        P                  ! W4      p\!        \#        \%        V4      4      4      p\        P&                  ! V. RR7      pV F(  pVP)                  V	V,          ^ ,          \*        R7       K*  	  VP-                  4        \        P.                  ! VV.4      pVP1                  4        \2        P4                  ! V4      p/ pV F:  pV	V,          w  ppVP7                  V4       VP9                  V\*        R7      VV&   K<  	  V
'       dC   / pV F:  pV
V,          w  ppVP7                  V4       VP9                  V\*        R7      VV&   K<  	  VP;                  4       pVP-                  RR7      pV Uu. uF  pVVV,          ,          NK  	  pp\        P<                  ! VV4      pV
'       d    V Uu. uF  pVXV,          ,          NK  	  ppRpRpV'       d   \?        4       pVPA                  VV 4       \%        VPC                  4       4      p\?        4       pVPA                  VV 4       VPA                  VV 4       \%        VPC                  4       4      pVV8  pV'       d   TpRpM!TpV
'       d   \        P<                  ! XV4      pVVn"        \G        WPH                  V4       Ve   \G        WPJ                  V4       \G        WPL                  R4       \G        WPN                  R4       W`V&   R# u upi u upi )	zGenerating    Fc              3   sF   "   T F  p\        V^,          4      x  K  	  R# 5ir4   )idr   r7   r/   r8   Z_add_VHVAR.<locals>.<genexpr>v  s      &
ABqtHHAs   !Nr   r|   r   )Zuse_NO_VARIATION_INDEX)(r   r   rA   rB   r   rD   r~   r   Versionr   r   rE   ZnextZiterr   ZbuildVarRegionListlistZrangerr   ZbuildVarDataZaddItemr   r|   ZbuildVarStoreZprune_regionsr   rv   ZsetSupportsZstoreDeltasr{   ZbuildVarIdxMapr   r   Z
getAllDatar   r   r   r   r   r   ) rZ   r   tableFieldsr   r   
glyphOrderZVHVARZ
tableClassZvhvarvhAdvanceDeltasAndSupportsvOrigDeltasAndSupportsZsingleModelZdirectStorer   ZvarTupleListZvarTupleIndexesZvarDatar   r   r   r   ZvOrigMapZindirectStoreZmapping2ZgZadvanceMappingZ	useDirectr   ZwriterZ
directSizeZindirectSizeZmetricsStores    &&&&                            r/   r   r   g  sk   ##H##%JHH]X%&XEX&J$,&EKEM9J9L6oo &
8??A&
 
 K7>>@AB1EbI11(EuS]34&&UK#IOO6yA!DGOT $++L7)D!!# 11(;LJ	5i@  * , 8 8w 8 O
9  
 #I5i@FH$$X.".":":6":"QHY $
 !'')M%%U%CH3=>:a(:a=)):J>++J
CN3=>:aHXa[)):>IL FD)**,-
fd+vt,6,,./-	"$!"11(JGL!ENE))>://>E??D)E??D)N
M ? ?s   #O !O%c                 s   VP                   pV P                  4       pVP                  pV Uu. uF  qV,          P                  NK  	  p	pVR 8X  df   RV^ ,          9   dX   V Uu. uF  qR,          P                  NK  	  p
pV Uu. uF  qR,          P
                  NK  	  pp\        \        W4      4      p
MRp
/ p/ pRpV FY  pV	 Uu. uF1  pVV9   d&   VV,          ^ ,          V8w  d   VV,          ^ ,          MRNK3  	  ppVP                  V\        R7      W&   K[  	  V
'       dI   V FB  pV
 UUu. uF  w  ppVV9   d
   VV,          MTNK  	  pppVP                  V\        R7      W&   KD  	  W3# u upi u upi u upi u upi u uppi )r   ZVORGNi  r   )
r   r   r   r   ZVOriginRecordsZdefaultVertOriginYr   rs   r   r   )rZ   r   r   r   r   r   r   r   r   ZadvMetricsesZvOrigMetricsesZdefaultYOrigsr   r   Zsparse_advancer   r   Z
vhAdvancesZdefaultVOrigZvOrigss   &&&&&               r/   r   r     s   ##H##%J ''J3>?;ajM));L? 6fA6<GHKqF)22KH?JK{!655{Kc.@A!#
 N (
 ( G#q(9^(K q! ( 	 
 -8,L,Le -M -
")  E .<-;)G\ #(7"2D-;   -8,L,Le -M -")   &==W @ IK
"s   E0#E5E:7E?/Fc                 s
   \         P                  R 4       \        P                  ! V4      p. pRpRpRpRR
RR
/p	\	        \
        P                  ! 4       R R7       EF_  w  p
w  rW8w  d   R;rW9   d   W,          p. pV FV  pW9  g$   W9   d1   \        W,          V4      W,          8X  d   VP                  R4       K?  VP                  W,          4       KX  	  VP                  V4      w  rVP                  V4       TpVf   K  V Uu. uF  p\        W4      NK  	  pp\        P                  ! V4      '       d   V^ ,          RppMVP                  V4      w  pp\        W|V4       Vf   EK  \         P                  RWVV4       \        P                   ! 4       pV
Vn        VVn        VP                  V4       EKb  	  RV 9  g   Q hV'       d   VP'                  4       pVP)                  4       pV F  pVVP$                  ,          Vn        K  	  \+        R4      ;pV R&   \        P,                  ! 4       ;pVn        RVn        ^ Vn        VVn        ^Vn        \9        V4      Vn        \	        VR	 R7      Vn        R# R# u upi )zGenerating MVARNZundsZundoc                 s    V ^,          # )r5   r>   )Zkv   &r/   <lambda>_add_MVAR.<locals>.<lambda>  s    QSTUQVr1   )Zkeyz	%s: %s.%s	%sMVARr   c                 s    V P                   # rc   )ValueTag)Zrr   r/   r   r   A  s    r1   i )rA   rB   r   rv   ro   r   rS   rD   rQ   r   rw   r   r   rz   r   r~   ZMetricsValueRecordr   ZVarIdxr{   r|   r   r   r   r   ZReservedr   ZValueRecordSizerr   ZValueRecordCountZValueRecord)rZ   r   r   r   store_builderZrecordsZlastTableTagZ	fontTableZtablesZspecialTagsrF   r   ZitemNamemasterr   r   Zmaster_valuesbaseZvarIdxZrecr   r   r   Zmvars   &&&&                    r/   	_add_MVARr     sQ   HH228<MGLIF 7FG4K%+L,>,>,@FV%W%W!!h #!%%F N	)F-*#F$4h?;CSSd+f&67 * !, 7 7 ?&&u-#L> @FFve1vF??=))(+T&D&(55mDLD&	T*>#=I##%
sO &XR $$&.."C ,CJ  'v..tF|GGI%tz!  #G!'/CD ! Gs   	J c                 s   \         P                  R 4       \        WV 4      pVP                  WR.4       VP                  P                  4       pV'       g   R# V R,          P                  pVP                  R8X  g   Q hRVn        WVn        R# )zGenerating BASEBASENr   i  )	rA   rB   r   mergeTablesr   r{   r   r   r   )rZ   r   r   r   mergerr   r   s   &&&&   r/   	_add_BASEr   D  st    HH[D9F
t6(3  '')E<D<<:%%%DLMr1   c                 s  a  . R
Op\         ;QJ d    V 3R lV 4       F  '       g   K   RM	  RM! V 3R lV 4       4      '       g   R# \        P                  R4       \        WS 4      pVP	                  S W$4       VP
                  P                  4       pV'       g   R#  S R,          P                  pVP                  R8:  g   Q h R	Vn        Wgn        VP'                  4       p	VP)                  V	4       RS 9   d%   S R,          P                  P)                  V	4       R# R#   \         d`    \        R4      S R&   \        R4      ;pS R&   \        P                  ! 4       ;qxn        RTn        RTn        RTn        RTn        RTn         Li ; i)GSUBGDEFGPOSc              3   s,   <"   T F	  qS9   x  K  	  R # 5irc   r>   )r6   rF   rZ   re   r/   r8   Z_merge_OTL.<locals>.<genexpr>U  s     /hsd{hr   TFNzMerging OpenType Layout tablesi  i  )r   r   r   )rC   rA   rB   r   r   r   r{   r   r   ZKeyErrorr   r~   r   ZGlyphClassDefZ
AttachListZLigCaretListZMarkAttachClassDefZMarkGlyphSetsDefr   r|   Zremap_device_varidxes)
rZ   r   r   r   Zotl_tagsr   r   r   Z	GDEFTableZ
varidx_maps
   f&&&      r/   
_merge_OTLr   S  sL   'H3/h/333/h///HH-.Ud3F
t\4  '')E%F|!!||z))) DLM !Jz*~V00< !  %'V#+F#33	DL!#*! "& $%s    &D" "A'FFc                 sL  a V3R  lp\         P                  R4       VP                  4        UUu/ uF  w  rgWgP                  bK  	  ppp. p	V F  p
. pV
P                   Fq  p/ pV FU  pVR,          pVR,          e   V! WR,          4      pMRpVR,          e   V! WR,          4      pMRpW,          pVV3VV&   KW  	  VP                  V4       Ks  	  V
P                   UUu/ uF	  w  ppVVbK  	  pppV	P                  VV34       K  	  \        W	V4       R# u uppi u uppi )c                 sB   < \         P                  ! W/S4      V ,          # rc   )r   normalizeLocation)r3   r]   internal_axis_supportss   &&r/   	normalizeZ/_add_GSUB_feature_variations.<locals>.normalizey  s    ''7MNtTTr1   z!Generating GSUB FeatureVariationsr3   rH   Nrb   rJ   rn   )rA   rB   rS   rF   ZconditionSetsrQ   subsr   )rZ   rP   r  rulesfeatureTagsr  r3   r\   r   Zconditional_subsZruleZregionZ
conditionsZspaceZ	condition	axis_namerH   rJ   rF   r^   r_   r  s   &&f&&                 r/   _add_GSUB_feature_variationsr  v  s%   U HH0126**,?,JDxx,I?,,JE'	%f-	Y'3'	Y3GHG"GY'3'	Y3GHG!G*%w/c
 ( MM%  -  "&+A1+/) , =3 @* ,s   D#D _DesignSpaceDatac                 s    ^RI Hp V P                  4       pRV 9  d   ^ RIHp V! V 4       VP                  W!P                  4      pV! WWd4       R# )r5   )merge_region_fontsCFF2)convertCFFToCFF2N)Zcffr	  r   ZfontTools.cffLib.CFFToCFF2r  ZreorderMastersr   )ZvarFontr   r   r	  r   r  Zordered_fonts_lists   &&&    r/   	_add_CFF2r    sH    '&&(JW?!--l<P<PQw'9Fr1   c                 s^   \        WWR 7      pVP                  W4       VP                  P                  4       pV R,          P                  pV'       dU   VP                  4       pWgn        VP                   U	u. uF  qV	,          NK  	  p
p	\        P                  ! V
4      Vn
        R# R# u up	i ))ZallowLayerReuseCOLRN)r   r   r   r{   r   r|   r   rm   r   r}   ZVarIndexMap)rZ   r   r   r   colr_layer_reuser   r   Zcolrr   r_   rm   s   &&&&&      r/   	_add_COLRr    s     F t*  '')E<D.."(.81AJJ8"88B	  9s   8B*require_sourcesc                s    \        V R 4      '       d   T pM\        P                  ! V 4      pVP                  pV'       d   V'       g   \	        R4      hVP
                  p\        RRRR/33RRRR/33R	R
RR/33RRRR/33RRRR/33.4      pVP                  '       g   \	        R4      h\        4       p\        VP                  4       F  w  rV	P                  p
V
'       g4   V	P                  '       g   \	        RV R24      hV	P                  ;qn	        W9   d^   V	P                  f   Wj,          ^ ,          V	n
        V	P                  '       g)   V	P                  P                  Wj,          ^,          4       MKV	P                  '       g   \	        RV R24      hV	P                  '       g   \        V
4      V	P                  R&   WV
&   EK  	  V'       dK   \        P                  R\!        VP#                  4        U	u. uF  qP%                  4       NK  	  up	4      4       VP&                  pV'       d(   V'       d    \        P                  R\!        V4      4       WE,            EF  pVP                  ;'       g    VP(                  ;'       g    RpVP+                  V4      pWn        Vf   \	        RV R24      hVP/                  4        F  p
W9  g   K  \	        RV
 RV R24      h	  VP1                  4        Fp  w  rV	P3                  W,          4      pV	P4                  Tu;8:  d   V	P6                  8:  d   KA  M \	        RV RV
 RV R V	P4                   R!V	P6                   R"24      h	  EK  	  V Uu. uF  pVP+                  V4      NK  	  ppV'       d    \        P                  R#\!        V4      4       / pVP#                  4        FS  p	V	P4                  V	P8                  V	P6                  3pV Uu. uF  qP;                  V4      NK  	  upVV	P                  &   KU  	  V'       d    \        P                  R$\!        V4      4       V Uu. uF  p\<        P>                  ! VV4      NK  	  ppV'       d    \        P                  R%\!        V4      4       Rp\        V4       Fo  w  pp\@        ;QJ d*    R& VP#                  4        4       F  '       d   K   R'M	  R(M! R& VP#                  4        4       4      '       g   K^  Ve   \	        R)4      hTpKq  	  V'       d   Vf   \	        R*4      hV'       d   \        P                  R+V4       \C        VVVVVVVVPD                  VPF                  VPH                  4
      # u up	i u upi u upi u upi ),sourcesz*Designspace must have at least one source.Zweightwghtr;   ZWeightZwidthwdthZWidthZslantslntZSlantZopticalZopszzOptical SizeZitalicZitalZItalicz(Designspace must have at least one axis.zAxis at index z needs a tag.NzAxes:
%szMappings:
%sr   zSource or instance 'z' has no location.zLocation axis 'z' unknown for 'z'.z&' has out-of-range location for axis 'z': is mapped to z but must be in mapped range [z..z'] (NOTE: all values are in user-space).zInternal master locations:
%szInternal axis supports:
%szNormalized master locations:
%sc              3   r   ri   r>   r   r7   r/   r8   Z#load_designspace.<locals>.<genexpr>/  s     *z!Avzr   FTz/More than one base master found in Designspace.z5Base master not found; no master at default location?zIndex of base master: %s)%hasattrr   fromfiler  r)   r+   r"   rP   r   r3   rF   rL   rt   r   rA   rB   r&   rE   ZasdictaxisMappingsrU   ZgetFullDesignLocationZdesignLocationr   rS   rW   rH   rJ   rI   rd   r   r   rj   r  r  rulesProcessingLastlib)designspacelog_enabledr  dsmastersr+   Zstandard_axis_maprP   Z
axis_indexr\   r  r  ZobjZobj_namerk   r_   ZoZinternal_master_locsr  Ztripler   normalized_master_locsbase_idxr   s   &&$                     r/   load_designspacer     s    {I&& ))+6jjGw#$PQQI $x 012vg/0vg/0$!789x 012	
 777#&NPP=D%bgg.
II	888+nZL,VWW$(HH,I	)xx,7:???&&'8'CA'FG888+nZL,VWW???(-i(8%Y% /& g&O{{}&OPQ??L',"78 ""8822s}}22''+ ;'&xj0BC  I$+%i[zL  $
  $zz|OI!!#.1ALLA555+*8* 5!!*+;A3 ?%%)\\N"T\\N C11   , #2 BIIAA33B7I17;O3PQ  ,,dll;JP,Q&Q-=-=a-@&,Qtyy)  .8N0OP &%A 	  $:;%   3W=S5TU H0113*qxxz*333*qxxz***#+E  H 2 8+#C
 	
 +X6


 G 'P@ J -Rs   ;U<5V4V Vg     @O@g     U@g      \@c           	      s   R V 9   d   RV9   db   \        \        ^\        VR,          R4      4      4      pV R ,          P                  V8w  d$   \        P                  RV4       W R ,          n        RV9   d}   \        \        VR,          ^24      ^4      p\        \        P                  ! V\        4      4      pV R ,          P                  V8w  d$   \        P                  RV4       W@R ,          n	        RV9   df   RV 9   d]   \        R
\        VR,          ^Z4      4      pV R,          P                  V8w  d&   \        P                  RV4       WPR,          n
        R	# R	# R	# R	# )zOS/2r  i  zSetting OS/2.usWeightClass = %sr  zSetting OS/2.usWidthClass = %sr  postzSetting post.italicAngle = %sNi)r   rq   rp   ZusWeightClassrA   rB   r   ZpiecewiseLinearMapWDTH_VALUE_TO_OS2_WIDTH_CLASSZusWidthClassitalicAngle)rZ   rR   Zweight_classZ
widthValueZ
widthClassr#     &&    r/   set_default_weight_width_slantr%  X  s   ~X"3q#hv.>*E#FGLF|))\9:LI-9V*XS&!126<J ))*6STJ F|((J69:F,6V)fn#s8F#3R89<##{2HH4kB'2L$ 3 -r1   c                s0    V ^8  d   QhR\         R\        /# )r*   r  r   )r   rN   r,   r.   r/   r0   r0   q  s     % %& %S %r1   c                 s   ^ p\        \        4      pV  Uu/ uF  p\        V4      VbK  	  upP                  4        F@  pVR,          pVP	                  4        F   pW&,          P                  WV,          4       K"  	  KB  	  ^ pVP                  4        F!  w  rg \        V!  pV\        V4      ,          pK#  	  V# u upi   \         d"   p	\        P                  RYi4        Rp	?	KS  Rp	?	ii ; i)a~  Drop impliable on-curve points from all the simple glyphs in masters.

In TrueType glyf outlines, on-curve points can be implied when they are located
exactly at the midpoint of the line connecting two consecutive off-curve points.

The input masters' glyf tables are assumed to contain same-named glyphs that are
interpolatable. Oncurve points are only dropped if they can be implied for all
the masters. The fonts are modified in-place.

Args:
    masters: The TTFont(s) to modify

Returns:
    The total number of points that were dropped if any.

Reference:
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM01/Chap1.html
r   z*Failed to drop implied oncurves for %r: %sN)r#   r   r   rE   r   rQ   rS   r   rr   r   rA   r   )
r  ZcountZglyph_mastersr   rZ   r   r   r   ZdroppedZes
   *         r/   drop_implied_oncurve_pointsr&  q  s    ( E%M $++7aA7+224F|I$++DO< % 5 E*002		".7G
 S\!E 3 L ,  	TKKDiSS	Ts   B9	B>>C*	C%%C*c                     V # rc   r>   r   r   r/   r   r         Ar1   c                 s    R # )Fr>   )vf_namer   r/   r   r     s    Er1   Fc                r   )r*   r  )r   r,   r.   r/   r0   r0     s     8 8$8r1   c                s
   / pRV9  ;'       dt    V P                   R8  ;'       d]    \        ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      ;'       g    V P                  p\	        V 4       Fq  w  r\        V
4       F]  w  rV! V4      '       d   \        P                  RV 24       K-  \        VVVVVVR7      ^ ,          pV'       d   \        WV4       WV&   K_  	  Ks  	  V# )aM  
Build variable fonts from a designspace file, version 5 which can define
several VFs, or version 4 which has implicitly one VF covering the whole doc.

If master_finder is set, it should be a callable that takes master
filename as found in designspace file and map it to master font
binary as to be opened (eg. .ttf or .otf).

skip_vf can be used to skip building some of the variable fonts defined in
the input designspace. It's a predicate that takes as argument the name
of the variable font and returns `bool`.

Always returns a Dict[str, TTFont] keyed by VariableFontDescriptor.name
r   c              3   sd   "   T F&  qP                   ;'       g    VP                  R Jx  K(  	  R # 5irc   )Z
axisLabelsZaxisOrdering)r6   r[   r7   r/   r8   Zbuild_many.<locals>.<genexpr>  s(     UDTq::d ::DTs   00TFzSkipping variable TTF font: excluder|   r  drop_implied_oncurves)i   r?   )
ZformatTuplerC   rP   ZlocationLabelsr   r   rA   r   buildr   )r  master_finderr,  r|   Zskip_vfr  r-  ZresZdoBuildStatFromDSv5Z	_locationZsubDocr3   ZvfDocr   s   &&&&&&&       r/   
build_manyr0    s   . C 	g 	
 	
##v-	
 	
 CUKDTDTUCCCUKDTDTUU * *))  /{;	-f5KDt}}		8?@!!1&; B # $7I 6 <  Jr1   c                 r'  rc   r>   r(  r   r/   r   r     r)  r1   c                s   \        V R4      '       d   M\        P                  ! V 4      p \        V 4      p\        P                  R4       \        P                  R4       \        W4      p. pV F3  p	 VP                  V	P                  P                  P                  4       K5  	  V'       d7   RWvP                  ,          9   d    \        V!  p
\        P                  RV
4       \        WvP                  ,          4      pRV9   d   VR RV9   d   \        W4       \!        WP"                  VP$                  4      pRV9  d   \'        V4       VP(                   UUUu. uFB  qP+                  4        UUu/ uF#  w  rVP"                  V,          P,                  VbK%  	  uppNKD  	  ppppVP"                   Uu. uF  pVP.                  NK  	  pp\0        P2                  ! VVR	7      p^ VP4                  VP                  ,          8X  g   Q h\        P                  R
4       RV9  d"   \7        WP"                  VP8                  V4       RV9  d   RV9   d   \;        VVVV4       RV9  d   \=        VVVV4       RV9  d   \?        VVVV4       RV9  d   RV9   d   \A        VVVV4       RV9  g   RV9  d   \C        VVVV4       RV9  d   RV9   d   \E        VVWsR7       RV9  d   RV9   d   \G        VVV4       RV9  dJ   VPH                  '       d8   \K        V4      p\M        WP"                  VPN                  VPH                  V4       RV9  dR   RV9   g   RV9   dD   \Q        VVV4       RV9   d0   VR,          pVPR                  R8w  d   RVn)        . Vn*        / Vn        RV9  d/   RV9   d(   VR,          PV                  ^ 8  d   \Y        VVVVV4       \[        YR,          P"                   Uu/ uF  pVP.                  VP\                  bK  	  upR7       V F  pVV9   g   K  VV K  	  VVV3#   \         d    TP                  R4        EK  i ; iu uppi u upppi u upi u upi )z
Build variation font from a designspace file.

If master_finder is set, it should be a callable that takes master
filename as found in designspace file and map it to master font
binary as to be opened (eg. .ttf or .otf).
r  zBuilding variable fontzLoading master fontsNr   zADropped %s on-curve points from simple glyphs in the 'glyf' tableZDSIGr   )Z	axisOrderzBuilding variations tablesra   r   r   r   r   r   r   r   r   r   r   r   r
  zCFF r!  g       @r  r2   )rR   )/r  r   r  r   rA   rB   load_mastersrQ   ZreaderZfiler3   ZAttributeErrorr  r&  r%   r   r`   rP   r+   r   r  rS   rF   rG   r   ru   r   r   r  r   r   r   r   r   r   r   r  _feature_variations_tagsr  r  r  Z
formatTypeZ
extraNamesr   r  r%  rK   )r  r/  r,  r|   r  r-  r  r   r   r   Z
drop_countr   r2   rk   r^   r_   r  r\   r   r   r  r!  rF   s   &&&&&&                 r/   r.  r.    s    {I&&)22;?	+	&BHH%&HH#$;L K	%v}}11667  <+D!D0,?
O	
 
,{{+	,B|vJ |0B R",,/DW" @B?X?X?Xyy{3{tq	{3?X   *.3H3 !!"8HMEbkk****HH)*W"ggr9W2"e\84W"e\84W"e\84W2"e\84Wg 52ulH5W2"e\=W2UL1W.r2$22BHHk	
 W&B,&B,"e\*R<f:D#%"%"$!W2"V*2D2Dq2H"e\85EF"
V*//R/$dllD$5$55/R "93 
 uk!!_  	%t$$	%6 	4 4R Ss6   2/P4Q3)QQ6Q%2 Q*
4QQQc                 r'  rc   r>   r(  r   r/   r   r   E  s    Qr1   c                 s   ^ RI Hp \        P                  P	                  V 4      pV! V4      pVf   V! V4      pV! V4      pVR9   d   \        4       pVP                  V4       V# VR9   d   \        V4      pV# \        RV,          4      h)r?   )guessFileTypezInvalid master path: %r)ZTTXZOTX)ZTTFZOTFZWOFFZWOFF2)ZfontTools.ttxr3  ospathnormpathr   Z	importXMLr)   )r5  r/  r3  Zmaster_pathZtprZ   r$  r/   
_open_fontr7  E  s     ,''""4(K	{	#B	z#K0;'	^x{#
 K	 
.	.k" K $$=$KLLr1   c                 r'  rc   r>   r(  r   r/   r   r   [  s    ar1   c                s    V P                    FH  pVP                  '       g   K  VP                  e   K'  \        RVP                  ;'       g    R R24      h	  V P                  \        VR7      # )a  Ensure that all SourceDescriptor.font attributes have an appropriate TTFont
object loaded, or else open TTFont objects from the SourceDescriptor.path
attributes.

The paths can point to either an OpenType font, a TTX file, or a UFO. In the
latter case, use the provided master_finder callable to map from UFO paths to
the respective master font binaries (e.g. .ttf, .otf or .ttx).

Return list of master TTFont objects in the same order they are listed in the
DesignSpaceDocument.
zDesignspace source 'z	<Unknown>zV' specified a layer name but lacks the required TTFont object in the 'font' attribute.)r/  )r  Z	layerNamerZ   r)   r3   ZloadSourceFontsr7  )r  r/  r   s   && r/   r1  r1  [  so     %%  3'&v{{'A'Ak&B C  	 & &&z&OOr1   c                   s,   a  ] tR tRt o R tR tRtV tR# )MasterFinderit  c                s    Wn         R # rc   template)selfr:  s   &&r/   __init__ZMasterFinder.__init__u  s     r1   c                sB   \         P                  P                  V4      p\         P                  P                  V4      w  r4\         P                  P	                  V4      w  rVV P
                  P                  VVVVVR 7      p\         P                  P                  V4      # ))fullnamedirnamebasenamestemext)r4  r5  ZabspathsplitZsplitextr:  r-   r6  )r;  Zsrc_pathr=  r>  r?  r@  rA  r5  s   &&      r/   __call__ZMasterFinder.__call__x  s~    77??8,GGMM(3GG$$X.	}}## $ 
 ww%%r1   r9  N)__name__Z
__module__Z__qualname__Z__firstlineno__r<  rC  Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r/   r8  r8  t  s     !& &r1   r8  c                 s    V P                   P                  \        V P                  '       d   R MR4      p\	        VP                  R4       Uu0 uF  q"P                  4       kK  	  up4      # u upi )ZrcltZrvrnZ,)r  rx   FEAVAR_FEATURETAG_LIB_KEYr  ro   rB  Zstrip)r  Zraw_tagsrl   rh   r/   r2  r2    sU    vvzz!(((fH hnnS&9:&9779&9:;;:s   A,r  c               s    \        WR7      pVP                  '       g   R# V'       g   \        V4      p\        WP                  VP
                  VP                  V4       R# )a  Add GSUB FeatureVariations table to variable font, based on DesignSpace rules.

Args:
    vf: A TTFont object representing the variable font.
    designspace: A DesignSpaceDocument object.
    featureTags: Optional feature tag(s) to use for the FeatureVariations records.
        If unset, the key 'com.github.fonttools.varLib.featureVarsFeatureTag' is
        looked up in the DS <lib> and used; otherwise the default is 'rclt' if
        the <rules processing="last"> attribute is set, else 'rvrn'.
        See <https://fonttools.readthedocs.io/en/latest/designspaceLib/xml.html#rules-element>
    log_enabled: If True, log info about DS axes and sources. Default is False, as
        the same info may have already been logged as part of varLib.build.
)r  N)r   r  r2  r  rP   r  )r   r  r  r  r  s   &&&$ r/   addGSUBFeatureVariationsrF    sF     
+	?B888.r2 
GGR..+r1   c           	     s   ^ RI Hp ^ RIHp V! R\        P
                  R7      pVP                  R4       VP                  4       pVP                  RRRR	R
R7       VP                  RRRR	RR7       VP                  RRRR. RR7       VP                  RRRRR7       VP                  RRRRR7       VP                  RR R!R"7       VP                  R#R$R%R&7       VP                  R'R(R)R*R+7       VP                  R,R-7      pVP                  R.R/R R0R"7       VP                  R1R2R R3R"7       VP                  V 4      pT! VP                  '       d   R4MVP                  '       d   R5MR6R77       VP                  p\        P                  ! V4      pVP                  4       p	V	'       g    VP                  R8VP                   : 24       . p
V	 F<  p\#        VP$                  VP&                  4      '       g   K+  V
P)                  V4       K>  	  V
'       g    VP                  R9VP$                  : 24       VP*                  e"   \-        V
4      ^8  d   VP                  R:4       VP.                  pVf    \0        P                   P3                  V4      p/ p\-        V
4      ^8X  d/   VP*                  e!   VP*                  W^ ,          P&                  &   MV
 Fy  pVP4                  e+   \0        P                   P7                  VP4                  4      pMVP&                  R;,           p\0        P                   P9                  W4      WP&                  &   K{  	  \;        VP<                  4      p\?        VVVP@                  VPB                  VPD                  VPF                  R<7      pVPI                  4        F  w  ppVPJ                  R=8X  d   R>MR?pVV,          PM                  VR@7      p\0        P                   P3                  V4      pV'       d   \0        PN                  ! VRARB7       \P        PS                  RCV4       VPU                  V4       K  	  R	# )Dz8Build variable fonts from a designspace file and masters)ArgumentParser)configLoggerZvarLib)ZprogZdescriptionr  z-oZ
OUTPUTFILEoutfileNzoutput file)metavardestrI   helpz-dz--output-dirZ	OUTPUTDIRz4output dir (default: same as input designspace file))rJ  rI   rL  z-xZTAGr,  rQ   zexclude table)rJ  rK  actionrI   rL  z--disable-iupr|   Zstore_falsezdo not perform IUP optimization)rK  rM  rL  z--no-colr-layer-reuser  z?do not rebuild variable COLR table to optimize COLR layer reusez--drop-implied-oncurvesZ
store_truez|drop on-curve points that can be implied when exactly in the middle of two off-curve points (only applies to TrueType fonts))rM  rL  z--master-finderz$master_ttf_interpolatable/{stem}.ttfa  templated string used for finding binary font files given the source file names defined in the designspace document. The following special strings are defined: {fullname} is the absolute source file name; {basename} is the file name without its directory; {stem} is the basename without the file extension; {ext} is the source file extension; {dirname} is the directory of the absolute file name. The default value is "%(default)s".)rI   rL  z--variable-fontsz.*ZVF_NAMEaw  Filter the list of variable fonts produced from the input Designspace v5 file. By default all listed variable fonts are generated. To generate a specific variable font (or variable fonts) that match a given "name" attribute, you can pass as argument the full name or a regular expression. E.g.: --variable-fonts "MyFontVF_WeightOnly"; or --variable-fonts "MyFontVFItalic_.*".)rI   rJ  rL  F)Zrequiredz-vz	--verbosezRun more verbosely.z-qz--quietzTurn verbosity off.ZDEBUGZERRORZINFO)Zlevelz'No variable fonts in given designspace zNo variable fonts matching zwcan't specify -o because there are multiple VFs to build; use --output-dir, or select a single VF with --variable-fontsz.{ext}r+  ZOTTOZotfZttf)rA  T)Zexist_okzSaving variation font %s)+ZargparserG  Z	fontToolsrH  main__doc__Zadd_argumentZadd_mutually_exclusive_groupZ
parse_argsZverboseZquietr  r   r  ZgetVariableFontsZerrorr5  r'   Zvariable_fontsr3   rQ   rI  rr   
output_dirr4  r>  filenamer?  Zjoinr8  r/  r0  r,  r|   r  r-  rS   ZsfntVersionr-   ZmakedirsrA   rB   Zsave)ZargsrG  rH  ZparserZoutput_groupZlogging_groupZoptionsZdesignspace_filenamer  Zvf_descriptorsZvfs_to_buildr   rP  Zvf_name_to_output_pathrQ  ZfinderZvfsr*  rA  Zoutput_paths   &                   r/   rN  rN    s   '&t||DF
&668LlD}   C      .	   N	   !D	   68	   N   777GMk,5J   i3H   %G!///w'---wV #..%../CDK 113N>{?O?O>RSTL//99B	  273I3I2LMN"s<'81'<L	

 ##JWW__%9:

<A'//"=7>A334B{{&77++BKK877X-.0ggll:.P"77+  '//0F
!! 11%;;C yy{~~/eU,W5<<<EWW__[1
KK
T2+[9
 #r1   Z__main__)r   r   r   )g      ?T)
rP   r  r  r  r  r  r+   r  r  r  )T)r>   rc   ){rO  Ztypingr    ZfontTools.misc.vectorr   ZfontTools.misc.roundToolsr   r   ZfontTools.misc.fixedToolsr   ry   ZfontTools.misc.textToolsr   r   ZfontTools.ttLibr   r   ZfontTools.ttLib.tables._f_v_a_rr	   r
   ZfontTools.ttLib.tables._g_l_y_fr   r   r   Z fontTools.ttLib.tables.ttProgramr   Z%fontTools.ttLib.tables.TupleVariationr   ZfontTools.ttLib.tablesr   r~   ZfontTools.ttLib.tables.otBaser   ZfontTools.varLibr   r   r   ZfontTools.varLib.mergerr   r   ZfontTools.varLib.mvarr   ZfontTools.varLib.iupr   ZfontTools.varLib.featureVarsr   ZfontTools.designspaceLibr   r   ZfontTools.designspaceLib.splitr   r   ZfontTools.varLib.statr   ZfontTools.colorLib.builderr   ZfontTools.colorLib.unbuilderr    Z	functoolsr!   Zcollectionsr"   r#   r$   Zos.pathr4  ZloggingZcopyr%   Zpprintr&   Zrer'   Zerrorsr(   r)   Z	getLoggerrA   rE  r`   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r   r"  r%  r&  r0  r.  r7  r1  Zobjectr8  r2  rF  rN  rD  Zsysrr   ZargvZexitZdoctestZtestmodZfailedr>   r1   r/   <module>rR     s~  2  ( 6 ; / , ? 
 5 @ 1 7 6 6 H . 3 = L P 2 2 6  < <      6*+ P ZzIX (HIO/d!&C%L(0=f   ??Xv1>hKE\ =F!>H  "GCt H !!	1
! 32%T !8z n"b $/ , -8 P2&6 &$<U 0Pf z
388}qHHW__%%& r1   