+
    f7i  c                   s	   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIHtH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RI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 H!t!H"t"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+H,t, ]PZ                  ! R4      t.^RI/H0t0H1t1H2t2H3t3H4t4H5t5H6t6H7t7H8t8H9t9H:t:  ! R R];4      t< ! R R]<4      t=]=P}                  ]P~                  R4      R 4       t@R tAROR ltB]=P}                  ]P                  4      R 4       t@]=P}                  ]P                  4      R 4       t@R tER tF]=P}                  ]P                  4      R  4       t@]=P}                  ]P                  4      R! 4       t@R" tIRPR# ltJRPR$ ltKRQR% ltLR& tM]=P}                  ]P                  4      R' 4       t@RRR( ltO]=P}                  ]P                  4      R) 4       t@]=P}                  ]P                  4      R* 4       t@R+ tRR, tSR- tTR. tUR/ tV]=P}                  ]P                  4      R0 4       t@]=P}                  ]P                  4      R1 4       t@]=P}                  ]P                  4      R2 4       t@ ! R3 R4]=4      tZ]ZP}                  ]P                  4      R5 4       t@]ZP}                  ]P                  4      R6 4       t@]ZP}                  ]P                  4      R7 4       t@ ! R8 R9]=4      t\]\P}                  ]P                  4      R: 4       t@]\P}                  ]P                  4      R; 4       t@]\P}                  ]P                  4      R< 4       t@ ! R= R>]=4      t]R? t^]]P}                  ]P                  4      R@ 4       t@]]P}                  ]P                  4      RA 4       t@]]P}                  ]P                  4      RB 4       t@]]P}                  ]P                  4      RC 4       t@ ! RD RE]]4      t`]`P}                  ]P                  4      RF 4       t@]`P}                  ]P                  4      RG 4       t@RH tcRI td]`P}                  ]P                  ]P                  34      RJ 4       t@]`P}                  ]P                  ]P                  34      RK 4       t@]`P}                  ]P                  4      RL 4       t@]`P}                  ]P                  RM4      RN 4       t@R# )Sz4
Merge OpenType Layout tables (GDEF / GPOS / GSUB).
N)ior)MAX_PAINT_COLR_LAYER_COUNTLayerReuseCache)classifyTools)otRound)build_n_ary_tree)otTables)otBase)BaseFixedValue)dfs_base_table)DefaultTable)buildermodelsvarStore)nonNoneallNoneallEqual
allEqualTosubList)VarStoreInstancer)reduce)buildSinglePos)_compression_level_from_envcompact_pair_poszfontTools.varLib.merger)ShouldBeConstant
FoundANoneMismatchedTypesNotANoneLengthsDiffer
KeysDifferInconsistentGlyphOrderInconsistentExtensionsInconsistentFormatsUnsupportedFormatVarLibMergeErrorc                   sp   a  ] tR t^.t o R
R lt]RR l4       t]/ 3R l4       tRR ltR t	R t
R tR	tV tR# )MergerNc                s     Wn         R V n        R # Nfontttfs)selfr&      &&>/usr/lib64/python3.14/site-packages/fontTools/varLib/merger.py__init__ZMerger.__init__/   s    		    c                s   a aa S \         8w  g   Q R 4       hRS P                  9  d   / S n        \        S4      \        \        P
                  39   d   S3o\        S4      \        8X  d   S3oVV V3R lpV# )zSubclass Merger instead.mergersc                 s  < V P                   R 8X  g   Q h. pS Fe  pW!9   d   K  VP                  V4       SP                  P                  V/ 4      pS F'  pWC9  g   Q RVP                   : RV: R24       hWV&   K)  	  Kg  	  R# )mergezOops, class 'z' has merge function for 'z' defined already.N)__name__appendr-   Z
setdefault)ZmethodZdoneZclazzr-   attrattrscelfclazzess   &    r*   wrapperZMerger.merger.<locals>.wrapper>   s    ??g---D =E",,11%<!D.  >>41. %+DM " ! r,   )r#   __dict__r-   typeenumZEnumMetaZstr)r3   r4   r2   r5   s   fff r*   mergerZMerger.merger4   sc    v~999~DMM)DL=T4==11jG;#HE	  r,   c                s    \        V4      pV P                  4        F;  p \        V R R4      pVf    V# V P                  P	                  VR4      pVf   K9  Vu # 	  V# )r-   N)r7   Zmrogetattrr-   get)r3   ZthingZ_defaultZtypr-   m   &&&   r*   
mergersForZMerger.mergersForP   sa    5kHHJDdIt4G 	   d+A}  r,   c                s~  a \        VR 4      '       d   VP                  RR7       V F)  p\        VR 4      '       g   K  VP                  RR7       K+  	  \        \        V4      P	                  4       4      o\
        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       g?   \        T SV Uu. uF%  p\        \        V4      P	                  4       4      NK'  	  upR7      hV P                  V4      pVP                  RV P                  P                  4      p S FJ  pW9   d   K  \        W4      p	V U
u. uF  p
\        W4      NK  	  pp
VP                  W4      pV! W	V4       KL  	  R# u upi u up
i   \         d)   pTP                  P                  RX,           4       h Rp?ii ; i)	ensureDecompiledF)Zrecursec              3   sn   <"   T F*  pS\        \        V4      P                  4       4      8H  x  K,  	  R # 5ir$   )sortedvarskeys).0vrB      & r*   	<genexpr>Z&Merger.mergeObjects.<locals>.<genexpr>f   s%     ?3a46$q',,.113s   25TexpectedgotZ*.N)hasattrr?   r@   rA   rB   allr   r>   r;   	__class__mergeThingsr:   r"   stackr0   )r(   outlstexcludeitemrD   r-   ZdefaultMergerkeyvaluetablevalues
mergerFuncerB   s   &&&&          @r*   mergeObjectsZMerger.mergeObjects_   sf   3*++   /Dt/00%%e%4  d3inn&'s?3?sss?3???t#)N#Q&a*@#)N  //#&C)C)CD
	>);>?3%'%-3?$[[<
4/  *O @   	GGNN39%	s0   +E?-F	 	F F	 F	 	F<#F77F<c           
     s|   \        W\        4      '       g1   \        T \        V4      V Uu. uF  p\        V4      NK  	  upR 7      h\        \	        V\	        V!  4      4       F  w  pw  rV V P                  WV4       K  	  R# u upi   \         d)   pTP                  P                  RT,          4       h Rp?ii ; i)rG   z[%d]N)	r   lenr   	enumerateziprN   r"   rO   r0   )r(   rP   rQ   xirU   rW   rY      &&&     r*   
mergeListsZMerger.mergeListsx   s    #C((s3xc=Rcc!fc=RSS"+CS#Y,?"@A  / #A >S $ vz*s   B,BB;#B66B;c           
     s|   \        W\        4      '       gE   \        T \        V4      P                  V Uu. uF  p\        V4      P                  NK  	  upR 7      hV P	                  V4      P                  RR4      pVe   V! WV4       R# \        V\        P                  4      '       d!   \        W4      '       g   \        WVR 7      hR# \        VR4      '       d   V P                  W4       R# \        V\        4      '       d   V P                  W4       R# \        W4      '       g   \        WVR 7      hR# u upi )rG   Nr6   )r   r7   r   r/   r>   r;   
isinstancer8   ZEnumr   rK   rZ   listra   )r(   rP   rQ   r^   rX      &&&  r*   rN   ZMerger.mergeThings   s    #D))!tCy11RU7VRUQQ8H8HRU7V  __S)--dD9
!t#&TYY'' c''&tsCC (S*%%c'T""OOC%c''&tsCC ( 8Ws   D9c           
     s
   V FH  pWA9  d   K   W n         T P                  W,          V Uu. uF  qUP                  V4      NK  	  up4       KJ  	  R # u upi   \         d"   pTP                  P                  T4       h R p?ii ; ir$   )r'   rN   r;   r"   rO   r0   )r(   r&   master_ttfs	tableTagsZtagr<   rY   s   &&&&   r*   mergeTablesZMerger.mergeTables   sn    C'	  ,MAUU3Z,MN 
 -N# s#s(   AAAAB!A==Br%   r$   )r$   ) )r/   
__module____qualname____firstlineno__r+   classmethodr9   r>   rZ   ra   rN   rg   __static_attributes____classdictcell____classdict__   @r*   r#   r#   .   sO     
  6 )+  2D*	 	r,   r#   c                   s    ] tR t^tRtR# )AligningMergerrh   N)r/   ri   rj   rk   rm   rh   r,   r*   rr   rr      s    r,   rr   ZGlyphClassDefc                 s  a Vf"   \        V4      '       g   \        V R VR7      hR # V Uu. uF  q3P                  NK  	  pp/ Vn        VP                  p\        4       pVP                  ! V Uu. uF  q3P                  4       NK  	  up!   V Fa  o\        V3R lV 4       4      p\        V4      '       g   \        W^ ,          VRS,           .R7      hV'       g   R VS&   KU  V^ ,          VS&   Kc  	  R # u upi u upi )NrG   c              3   sD   <"   T F  qP                  S4      x  K  	  R # 5ir$   )r;   )rC   lkrE   r*   rF   merge.<locals>.<genexpr>   s     2cEE!HHc    rJ   )rH   rI   rO   )	r   r   	classDefssetupdaterB   r   r   r   )r9   r(   rQ   rs   ZallKeysZ	allValuesrt      &&&   @r*   r.   r.      s    |s||6Dc:: #
$1;;C
$DN>>DeGNNs+s!VVXs+,2c22		"""13sQwi  DGlDG  % ,s   C4.C9c                 sN   V P                   ^8X  d   V # \        P                  ! 4       p^Vn         V P                  Vn        V P                  Vn        VP                  P
                   Uu. uF  q P                  NK  	  upVn        \        VP                  4      Vn        V# u upi )   )	Formatot	SinglePosCoverageValueFormatglyphsValuer[   
ValueCount)r(   ret_s   &  r*   _SinglePosUpgradeToFormat2r      sz    {{a
,,.CCJ==CL&&CO%(\\%8%89%8%89CI^CNJ :s   *B"c                s0  a Vf   V Uu. uF  p\        V4      NK  	  ppM?\        W4       UUUUu. uF$  w  rF\        WF4       UUu/ uF  w  rxWxbK	  	  uppNK&  	  ppppp\        4       p	V	P                  ! V!   V P                  4       P                  o\        V	SR7      p
\        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       g   \        4       h?	RpVf/   V UUu. uF  pV
 Uu. uF  qV9   d   TMTNK  	  upNK  	  pppW3# \        V4      \        V4      8X  g   Q hV UUu. uF#  pV
 Uu. uF  qV9   d	   W,          MTNK  	  upNK%  	  pppW3# u upi u uppi u uppppi u upi u uppi u upi u uppi )a<  Takes font and list of glyph lists (must be sorted by glyph id), and returns
two things:
- Combined glyph list,
- If values_lst is None, return input glyph lists, but padded with None when a glyph
  was missing in a list.  Otherwise, return values_lst list-of-list, padded with None
  to match combined glyph lists.
NrT   c              3   sD   <"   T F  p\        VSR 7      V8H  x  K  	  R# 5i)r   N)r@   )rC   vssortKeyrE   r*   rF   Z%_merge_GlyphOrders.<locals>.<genexpr>   s     ;svbg&",srv   FT)	rx   r]   ry   getReverseGlyphMapZ__getitem__r@   rL   r   r[   )r&   rQ   Z
values_lstdefaultrs   Z	dict_setsr   grD   ZcombinedZorderZpaddedValuesZdict_setglyphpaddedr   s   &&&&           @r*   _merge_GlyphOrdersr      s    %()SSVS	)	@CC@TU@Tuqs1z2ztqadz2@T	UuHOOY%%'33G8)E3;s;333;s;;;$&&L &
% CHH%x'UW4%H% 	 
 = 3x3z?*** &
% MRRE5 1X_w>ER% 	 
 =3 *2U I
 S
sL   E/E:
E4E:
7	F FF 	F	F"F4E:
FFc                 t    V^ ,          P                   P                  4       Vn         V P                  W4       R#     Nr6   copyrZ   r9   r(   rQ      &&&r*   r.   r.      *     FOO((*DM
"r,   c                 r   r   r   r   r   r*   r.   r.      r   r,   c                 s   V F  pVeG   \        V4      \        P                  8w  g)   VP                  e   W#P                  P                  9  d   KO  VP
                  ^8X  d   VP                  u # VP
                  ^8X  d9   VP                  VP                  P                  P                  V4      ,          u # \        V RR7      h	  R # )Nsingle positioning lookupsubtable)	r7   r}   r~   r   r   r|   r   indexr!   )r9   	subtablesr   r(      &&& r*   %_Lookup_SinglePos_get_effective_valuer     s    LDzR\\)}}$MM000;;!::[[A::dmm2288?@@#F5PQQ  r,   c                 s   V EFR  pVeG   \        V4      \        P                  8w  g)   VP                  e   W$P                  P                  9  d   KP  VP
                  ^8X  de   VP                  VP                  P                  P                  V4      ,          pVP                  pV F  pVP                  V8X  g   K  Vu u # 	  K  VP
                  ^8X  ds   VP                  P                  P                  V^ 4      pVP                  P                  P                  V^ 4      p	VP                  V,          P                  V	,          u # \!        V RR7      h	  R # )Npair positioning lookupr   )r7   r}   PairPosr   r   r|   PairSetr   PairValueRecordSecondGlyph	ClassDef1rw   r;   	ClassDef2Class1RecordClass2Recordr!   )
r9   r   Z
firstGlyphZsecondGlyphr(   pspvrrecZklass1Zklass2
   &&&&      r*   (_Lookup_PairPos_get_effective_value_pairr     s    LDzRZZ'}}$!5!55;;!dmm2288DEB$$C??k1J  [[A^^--11*a@F^^--11+qAF$$V,99&AA#F5NOO) * r,   c                 s  a \        \        P                  V Uu. uF  q3P                  NK  	  up^ 4      ;Vn        p\	        V4      ^8X  g   VR	,          ^ 8X  g   \        V RR7      hVP                  P                  o\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       d   \        P                  ! WAP                  4      Vn        V^ 8w  dY   T P                  VP                  V Uu. uF1  qUP                  e   VP                  M\        P                  ! 4       NK3  	  up4       VP                  P                  4       Vn        R# ^Vn        V Uu. uF  p\        V4      NK  	  pp\!        V P"                  V Uu. uF  qUP                  P                  NK  	  upV Uu. uF  qUP                  NK  	  up4      w  rgWaP                  n        V Uu. uF  p\        P                  ! V4      NK  	  upVn        \	        VP                  4      Vn        \'        V4       F`  w  r\'        V4       FL  w  rW,          e   K  \)        W P*                  V	,          V4      pVf   \        P                  ! V4      pWZV&   KN  	  Kb  	  V P-                  VP                  V4       V P/                  WR
R7       \        \        P                  VP                   Uu. uF  qUP1                  4       NK  	  up^ 4      Vn        R# u upi u upi u upi u upi u upi u upi u upi )r   r   r   c              3   s>   "   T F  qP                   ^8H  x  K  	  R# 5i   Nr|   rC   rD      & r*   rF   ru   <  s     
&#Q88q=#s   FTc              3   sV   <"   T F  pSVP                   P                  8H  x  K   	  R # 5ir$   )r   r   )rC   rD   coverageGlyphsrE   r*   rF   ru   <  s#      /58!**+++Ss   &)NrR   i)r|   r   r   r   r   )r   int__or__r   r[   r!   r   r   rL   r   ValueRecordr   rN   	getFormatr|   r   r   r&   r   r\   r   lookup_subtablesra   rZ   ZgetEffectiveFormat)r9   r(   rQ   rs   ZvalueFormatrD   r   r   r   r_   rW   jr   r   s   &&&          @r*   r.   r.   4  s   %+CJJPS8TPS1PS8TVW%XXD{HMkD0A51LMM ]]))N
s
&#
&sss
&#
&&&33 /58/333 /58/ , , ''ZZ@
! 

SVWSVaGG/V5G5G5IISVW  :://1 DK25
6#Q%a(#C
6 (5Ajj''57MA7MNF "MM;AB6a&$$[16BDJ$**oDOv&	!&)HAy$
 6//2EA y&&{31I * ' djj&) W   

TZZ@Z))+Z@!Do 9U  X 7 67M C2 As)   M
>7M
(MM
6M#'M((M-
c                 s   \        V P                  V UUu. uF'  q3P                   Uu. uF  qDP                  NK  	  upNK)  	  uppV Uu. uF  q3P                  NK  	  up4      w  rV. ;Vn        pV F  p\        P                  ! 4       p	Wn        V P
                  '       d!   \        P                  ! V P
                  4      MR V	n        V P                  '       d!   \        P                  ! V P                  4      MR V	n
        VP                  V	4       K  	  \        VP                  4      Vn        \        V4       EF  w  r\        V4       F  w  r\        P                  ! 4       pWn        W,          e
   W,          pM(\        W P                   V
,          VP"                  V4      pVf   R R rM\%        VRR 4      p\%        VRR 4      pV P
                  '       d#   \        P                  ! V P
                  VR7      MR Vn        V P                  '       d#   \        P                  ! V P                  VR7      MR Vn
        WKV&   K  	  EK  	  V=V P'                  VP                  V4       R # u upi u uppi u upi )NValue1Value2)Zsrc)r   r&   r   r   r}   valueFormat1r   r   r   valueFormat2r   r0   r[   PairValueCountr\   r   r   _firstGlyphr:   ra   )r9   r(   rQ   r   rD   r   r   pvrsr   r   r_   rW   r   ZvpairZv1Zv2s   &&&             r*   r.   r.   r  s    (?BCs!3!3	4!3A--!3	4sC&)*c		c*NF #%$D4  "7=7J7J7JFv223PT 	
 8>7J7J7JFv223PT 	
 	C  d223Dv&	!&)HA""$A!My$	@33A68H8H% }tBUHd3UHd3 &&& ""6#6#6B? H &&& ""6#6#6B? H
 1I3 * '6 	
d**F3] 
5C*s   I2I-I2
I8-I2c                 s   \        V Uu. uF%  q3P                  '       g   K  VP                  ^ 8H  NK'  	  up4      '       g   Q R4       hVP                  V VRR7       \        P                  ! 4       p. Vn        ^ Vn        \        VP                  V Uu. uF  qUP                  P                  NK  	  upV Uu. uF  qUP                  NK  	  upVR7      w  rgW`P                  n
        V Uu. uF  p\        P                  ! 4       NK  	  upV n        \        V P                  4      V n        \        W`P                  4       F  w  rWn        K  	  VP                  V P                  V4       R# u upi u upi u upi u upi )r   Report bug against fonttools.r   r   N)r   r   PairSetCountValueFormat1ValueFormat2)r   r   r   rZ   r}   r   r   r   r&   r   r   r[   r   r]   r   ra   )r(   rQ   r9   rs   ZemptyrD   r   r   r   r   r      &&&        r*   _PairPosFormat1_merger     s?   &)7cYY	1	c7  '&' 
 W   JJLEEE ($'(Cq		C( CqC 	NF "MM*01&QBJJL&1DLDLL)D.	 / dllF+9 	8" 	) 
 2s   E-E-E2
8E7+E<c                 s0   \        V \        4      '       d   T pM(V '       d   V P                  '       d   V P                  M/ pV'       d   \        VP	                  4       4      M^ p. p\        V^,           4       F  pVP                  \        4       4       K  	  VP                  4        F  w  rgWG,          P                  V4       K  	  Vf   RV^ &   V# \        V4      ;V^ &   pVR,           F%  p	V	P                  V4       VP                  V	4       K'  	  V# )r   Nr   NN)rb   Zdictrw   maxrW   ranger0   rx   ZitemsaddZintersection_updateZdifference_update)
r(   	allGlyphsrw   r<   r   r   rt   rD   Zclass0Zss
   &&        r*   _ClassDef_invertr     s    $	&*t~~~DNN2	#,I!A
C1q5\

35  !

1 " A J i.(ARA!!&)$$Q'  Jr,   c                 s   \         P                  ! 4       p/ ;Vn        pVR J pV'       d   R .\        V 4      ,          p\        P
                  ! 4       p\        W4       F.  w  rg\        Wg4      pVf
   VR,          pVP                  V4       K0  	  VP                  4       p	V'       d   V	P                  ^ \        4       4       \        V	4       F  w  rV
^ 8X  d   K  V F  pWV&   K	  	  K  	  W)3# )Nr   )r}   ZClassDefrw   r[   r   Z
Classifierr]   r   ry   Z
getClassesZinsertrx   r\   )rQ   ZallGlyphsesr(   rw   ZallGlyphsesWasNoneZ
classifierZclassDefr   Zsetsclassesr_   classSetr      &&           r*   _ClassDef_merge_classifyr     s    ;;=D!##DNY$,fs3x'))+J"3448D$	  5
 ##%Gq#%  )6AaL  * =r,   c                 s   V Uu. uF  qDP                   NK  	  pp\        V Uu. uF  qDP                  NK  	  upV Uu. uF  qDP                  P                  NK  	  up4      w  V n        p\        V4      V n        . p\        W4       EF  w  rHR p	\        VP                  P                  4      p
VP                  P                  p. pV EF/  p\        \        V4      4      pW9  d   R p	V	f   \        P                   ! 4       p	. ;qn        \        VP                  4       F  pV'       d   R pM\        P                  ! 4       pV P                   '       d!   \"        P$                  ! V P                   4      MR Vn        V P(                  '       d!   \"        P$                  ! V P(                  4      MR Vn        VP-                  V4       K  	  T	pMVP/                  V^ 4      pVV,          pVP-                  V4       EK2  	  VP-                  V4       EK  	  Tp?\        V Uu. uF  qDP0                  NK  	  up4      w  V n        p\        V4      V n        . p\        W4       F  w  rHVP0                  P                  p. pV F  pVP                  p\        P                   ! 4       p. ;pVn        V Fi  pV'       g   V^ ,          pM/\        \        V4      4      pVP/                  V^ 4      pVV,          pVP-                  \2        P4                  ! V4      4       Kk  	  VP-                  V4       K  	  VP-                  V4       K  	  Tp?V# u upi u upi u upi u upi r$   )r   r   r   r   r   r[   Class1Countr]   rx   rw   nextiterr}   r   r   Class2Countr   r   r   r   r   r   r0   r;   r   r   deepcopy)r(   rQ   r&   transparentrs   matricesr   Znew_matricesmatrixZnullRowZcoverageZ	classDef1Zclass1Recordsr   ZexemplarGlyphZclass2recordsr   Zrec2Zrec1ZklassZ	classDef2Zrec1oldZoldClass2RecordsZrec1newZclass2Recordss   &&&&                     r*   _PairPosFormat2_align_matricesr      s   (+,1H, 7!"cc"$D1ZZ%6%6$DDNG 7|DL'	qzz(()KK))	H h0M,
 ? oo/G;==M$8"1==1&#'D#%??#4D $(#4#4#4 !' 2 243D3D E%) !K $(#4#4#4 !' 2 243D3D E%) !K
 &,,T2 2  !mQ7e}  &A  B 	M*M (N H 7S7QSS7QRDNG7|DL'	KK))	G&33oo'G355MG0#+A.D$(h$8M%MM-;E+E2D$$T]]4%89 $   )  	M*! (" HOU - 	#$D^ 8Rs   M	MM
Mc                 s   \        V Uu. uF%  q3P                  '       g   K  VP                  ^ 8H  NK'  	  up4      '       g   Q R4       hVP                  V VRR7       \	        VP
                  V Uu. uF  qDP                  P                  NK  	  up4      w  rVWPP                  n        \        WP                  4       F1  w  r7VP                  P                  V8w  g   K"  W7R,          8X  d   K1  Q h	  \        WVP
                  4      p\        V^ ,          4      V n        VP                  V P                  V4       R# u upi u upi )r   r   r   N)r   r   r   r   r   r   r   r   )r   r   r   rZ   r   r&   r   r   r]   r   r   rc   ra   )	r(   rQ   r9   rs   rD   r   r   r   r   	   &&&      r*   _PairPosFormat2_merger   N  s   &)<c^^	1	c<  '&'  	
    #6;;C0PCq1B1BC0PQIF!MM C!8!89::&"%%% : .dEHXa[)D
d''2I 	=& 1Qs   D=D=1E
c                 s   \        \        P                  V Uu. uF  q3P                  NK  	  up^ 4      ;V n        Vn        \        \        P                  V Uu. uF  q3P
                  NK  	  up^ 4      ;V n        Vn        VP                  ^8X  d   \        WV 4       M+VP                  ^8X  d   \        WV 4       M\        V RR7      hV =V =^ p^ pVP                  ^8X  dx   VP                   Ff  pVP                   FS  p\        VRR4      pVe   WHP                  4       ,          p\        VRR4      p	V	f   K=  WYP                  4       ,          pKU  	  Kh  	  MVP                  ^8X  dw   VP                   Ff  p
V
P                    FS  p\        VRR4      pVe   WHP                  4       ,          p\        VRR4      p	V	f   K=  WYP                  4       ,          pKU  	  Kh  	  WAn        WQn        R# u upi u upi )r   r   r   r   Nr   )r   r   r   r   r   r   r   r|   r   r   r!   r   r   r:   r   r   r   )r9   r(   rQ   rs   Zvf1Zvf2ZpairSetZpairValueRecordZpv1Zpv2Zclass1RecordZclass2Records   &&&         r*   r.   r.   w  s   .4

S1S^^S11/ F$+ /5

S1S^^S11/ F$+ {{ad0		d01JKKV0 C
C{{a||G#*#:#:ox>?==?*Cox>?==?*C $; $ 
	 --L , 9 9lHd;?==?*ClHd;?==?*C !: . M 2 2s   G/
G4
c                 sL   \        R  V 4       4      V n        \        VP                  V Uu. uF  p\	        WSR,           4      P
                  NK!  	  upV Uu. uF  p\	        WSR,           4      P                  NK!  	  up4      w  rgV\	        WR,           4      n        \        VP                  V Uu. uF  p\	        WTR,           4      P
                  NK!  	  upV Uu. uF&  p\	        \	        WTR,           4      VR,           4      NK(  	  up4      w  rV\	        WR,           4      n        . p
\        V\        V!  4       F  w  rV Uu. uF  qf   K  VP                  NK  	  pp\        V4      '       g   \        W.^ ,          VR7      h\        P                  ! 4       pV^ ,          Vn        V Uu. uF  qf   RMVP                  NK  	  pp\        V4      '       d   RpM.\        P                  ! 4       p^Vn        VP!                  VV4       VVn        V
P#                  V4       K  	  \        P$                  ! 4       pV
Vn        \'        V
4      Vn        \+        WR,           V4       . p
\        V\        V	!  4       EF!  w  r\        V4      '       d   RpM\	        \        VR,           4      ! 4       p. p\+        WR,           V4       V Uu. uF  qf   . M\	        WR,           4      NK  	  ppV F6  pVP-                  R.V P                  \'        V4      ,
          ,          4       K8  	  \        V!   FV  p\        V4      '       d   RpM.\        P                  ! 4       p^Vn        VP!                  VV4       VP#                  V4       KX  	  V
P#                  V4       EK$  	  \	        \        VR,           4      ! 4       p\+        VVR,           V
4       \+        VVR,           \'        V
4      4       \+        WR,           V4       R# u upi u upi u upi u upi u upi u upi u upi )c              3   8   "   T F  qP                   x  K  	  R # 5ir$   )
ClassCountrC   rs   r   r*   rF   Z,_MarkBasePosFormat1_merge.<locals>.<genexpr>  s     41,,   r   ZArrayZRecordNrG   AnchorZCount)r   r   r   r&   r:   r   Z
MarkRecordr]   ZClassr   r   r}   Z
MarkAnchorr   r   r|   rN   r0   Z	MarkArrayr[   Z	MarkCountsetattrextend)r(   rQ   r9   MarkBasers   ZMarkCoverageGlyphsZMarkRecordsZBaseCoverageGlyphsZBaseRecordsZrecordsr   ZglyphRecordsrZ
allClassesr   Z
allAnchorsZanchorZarrayZanchorsZglyphAnchorss   &&&&&                r*   _MarkBasePosFormat1_merger     si   444DO&87:;s!:%	&	-	-s;8;<17N	#	.	.<'#
 /AGD#$+&87:;s!:%	&	-	-s;GJKs!7N+TH_	=sK'#
 /AGD#$+ G133DE'3E|!gagg|
E$ 
##"6qMzRR--/C"1CIGST|!)$=|JTz"" !""6:6#CNsA FB LLNEE'lEOD.%( G133DE<  C"dXo.0CGC'2JVJVQiWQx%@@,   "$4??SV#;<= "!<0
:&&!FYY[F$%FM&&vz:v& 1 	s) F* Bw')EE4(?G,E4'>3w<0D.%(] 	<< 	<K F. U.s/   %P
%P0%P
,PPP-P
 P!c           	      s   \        VP                  R  V 4       4      '       g3   \        T RVP                  V Uu. uF  q3P                  NK  	  upR7      hVP                  ^8X  d   \        WV 4       R# \	        V RR7      hu upi )c              3   r   r$   r   r   r   r*   rF   ru          #:cHHcr   zmark-to-base positioning lookupr   rH   rI   r   Nr   r|   r    r   r!   r9   r(   rQ   rs   r   r*   r.   r.     sr    dkk#:c#:;;!6[[#&'3a3'	
 	
 {{a!$V41RSS (s   Bc           	      s   \        VP                  R  V 4       4      '       g3   \        T RVP                  V Uu. uF  q3P                  NK  	  upR7      hVP                  ^8X  d   \        WV RR4       R# \	        V RR7      hu upi )c              3   r   r$   r   r   r   r*   rF   ru   
  r   r   zmark-to-mark positioning lookupr   ZMark1ZMark2r   Nr   r   r   r*   r.   r.     sv    dkk#:c#:;;!6[[#&'3a3'	
 	
 {{a!$VWgF1RSS (s   Bc                 s   \         P                  ! 4       p\         P                  ! 4       Vn        \        TV  UUu. uF'  q3P                   Uu. uF  qDP
                  NK  	  upNK)  	  uppV  Uu. uF  q3P                  NK  	  up4      w  rVWRP                  n        . ;Vn        p\        V!   F$  pV F  pVf   K	  VP                  V4        K"  	  Q h	  \        VP                  4      Vn
        V# u upi u uppi u upi r$   )r}   r   r   r   r   r   r   r]   r0   r[   r   )	rQ   r&   r(   r   rD   r   r   r   rW   s	   &&       r*   _PairSet_flattenr     s    ::<DKKMDM (?BCs!3!3	4!3A--!3	4sC&)*c		c*NF "MM"$$D4v,A}A 
 5  d223DK 
5C*s   C7C2!C7/C=2C7c           
      s   \        V  Uu. uF%  q"P                  '       g   K  VP                  ^ 8H  NK'  	  up4      '       g   Q R4       h\        P                  ! 4       p^Vn        \        P                  ! 4       Vn        \        \        P                  V  Uu. uF  q"P                  NK  	  up^ 4      Vn
        \        \        P                  V  Uu. uF  q"P                  NK  	  up^ 4      Vn        \        Y Uu. uF  qDP                  P                  NK  	  upV  Uu. uF  qDP                  NK  	  up4      w  rVWSP                  n        \        V!   UUu. uF$  p\        V Uu. uF
  qDf   K  VNK  	  upV4      NK&  	  uppVn        \        VP                  4      Vn        V# u upi u upi u upi u upi u upi u upi u uppi )r   r   )r   r   r   r}   r   r|   r   r   r   r   r   r   r   r]   r   r[   r   )rQ   r&   rs   r(   rD   r   r   rW      &&      r*   (_Lookup_PairPosFormat1_subtables_flattenr   0  sn   &)7cYY	1	c7  '&'  ::<DDKKKMDMszzC+HCqNNC+H!LDszzC+HCqNNC+H!LD (#.#Qzz  #.C0HCqC0HNF "MM 6l"F 	V=V!!V=tD"DL DLL)DK) 	8 ,I+H /0H
 >s@   F&F&F+
F0
:F5
F:G%F?/F?5G?Gc                 s   \        V  Uu. uF%  q"P                  '       g   K  VP                  ^ 8H  NK'  	  up4      '       g   Q R4       h\        P                  ! 4       p^Vn        \        P                  ! 4       Vn        \        \        P                  V  Uu. uF  q"P                  NK  	  up^ 4      Vn
        \        \        P                  V  Uu. uF  q"P                  NK  	  up^ 4      Vn        \        Y Uu. uF  qDP                  P                  NK  	  up4      w  rVWSP                  n        \        W0VRR7      p. ;qn        \        V!   F  p	\        P                  ! 4       p
VP                  V
4       . V
n        V
P                   p
\        \#        R V	 4       4      !   F/  p\%        \'        R V 4       4      4      pV
P                  V4       K1  	  K  	  V# u upi u upi u upi u upi )r   r   T)r   c              3   r   r$   )r   )rC   r   r   r*   rF   ;_Lookup_PairPosFormat2_subtables_flatten.<locals>.<genexpr>`  s     ;dnndr   c              3   s0   "   T F  qf   K  Vx  K  	  R # 5ir$   rh   rC   cr   r*   rF   r   a  s     =t!AAts   
)r   r   r   r}   r   r|   r   r   r   r   r   r   r   r   r]   r0   r   rc   r   r   )rQ   r&   rs   r(   rD   r   r   r   r   ZrowsZrowZcolsZcolr   r*   (_Lookup_PairPosFormat2_subtables_flattenr   I  s   &)<c^^	1	c<  '&'  ::<DDKKKMDMszzC+HCqNNC+H!LDszzC+HCqNNC+H!LD #4S)IS***;*;S)IJIF!MM-d4PH!##FXooc;d;;<Dt=t==>CJJsO =  K3 	= ,I+H *Js   GGG#
G(
:G-
c                sH   \        V 4      p \        V 4      p^ pW28  d#   W,          P                  ^8X  d   V^,          pK(  \        V RV V4      .V RV% \        V 4      pTpV^ 8  d*   W^,
          ,          P                  ^8X  d   V^,          pK0  \	        WR V4      .WR% V # )zMerge multiple Format1 subtables at the beginning of lst,
and merge multiple consecutive Format2 subtables that have the same
Class2 (ie. were split because of offset overflows).  Returns new list.N)rc   r[   r|   r   r   )rQ   r&   rs   r_      &&  r*   &_Lookup_PairPos_subtables_canonicalizer   g  s     s)CCA	A
%CFMMQ&	Q7BQFGCGCA	A
a%CAJ%%*	Q7BFGCGJr,   c                 sB   \        Y Uu. uF  q3P                  P                  NK  	  upR 4      w  rE\        V4      p\        P
                  ! 4       p^Vn        W'n        \        P                  ! 4       Vn        WGP                  n        Wgn        R .V,          Vn	        V  F  pVP                  ^8X  d`   VP                  p	VP                  P                   F7  p
VP                  V
4      p\        P                  ! V	4      VP                  V&   K9  	  Ks  VP                  ^8X  g   K  \        VP                  P                  4       FL  w  rVP                  V,          p	VP                  V
4      p\        P                  ! V	4      VP                  V&   KN  	  K  	  V.# u upi r$   )r   r   r   r[   r}   r~   r|   r   r   r   r   r   r   r\   )rQ   r&   Zmin_inclusive_rec_formatrD   r   r   Z
num_glyphsZnewZ	singlePosZval_recgnamer_   r   s   &&&          r*   #_Lookup_SinglePos_subtables_flattenr   |  s=   "4S)IS***;*;S)I4PIFVJ
,,.CCJ.O;;=CL LLN#CI	q ooG"++22LL'#}}W5		! 3 "%i&8&8&?&?@#//!,LL'#}}W5		! A  5L) *Js   F
c                 s   \        V P                  V Uu. uF  q3P                  P                  NK  	  upV Uu. uF  q3P                  NK  	  up4      w  rE^Vn        \        P                  ! 4       Vn        WAP                  n        . Vn        V F  p\        P                  ! 4       p\        P                  ! 4       Vn        ^VP                  n        \        P                  ! 4       Vn	        ^VP                  n        VP                  P                  V4       K  	  V P                  VP                  V4       \        VP                  4      Vn        R# u upi u upi r   )r   r&   r   r   EntryExitRecordr|   r}   r   EntryAnchor
ExitAnchorr0   ra   r[   ZEntryExitCount)r9   r(   rQ   rs   r   r   r   r   r`   r*   r.   r.     s     ($'(Cq		C($'(Cq		C(NF DKKKMDM!MMD  "))+!" !##C(  d**F3d223D! 	)(s
   E
Ec                 s,   \         ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       d   RVn        \         ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   RVn        V P                  W4       R# )c              3   <   "   T F  qP                   R J x  K  	  R # 5ir$   )r   rC   Zmasterr   r*   rF   ru     s     
8C&%C   FTNc              3   r   r$   )r   r   r   r*   rF   ru     s     
73$3r   )rL   r   r   rZ   r   r   r*   r.   r.     sa    
s
8C
8sss
8C
888
s
73
7sss
73
777
"r,   c           	      s   V Uu. uF  q3P                   NK  	  up;q@n        \        \        W$4      4      WP                   3.,            EF  w  r5V'       g   K  V^ ,          P                  P
                  P                  R4      '       g   KD  \        V Uu. uF  qfP                  NK  	  up4      '       g2   \        T RV Uu. uF  qfP                  P
                  NK  	  upR7      h\        V Uu. uF  qfP                  NK  	  up4      '       g   \        V 4      hV^ ,          P                  Vn
        V Uu. uF  qfP                  NK  	  ppVR VP                  V4       EK  	  VP                   ;'       d,    \        VP                   ^ ,          \        P                  4      pV'       dS   \!        VP                   V P"                  4      Vn         V Uu. uF  p\!        W`P"                  4      NK  	  up;q@n        EMVP                   ;'       d,    \        VP                   ^ ,          \        P$                  4      p	V	'       d   V Uu. uF  p\'        V4      NK  	  p
p\)        V
 Uu. uF  qV
^ ,          8H  NK  	  up4      '       g   V UUu. uF  qf F  qP*                  NK  	  K  	  ppp\-        \.        V4      p\1        VP                   V P"                  V4      Vn         V Uu. uF  p\1        W`P"                  V4      NK  	  up;q@n        RpMRpV P3                  VP                   V4       \'        VP                   4      Vn        V'       Ed   \'        VP                   4      ^8  d#   VP                   ^ ,          P6                  ^8X  g   Q hVP                   ^ ,          P8                  P:                  '       g5   VP                   P=                  ^ 4       V;P4                  ^,          un        \'        VP                   4      ^8  d#   VP                   R,          P6                  ^8X  g   Q hVP                   R,          P8                  P:                  '       g5   VP                   P=                  R4       V;P4                  ^,          un        V P"                  P>                  PA                  R\C        4       R7      pV^ 8w  dV   \D        PG                  R4       \I        V P"                  VVP                   4      Vn         \'        VP                   4      Vn        MX	'       d   X'       d~   VP                   ^ ,          pVP8                  P:                  p\        VVPJ                  4       UUu/ uF	  w  ppVVbK  	  ppp\M        VV P"                  PO                  4       4      Vn         V PQ                  WR	R
.R7       V =R# u upi u upi u upi u upi u upi u upi u upi u upi u uppi u upi u uppi )r   Z	ExtensionrG   :NNNTFz0fontTools.otlLib.optimize.gpos:COMPRESSION_LEVELr   zCompacting GPOS...SubTableSubTableCountr   Nr   ))r   r   rc   r]   rM   r/   Z
startswithr   r   ZExtensionLookupTypeZ
LookupTypeZExtSubTabler   rb   r}   r   r   r&   r~   r[   rL   r   r   r    r   ra   r   r|   r   r   popZcfgr;   r   logZinfor   r   r   r   rZ   )r9   r(   rQ   rs   r   ZstsstZnew_stsZ	isPairPosZisSinglePosZnumSubtablesZnumsZtZvalueFormatListZmirfZ	flattenedZlevelZsinglePosTabler   r   Z	valRecordZsinglePosMappings   &&&                   r*   r.   r.     s   ?B*Cs!::s*CCI' s3*+mm/D.EEEq6$$//<<C8Cb\\C899,(9<=2..= 
 cBc33cBCC,V44q655AL034"~~G4AJJw F" JJ*T]]1-=rzz"JI ?MM6;;
 OX/
NW22{{Ci/
 	
	+ mmRR
4==3CR\\(R.78iCGiL8LILDQ/LIJJ <E"Q9Rb==b=9"Qc?3 CMM6;;!
 (7' 8KKN'7 	3 !	!	
dmmY/T]]+Dy4==!Q&4==+;+B+Ba+GGG}}Q((///MMa !# 4==!Q&4==+<+C+Cq+HHH}}R ))000MMb!!# ##>/1 $ 
 A:HH)*,V[[%ODM!$T]]!3D	q)((// 69AUAU5V
5V!1	E95V 	 
 'fkk<<>
 J+HIA +D 9 >B 5/
 9I #R7T
sA   WW
W1W
9WWW$+W)W.*W42W9c                   s*   a  ] tR tRt o RtR tRtV tR# )InstancerMergeri  zHA merger that takes multiple master fonts, and instantiates
an instance.c                st    \         P                  W4       W n        W0n        VP	                  V4      V n        R # r$   )r#   r+   modellocationZgetMasterScalarsmasterScalars)r(   r&   r  r     &&&&r*   r+   ZInstancerMerger.__init__#  s+    #
 "33H=r,   )r  r  r  Nr/   ri   rj   rk   __doc__r+   rm   rn   ro   rq   r*   r  r    s     > >r,   r  c                 s    VP                   ^8X  g   Q hV Uu. uF  q3P                  NK  	  ppV P                  pV P                  p\	        VP                  WF4      4      Vn        R# u upi r   )r|   
Coordinater  r  r   interpolateFromValuesAndScalars)r9   r(   rQ   aZCoordsr  r     &&&    r*   r.   r.   *  s]    ;;!$'(CqllCF(LLE((M--fDDO )s   A'c                 sT   VP                   ^8X  g   Q hV Uu. uF  q3P                  NK  	  ppV Uu. uF  q3P                  NK  	  ppV P                  pV P                  p\        VP                  WG4      4      Vn        \        VP                  WW4      4      Vn        R# u upi u upi r   )r|   XCoordinateYCoordinater  r  r   r  )r9   r(   rQ   r  ZXCoordsZYCoordsr  r  r`   r*   r.   r.   5  s    ;;!&)*c}}cG*&)*c}}cG*LLE((M--gED --gED +*s
   B B%c           	      s$   V P                   pV P                  pR Fl  w  rV\        W4      '       d   Q h\        W4      '       g   K+  V Uu. uF  p\        Wu^ 4      NK  	  pp\	        VP                  W4      4      p	\        WV	4       Kn  	  R# u upi XAdvanceN)r  Z
XAdvDevice)ZYAdvanceZ
YAdvDevice)Z
XPlacementZ
XPlaDevice)Z
YPlacementZ
YPlaDevice)r  r  rK   r:   r   r  r   )
r9   r(   rQ   r  r  name	tableNamer  rW   rU   
   &&&       r*   r.   r.   D  s    LLE((M 4++++43673agaq)3F755fLE D& 8s   
Bc                   s.   a  ] tR tRt o RtRR ltRtV tR# )MutatorMergeri^  zA merger that takes a variable font, and instantiates
an instance.  While there's no "merging" to be done per se,
the operation can benefit from many operations that the
aligning merger does.c                sH    \         P                  W4       W n        W0n        R # r$   )r#   r+   	instancerdeleteVariations)r(   r&   r  r  r  r*   r+   ZMutatorMerger.__init__d  s    #" 0r,   )r  r  NTr  ro   rq   r*   r  r  ^  s     
1 1r,   r  c                 s   V^ ,          P                   P                  4       Vn         VP                  ^8w  d   R# V P                  pVP                  pV P
                  '       d   V=V'       db   VP                  R8X  g   Q hVP                  ^,          VP                  ,           p\        W5,          4      pV;P                  V,          un
        V P
                  '       d
   ^Vn        R# R# )r   N   )r6   r   r|   r  DeviceTabler  DeltaFormat	StartSizeEndSizer   r
  )r9   r(   rQ   r  devvaridxdeltar  r*   r.   r.   j  s     FOO((*DM{{a  I


C
&(((--2%4	)*5  r,   c           	      sF   V^ ,          P                   P                  4       Vn         VP                  ^8w  d   R# V P                  pR F  pVR,           p\	        W4      '       g   K  \        W4      pV P                  '       d   \        W4       Vf   KM  VP                  R8X  g   Q hVP                  ^,          VP                  ,           p\        W7,          4      pVR,           p	\        W\        W4      V,           4       K  	  V P                  '       d
   ^Vn        R# R# )r   NZXYr  r  r
  )r6   r   r|   r  rK   r:   r  delattrr  r  r  r   r   )
r9   r(   rQ   r  rD   r  r  r   r!  r1   r  r*   r.   r.     s     FOO((*DM{{a  I%	t''d&"""D$;&(((--2%4	)*<GD/%78 "  r,   c           
      s   V^ ,          P                   P                  4       Vn         V P                  pR F  w  rE\        W4      '       g   K  \	        W4      pV P
                  '       d   \        W4       Vf   KF  VP                  R8X  g   Q hVP                  ^,          VP                  ,           p\        W7,          4      p\        W\	        W^ 4      V,           4       K  	  R# )r   Nr  r  )r6   r   r  rK   r:   r  r"  r  r  r  r   r   )	r9   r(   rQ   r  r  r  r  r   r!  r   r*   r.   r.     s     FOO((*DM  I t''d&"""D$;&(((--2%4	)*GD2U:;%r,   c                   sB   a a ] tR tRt oRtR tR tV 3R ltRtVt	V ;t
# )VariationMergeri  zFA merger that takes multiple master fonts, and builds a
variable font.c                s    \         P                  W4       \        P                  ! V4      V n        V P                  V4       R # r$   )r#   r+   r   ZOnlineVarStoreBuilderstore_buildersetModel)r(   r  axisTagsr&   r  r*   r+   ZVariationMerger.__init__  s-    #%;;HEer,   c                sH    Wn         V P                  P                  V4       R # r$   )r  r$  r%  )r(   r  r)   r*   r%  ZVariationMerger.setModel  s    
##E*r,   c                s  < R pR pR V9   d   \        V4      '       d   Ve   \        WR7      hR # V P                  pV P                  '       d-   \        V Uu. uF  qUR JNK  	  upV P                  4      V n        V P                  pVP                  V4      w  rbV P                  V4       \        \        V `'  W4       V'       d   V P                  V4       V'       d	   W@n        R # R # u upi )N)rI   )
r   r   r'   r   r  ZgetSubModelr%  Zsuperr#  rN   )r(   rP   rQ   ZmasterModelZorigTTFsrD   r  rM   s   &&&    r*   rN   ZVariationMerger.mergeThings  s    3;s||?$T33 yyHyyy#C$@Cqd]C$@$))L	**K$005JEMM% ot0:MM+& I  %As   C()r  r$  r'   )r/   ri   rj   rk   r	  r+   r%  rN   rm   rn   Z__classcell__)rM   rp   s   @@r*   r#  r#    s     
+! !r,   r#  c                 s    \        V4      '       d   V^ ,          R3# V P                  V4      w  r#V\        P                  ! V4      3# r   )r   storeMastersr   buildVarDevTable)r$  master_valuesZbasevarIdxr   r*   r(  r(    sE    Q%% --m<LD))&111r,   c                     VP                   ^8w  d   \        V RR7      h\        V P                  V Uu. uF  q3P                  NK  	  up4      w  Vn        pV'       d   ^Vn         WAn        R# R# u upi )r   za baseline coordinater   Nr|   r!   r(  r$  r
  r  r9   r(   rQ   r  r  rd   r*   r.   r.     se    {{a1HII#3S9S||S9$ DO[ &  :   A/
c                 r+  )r   za caretr   Nr,  r-  rd   r*   r.   r.     sd    {{a;;#3S9S||S9$ DO[ &  :r.  c                 s|   VP                   ^8w  d   \        V RR7      h\        V P                  V Uu. uF  q3P                  NK  	  up4      w  Vn        p\        V P                  V Uu. uF  q3P
                  NK  	  up4      w  Vn        pV'       g	   V'       d   ^Vn         WAn        WQn        R# R# u upi u upi )r   z	an anchorr   N)r|   r!   r(  r$  r  r  XDeviceTableYDeviceTable)r9   r(   rQ   r  r/  r0  r=   r*   r.   r.     s    {{a==%5c:c}}c:&"Dl &6c:c}}c:&"Dl |(( $ ; ;s   B4
*B9
c                 s    R Fl  w  r4\        W4      '       g   K  \        V P                  V Uu. uF  p\        WS^ 4      NK  	  up4      w  rg\	        WV4       V'       g   K`  \	        WV4       Kn  	  R# u upi r  )rK   r(  r$  r:   r   )r9   r(   rQ   r  r  r  rU   ZdeviceTabler`   r*   r.   r.     sl     4!1$$C&HCqwq':C&H"E D&{5 'Is   A5c                   s   a  ] tR tRt o RtRR ltRR ltR 3R ltR tR t	R	 t
V 3R
 lR ltV 3R lR lt]R 4       t]R 4       tRtV tR# )COLRVariationMergeri&  a  A specialized VariationMerger that takes multiple master fonts containing
COLRv1 tables, and builds a variable COLR font.

COLR tables are special in that variable subtables can be associated with
multiple delta-set indices (via VarIndexBase).
They also contain tables that must change their type (not simply the Format)
as they become variable (e.g. Affine2x3 -> VarAffine2x3) so this merger takes
care of that too.
c                s    \         P                  WW#4       / V n        . V n        \	        4       V n        . V n        R V n        V'       d   \        4       V n        RV n	        R # )NF)
r#  r+   varIndexCachevarIdxesrx   varTableIdslayerslayerReuseCacher   _doneBaseGlyphs)r(   r  r&  r&   ZallowLayerReuses   &&&&&r*   r+   ZCOLRVariationMerger.__init__1  sT      h=   5##2#4D $r,   c                s    R V9   d*   R V9   d#   V P                  VR ,          P                  4       \        P                  WW#4       R# )COLRN)expandPaintColrLayersrV   r#  rg   )r(   r&   re   rf   r  r*   rg   ZCOLRVariationMerger.mergeTablesC  s:    Y6T> &&tF|'9'9:##DGr,   c                s    R # r  rh   )r      &r*   <lambda>ZCOLRVariationMerger.<lambda>P  s    4r,   c                s   VP                   pVP                  pR p V! V4      pV! V4      pV'       g"   \        V \	        V4      P
                  VR7      hTp. pV F*  p	\        V	RR4      p V! V4      pVP                  V4       K,  	  \        Wx4      '       g#   \        V \	        V4      P
                  VVR7      hV#   \         d     Li ; i  \         d     Lhi ; i)F)r   rU   r|   Nr   )
r|   
formatEnumZ
ValueErrorr!   r7   r/   r:   r0   r   r    )
r(   rP   rQ   Zvalidatefmtr<  ZokrH   rI   rD   r   r*   checkFormatEnumZ#COLRVariationMerger.checkFormatEnumP  s    jj^^
	S/C #B#D493E3ESQQA!Xt,C o JJsO  (((%c++!	  -  		  s#   B> ,C>CCCCc           
     s   VP                  4        F:  p T P                  W,          V Uu. uF  qDP                  V4      NK  	  up4       K<  	  R# u upi   \         d'   pTP                  P                  R T: R24       h Rp?ii ; i)Z[]N)rB   rN   r;   r"   rO   r0   )r(   rP   rQ   rt   rD   rY   r=   r*   mergeSparseDictZ#COLRVariationMerger.mergeSparseDictn  sl    A  C)@Cq%%(C)@A )@# 1%qz*s(   AAAAB!!BBc                s    V F:  p\        W4      pV Uu. uF  p\        Wd4      NK  	  pp V P                  WW4       K<  	  R# u upi   \         d%   pTP                  P	                  R T 24       h Rp?ii ; i)rJ   N)r:   rN   r"   rO   r0   )	r(   rP   rQ   r2   r1   rU   rS   rW   rY   	   &&&&     r*   
mergeAttrsZCOLRVariationMerger.mergeAttrsv  sp    DC&E69:cdgd)cF:  /	 : $ 4&z*s   AAA7A22A7c                s   V Uu. uF  p\        WC4      NK  	  ppR pVP                  V4      p\        V\        4      '       d"   RpV Uu. uF  qP	                  V4      NK  	  ppV^ ,          p	\
        P                  p
\        V4      '       g   V P                  P                  V4      w  rV'       d   VP                  V	4      p	W3# u upi u upi )FT)r:   ZgetConverterByNamerb   r   ZtoIntr}   NO_VARIATION_INDEXr   r$  r'  ZfromInt)r(   rP   rQ   r1   rS   r)  Zis_fixed_size_floatZconvrD   	baseValuer*  s   &&&&       r*   storeMastersForAttrZ'COLRVariationMerger.storeMastersForAttr  s    9<=,=
 $%%d+dN++"&4ABMqZZ]MMB!!$	&&&& $ 2 2 ? ? NIY/I  ' > Cs   C
Cc                    < V ^8  d   QhRS[ /# r{   Zreturnr   Zformatrp      "r*   __annotate__ COLRVariationMerger.__annotate__  s       r,   c                s   \        V4      pV P                  P                  V4      pVfs   \        \	        V P
                  4      \	        V4      ,
          ^,           4       F9  pV P
                  WD\	        V4      ,            V8X  g   K(  T;V P                  V&   p M	  Vf   \        \	        V4      ^,
          ^ R4       Fd  pV P
                  V) R  VR V 8X  g   K  \	        V P
                  4      V,
          pW0P                  V&   V P
                  P                  WR  4        M	  Vf@   \	        V P
                  4      ;V P                  V&   pV P
                  P                  V4       V# )Nr   )Ztupler2  r;   r   r[   r3  r   )r(   r3  rT   varIndexBaser_   ns   &&    r*   storeVariationIndicesZ)COLRVariationMerger.storeVariationIndices  s9    Ho))--c23t}}-H=AB==X%678C=>>D&&s+l C
 3x=1,a4==!%"15#&t}}#5#9L.:&&s+MM(("6 5 585GGDs#lMM  *r,   c                rF  rG  rH  rI  rJ  r*   rK  rL    s      S r,   c                s4   \         P                  p. pV F4  pV P                  WV4      w  rx\        WV4       VP	                  V4       K6  	  \
        ;QJ d    R  V 4       F  '       g   K   RM	  RM! R  V 4       4      '       d   V P                  V4      pV# )c              3   sF   "   T F  q\         P                  8g  x  K  	  R # 5ir$   )r}   rC  r   r   r*   rF   Z9COLRVariationMerger.mergeVariableAttrs.<locals>.<genexpr>  s     <8aB)))8s   !TF)r}   rC  rE  r   r0   anyrO  )	r(   rP   rQ   r2   rM  r3  r1   rD  r*  rA  r*   mergeVariableAttrsZ&COLRVariationMerger.mergeVariableAttrs  s    ,,D $ 8 84 HICy)OOF# 
 3<8<333<8<<<55h?Lr,   c                s   \        VR R R7       F  pVR,          pVP                  p\        V4      P                  pV! 4       pVP                  P                  VP                  4       VP                  4        VR,          P                  pVP                  e%   V\        WsP                  4      VP                  &   K  \        WsP                  V4       K  	  R# )Tc                 sT    \        \        V R,          P                  4      RR4      RJ# )r   VarTypeNr   )r:   r7   rU   )pathr:  r*   r;  Z?COLRVariationMerger.convertSubTablesToVarType.<locals>.<lambda>  s     T"X^^,i>dJr,   )Z	skip_rootZ	predicateNr   i)r	   rU   r7   rR  r6   ry   ZpopulateDefaultsr   r:   r  r   )ZclsrV   rS  r  ZsubTablevarTypeZnewSubTableZparentr   r*   convertSubTablesToVarTypeZ-COLRVariationMerger.convertSubTablesToVarType  s    "
D bBxxH8n,,G!)K  ''(9(9:((*"X^^Fxx#5@(25#
r,   c                s   V P                   '       g   R# \        4       p. pV P                  P                   EFL  pVP                  .pV'       g   K  VP                  4       pVP                  \        P                  P                  8X  d   KE  VP                  \        P                  P                  8X  d   \        \        WP4      4      p\        V4      pV Ff  p\        V4      V9   d)   \        P                   ! V4      p\        V4      V9  g   Q hVP#                  V4       VP%                  \        V4      4       Kh  	  Wun        \        V4      Vn        MVP+                  V 4      pVP-                  \/        V4      4       EK>  	  \        V4      \        V4      8X  g   Q hW P                   n        \        V4      V P                   n        R# )a  Rebuild LayerList without PaintColrLayers reuse.

Each base paint graph is fully DFS-traversed (with exception of PaintColrGlyph
which are irrelevant for this); any layers referenced via PaintColrLayers are
collected into a new LayerList and duplicated when reuse is detected, to ensure
that all paints are distinct objects at the end of the process.
PaintColrLayers's FirstLayerIndex/NumLayers are updated so that no overlap
is left. Also, any consecutively nested PaintColrLayers are flattened.
The COLR table's LayerList is replaced with the new unique layers.
A side effect is also that any layer from the old LayerList which is not
referenced by any PaintColrLayers is dropped.
N)	LayerListrx   BaseGlyphListBaseGlyphPaintRecordPaintr   r|   r}   PaintFormatZPaintColrGlyphPaintColrLayersrc   _flatten_layersr[   idr   r   r0   r   FirstLayerIndex	NumLayersgetChildrenr   Zreversed
LayerCount)	colrZuniqueLayerIDsZnewLayerListr   ZfrontierpaintZchildrenZfirst_layer_indexZlayers	   &        r*   r9  Z)COLRVariationMerger.expandPaintColrLayers  sW    ~~~%%::C		{H( <<2>>#@#@@\\R^^%C%CC  $OE$@AH(+L(9%!)e96$(MM%$8E#%e9N#BB#B$++E2&**2e95 "* ->)&)(mEO$006H 23- ;0 < C$7777+$'$5!r,   )r7  r6  r5  r3  r2  r4  Nr  ))r8  )r/   ri   rj   rk   r	  r+   rg   r>  r@  rB  rE  rO  rQ  rl   rU  Zstaticmethodr9  rm   rn   ro   rq   r*   r1  r1  &  sk     %$H 2@ <!, :  6 6( ,6 ,6r,   r1  c           
      s2   VP                    Uu/ uF  q3P                  VbK  	  ppV UUu. uF(  qUP                    Uu/ uF  q3P                  VbK  	  upNK*  	  ppp\        VP                  4       4       F<  w  rx T P	                  WH,          V U	u. uF  qP                  V4      NK  	  up	4       K>  	  RV n
        R# u upi u upi u uppi u up	i   \         d9   p
T
P                  P                  R T R24       RT: 2T
P                  R&   h Rp
?
ii ; i)z.BaseGlyphPaintRecord[r?  zbase glyph r  NT)rX  Z	BaseGlyphr\   rB   rN   r;   r"   rO   r0   Zcauser7  )r9   r(   rQ   r   rP   r<   Zmastersr_   r   rD   rY   r   r*   r.   r.     s     *.)B)B
C)B#==#)BC
CORSs!.D.DE.Dss".DEsGS#((*%	sv''B'Qa''BC & "F DES
 (C 	GGNN3A3a89$/u"5AGGJ	sE   B>CCC;CC*CCCD3DDc                 s    V P                   '       g   Q R 4       h\        V P                  4      Vn        V P                  Vn        R# )z-BaseGlyphList must be merged before LayerListN)r7  r[   r5  ra  rY  r   r   r*   r.   r.     s7     !!!R#RR!&--(DODJr,   c              #   s  "   V P                   \        P                  P                  8X  g   Q hV P	                  V4       FE  pVP                   \        P                  P                  8X  d   \        W!4       R j  xL
  KA  Vx  KG  	  R #  L5ir$   )r|   r}   rZ  r[  r`  r\  )Zrootrb  rc  s   && r*   r\  r\  !  sb     ;;"..88888!!$'<<2>>999&u333K	 (3s   A7B9B
:Bc           
      s  a a	 \        \        VS P                  R ,          P                  4      4      p\	        S P
                  4      \	        V4      8X  g   Q h\        \	        V4      4       Uu. uF@  p\        \        W$,          S P
                  V,          R ,          P                  4      4      NKB  	  pp S P                  W54       S P                  e   S P                  P                  T4      p\	        T4      \        8  p\        T\        R7      pT	T 3R lo	T Uu. uF  pS	! T4      NK  	  pp\	        T4      ^8X  dc   T^ ,          P                  \         P"                  P$                  8X  d3   T^ ,          P&                  Tn        T^ ,          P(                  Tn        R# \	        T4      Tn        \	        S P*                  4      Tn        S P*                  P-                  T4       S P                  e2   T'       g(   S P                  P/                  Y1P(                  4       R# R# R# u upi   \         d"   pTP                  P                  R4       h Rp?ii ; iu upi )r8  z.LayersN)rN  c                 s  < \        V \        4      '       d   V  Uu. uF  pS! V4      NK  	  pp\        P                  ! 4       p \	        \        P
                  P                  4      V n        \        V4      V n	        \        SP                  4      V n        SP                  P                  V4       SP                  e&   SP                  P                  W P                  4       V # u upi r$   )rb   rc   r}   rY  r   rZ  r[  r|   r[   r_  r5  r^  r   r6  r   )rc  rs   r5  listToColrLayersr(   s   &  r*   rd  Z0_merge_PaintColrLayers.<locals>.listToColrLayersM  s    eT""3895a&q)5F9HHJEr~~==>EL!&kEO$'$4E!KKv&##/$$((1F1FG :s   C&)rc   r\  r&   rV   r[   r'   r   ra   r"   rO   r0   r6  Z	try_reuser   r   r|   r}   rZ  r[  r_  r^  r5  r   r   )
r(   rP   rQ   Z
out_layersr_   Zmaster_layersesrY   Zis_treers   rd  s
   f&&      @r*   _merge_PaintColrLayersre  *  s    oc499V+<+B+BCDJ tyy>SX%%% s3x A 	_SVTYYq\&%9%?%?@A   

4 '))33J?
 *o ::G!*0JKJ
 0::z!"1%zJ:
:!
1 4 48V8V V
 #1//(m;;J!$++.:& +G  $$Z1D1DE 5<+o   	
y!	> ;s%   .AH*7H/ I/I:IIc                 s  a a
 S P                  WR  4      pV\        P                  P                  J d   \	        S W4       R# VP                  4       pRo
Ve!   \        P                  ! \        V4      V4      o
V
3R lVP                  4        4       pS P                  WV4       S P                  WS
4      pVP                  4        Uu. uF  qwP                  NK  	  ppV\        P                  8g  ;'       g;    \        ;QJ d    V 3R lV 4       F  '       g   K   RM	  RM! V 3R lV 4       4      p	V	'       d@   S
'       d   Wan        V'       d   S P#                  V4       Vf   Q h\%        V4      Vn        R# R# u upi )c                 s,    V P                  4       '       * # r$   )Zis_variable)r=  r:  r*   r;  Zmerge.<locals>.<lambda>p  s    COO<M8Mr,   Nc              3   `   <"   T F#  qP                   S9  g   K  VP                   x  K%  	  R # 5ir$   r  rC   r   varAttrsrE   r*   rF   ru   {  "     R#7a66;Q6166#7   ..c              3   T   <"   T F  p\        V4      SP                  9   x  K  	  R # 5ir$   r]  r4  )rC   rV   r9   rE   r*   rF   ru     s#      >5>E5	V'''Y   %(TFrh   )r>  r}   rZ  r[  re  Zas_variabler   getVariableAttrsr7   getConvertersrB  rQ  ZiterSubTablesrU   rC  rP  VarIndexBaserU  r   r|   )r9   r(   rQ   r=  Z	varFormatstaticAttrsrM  r  Z	subTablesZ
isVariableri  s   f&&       @r*   r.   r.   n  s?   

 
 ,M
NC
bnn,,,vt1!IH**4:yAR4#5#5#7RK
d-,,TAL$($6$6$89$8b$8I9 !6!66  ## >5>>### >5>> ;J  !-,,T2$$$)n  :s   E<c                 s\  a \        V4      P                  p\        P                  ! V4      oV3R  lVP	                  4        4       pV P                  WV4       V P                  WS4      pV\        P                  8w  d-   WQn	        V P                  P                  \        V4      4       R# R# )c              3   rf  r$   rg  rh  rE   r*   rF   ru     rj  rk  N)r7   rR  r   ro  rp  rB  rQ  r}   rC  rq  r4  r   r]  )r9   r(   rQ   rT  rr  rM  ri  rz   r*   r.   r.     s    4j  G&&w/HR4#5#5#7RK
d-,,TALr,,,(r$x( -r,   c                 sl  a  S P                  WR  VP                  4        4       4       \        ;QJ d)    V 3R lVP                   4       F  '       g   K   RM	  RM! V 3R lVP                   4       4      '       d8   S P	                  V4       S P
                  P                  \        V4      4       R# R# )c              3   r   r$   rg  r   r   r*   rF   ru     s     !G2FQ&&2Fr   c              3   rl  r$   rm  )rC   Zstopr9   rE   r*   rF   ru     s      
End2d8v)))nrn  TFN)rB  rp  rP  	ColorStoprU  r4  r   r]  r   s   f&&r*   r.   r.     sw    
d!G$2D2D2F!GH
s
Ednn
Esss
Ednn
EEE((.r$x( Fr,   Zclipsc                 s(    V P                  W4       R # r$   )r@  r   r   r*   r.   r.     s     4%r,   )NNr$   )F)r   r   )kr	  Zosr   r8   Zoperatorr    ZloggingZfontTools.colorLib.builderr   r   ZfontTools.miscr   ZfontTools.misc.roundToolsr   ZfontTools.misc.treeToolsr   ZfontTools.ttLib.tablesr   r}   r   Z#fontTools.ttLib.tables.otConvertersr   Z!fontTools.ttLib.tables.otTraverser	   Z#fontTools.ttLib.tables.DefaultTabler
   ZfontTools.varLibr   r   r   ZfontTools.varLib.modelsr   r   r   r   r   ZfontTools.varLib.varStorer   Z	functoolsr   ZfontTools.otlLib.builderr   ZfontTools.otlLib.optimize.gposr   r   Z	getLoggerr  Zerrorsr   r   r   r   r   r   r   r   r    r!   r"   Zobjectr#   rr   r9   ZGDEFr.   r   r   r   r   r   r   r~   r   r   r   r   r   r   r   r   ZMarkBasePosZMarkMarkPosr   r   r   r   r   Z
CursivePosr   ZLookupr  Z
CaretValuer  r#  r(  Z	BaseCoordr1  rW  rV  r\  re  rY  ZClipBoxZ	Affine2x3rs  Z	ColorLineZClipListrh   r,   r*   <module>rt     s   
     R ( - 5 1 3 > < < 6 6 S S 7  3
 12   rV rp	V 	 rww0# 1#2"J v))*# +# ryy!# "#$6 r||$: %:z rzz"24 #24j,B86K\&3R rzz"( #(VS)l r~~&T 'T r~~&T 'T22<*0 r}}%4 &4. r))*# +# ryy!a  "a R>n > & ' 		" # **+' ,'2	1N 	1 bmm$ %* bii  !: f(()< *<>%!n %!P2 %' &' &' '' 		") #) **+6 ,6 \6/ \6~ B,,-" ."" BLL) *AFH RXXrzz23%% 4%%P R\\2<<89) :)  BLL)) *) BKK1& 2&r,   