+
    f7iŎ  c                   s.   R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHt ^ RIHt ]P"                  ! R4      t. ROtR tR	 t ! R
 R]P,                  4      t ! R R4      tRR lt]R8X  d   ^ RIt]P8                  ! ]! 4       4       R# R# )u6  MS VOLT ``.vtp`` to AFDKO ``.fea`` OpenType Layout converter.

Usage
-----

To convert a VTP project file:


.. code-block:: sh

    $ fonttools voltLib.voltToFea input.vtp output.fea

It is also possible convert font files with `TSIV` table (as saved from Volt),
in this case the glyph names used in the Volt project will be mapped to the
actual glyph names in the font files when written to the feature file:

.. code-block:: sh

    $ fonttools voltLib.voltToFea input.ttf output.fea

The ``--quiet`` option can be used to suppress warnings.

The ``--traceback`` can be used to get Python traceback in case of exceptions,
instead of suppressing the traceback.


Limitations
-----------

* Not all VOLT features are supported, the script will error if it it
  encounters something it does not understand. Please report an issue if this
  happens.
* AFDKO feature file syntax for mark positioning is awkward and does not allow
  setting the mark coverage. It also defines mark anchors globally, as a result
  some mark positioning lookups might cover many marks than what was in the VOLT
  file. This should not be an issue in practice, but if it is then the only way
  is to modify the VOLT file or the generated feature file manually to use unique
  mark anchors for each lookup.
* VOLT allows subtable breaks in any lookup type, but AFDKO feature file
  implementations vary in their support; currently AFDKO’s makeOTF supports
  subtable breaks in pair positioning lookups only, while FontTools’ feaLib
  support it for most substitution lookups and only some positioning lookups.
N)StringIO)TopologicalSorter)ast)TTFont
TTLibError)ParserzfontTools.voltLib.voltToFeac                 s   . p\        V \        \        34      '       d&   V  F  pVP                  \	        V4      4       K  	  V# \        V R 4      '       d'   VP                  \	        V P                  4      4       V# VP                  V 4       V# )enum)
isinstanceZtupleZlistextend_flatten_groupZhasattrr   append)groupZretitems   &  B/usr/lib64/python3.14/site-packages/fontTools/voltLib/voltToFea.pyr	   r	   =   sx    
C%%''DJJ~d+,  J	 
		

>%**-. J 	

5J    c                 s   V  Uu/ uF  qP                   P                  4       VbK  	  ppV  UUu/ uFq  pVP                   P                  4       \        V4       Uu. uF?  p\        V\        P
                  4      '       g   K%  VP                  P                  4       NKA  	  upbKs  	  ppp\        V4      pVP                  4        Uu. uF  qbV,          NK  	  up# u upi u upi u uppi u upi N)	namelowerr	   r   VAst	GroupNamer   r   Zstatic_order)groupsr   Z	group_mapxZgraphZsorterr   s   &      r   sort_groupsr   L   s    8>?u!!#U*I?  E 	

#E*
*!T^^, AGGMMO*
 	

  
  u%F(.(;(;(=>(=dOO(=>> @
 ?s(   #C+C$"CCC$C*C$c                   s6   a a ] tR t^Zt oRV 3R lltRtVtV ;t# )Lookupc                s6   < \         SV `  WV4       . V n        R # r   )Zsuper__init__chained)selfr   use_extensionlocation	__class__s   &&&&r   r   ZLookup.__init__[   s    h7r   )r   )FN)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell__Z__classcell__)r   __classdict__s   @@r   r   r   Z   s      r   r   c                   s  a  ] tR t^`t o ]P
                  ! R4      t]P
                  ! R4      tRR ltR t	R t
RR ltR tRR	 ltR
 tR tR tRR ltR tR tR tR tRR ltR tR tR tR tR tR tR tR tRtV t R# )	VoltToFeaz[^A-Za-z_0-9.]z[^A-Za-z_0-9.\-]Nc                sV   \        V\        P                  4      '       d   VR uV n        V n        MR VuV n        V n        W n        / V n        R V n        / V n        / V n	        / V n
        / V n        \        4       V n        / V n        / V n        / V n        / V n        / V n        / V n        R # r   )r   r   ZVoltFile_doc_file_or_path_font
_glyph_map_glyph_order_gdef_glyphclasses	_features_lookupsset_marks
_ligatures_markclasses_anchors	_settings_lookup_names_class_names)r   file_or_pathfont   &&&r   r   ZVoltToFea.__init__d   s    lDMM22,8$)DIt),0,)DIt)
 
er   c                    WP                   9  dT   V P                  P                  R V4      pW P                   P                  4       9   d   VR ,          pK)  W P                   V&   V P                   V,          # _)r5   _NOT_LOOKUP_NAME_REsubvaluesr   r   Zres   && r   _lookupNameZVoltToFea._lookupName~   sc    )))**..sD9C++2244s
'*t$!!$''r   c                r:   r;   )r6   _NOT_CLASS_NAME_REr>   r?   r@   rA   r   
_classNameZVoltToFea._className   sc    ((())--c48C**1133s
&)d#  &&r   c                sz   VP                    F6  p\        V\        P                  4      '       g   K%  V P	                  V4       K8  	  VP                    Uu. uF'  p\        V\        P
                  4      '       g   K%  VNK)  	  pp\        V4       F  pV P                  V4       K  	  VP                    EF  p\        V\        P                  4      '       d   R V9   d   V P                  V4       K>  K@  \        V\        P                  4      '       d   V P                  WC4       Ks  \        V\        P                  \        P
                  34      '       d   K  \        V\        P                  4      '       d   V P                  V4       K  \        V\        P                  4      '       d   K  \        V4      h	  VP                    Fl  p\        V\        P                  4      '       g   K%  VP                   '       d
   R V9  d   K@  VP"                  '       d
   RV9  d   K[  V P%                  V4       Kn  	  R# u upi )GPOSGSUBN)
statementsr   r   ZGlyphDefinition_glyphDefinitionZGroupDefinitionr   _groupDefinitionZAnchorDefinition_anchorDefinitionZSettingDefinition_settingDefinitionZScriptDefinition_scriptDefinitionZLookupDefinitionNotImplementedErrorposr>   _lookupDefinition)r   doctablesignore_unsupported_settings	statementsr   r   s   &&&&    r   _collectStatementsZVoltToFea._collectStatements   s   I)T%9%9::%%i0 ( !^^S^z!T=Q=Q/R!!^S (E!!%( ) I)T%:%:;;V#**95 $It'='=>>''	OI(<(<d>R>R'STTIt'<'<==&&y1	4+@+@AA))44 ( I)T%:%:;;===V6%9===V6%9&&y1 (' Ts   "H8<H8c           
     sZ   \         P                  ! 4       pVP                  pV P                  '       dO   VP	                  \         P
                  ! R 4      4       VP                  V P                  P                  4       4       V P                  '       d_   VP	                  \         P
                  ! R4      4       VP                  R \        V P                  P                  4       4       4       4       V P                  '       ds   VP	                  \         P
                  ! R4      4       V P                  P                  4        F/  pVP                  VP                  4       VP	                  V4       K1  	  V P                  P                  4       pV F  pWV,          pV F~  pWx,          p	V	 F=  p
W,           Uu. uF%  qP                  4       V P                  9   g   K#  VNK'  	  upW&   K?  	  V	P                  4        UUu/ uF  w  rV'       g   K  WbK  	  uppWx&   K  	  VP                  4        UUu/ uF  w  rV'       g   K  WbK  	  uppWV&   K  	  VP                  4        UUu/ uF  w  rV'       g   K  WbK  	  pppV'       Ed   VP	                  \         P
                  ! R4      4       VP                  4        EF  w  rg\         P                   ! V4      p\        VR R7      pVR8X  d/   \#        V4      ^8  d   \$        P'                  R4       VR	,          pV EFF  pVR8w  d0   VP                  P	                  \         P(                  ! V4      4       \        Wx,          R
 R7      pVR8X  d/   \#        V4      ^8  d   \$        P'                  R4       VR	,          pV F  p
VR8w  dL   V
R8X  d   RMRpVP                  P	                  \         P*                  ! V
P-                  ^4      VR7      4       Wx,          V
,           FU  pV P                  VP                  4       ,          p\         P.                  ! V4      pVP                  P	                  V4       KW  	  K  	  EKI  	  VP	                  V4       EK  	  V P0                  '       Ed    RV9   d   . pR F  pVV P0                  9   dx   RVP                  4       ,           p\         P2                  ! VV P0                  V,          4      pVP	                  V4       VP	                  \         P4                  ! V4      4       K  VP	                  R4       K  	  \         P6                  ! R4      pVP                  P	                  \         P8                  ! V!  4       VP	                  V4       V# u upi u uppi u uppi u uppi )z# Glyph classesz
# Mark classesc              3   s2   "   T F  q^,          x  K  	  R# 5i)   N ).0Zc   & r   	<genexpr>Z.VoltToFea._buildFeatureFile.<locals>.<genexpr>   s     N,Mqdd,Ms   z

# Lookupsz
# Featuresc                     V R 8X  d   ^ # ^# )ZDFLTrW   Zk   &r   <lambda>-VoltToFea._buildFeatureFile.<locals>.<lambda>   s    fA<SRS<Sr   )keyZaaltzvFEA syntax does not allow script statements in 'aalt' feature, so only lookups from the first script will be included.:NrV   Nc                 r[   )dfltrW   r\   r]   r   r^   r_      s    1;a&=A&=r   zzFEA syntax does not allow language statements in 'aalt' feature, so only lookups from the first language will be included.ra   TF)include_defaultGDEFZGDEF_NBASEMARKLIGATUREZ	COMPONENT)r   ZFeatureFilerG   r,   r
   Commentr   r?   r2   Zsorteditemsr.   r   r-   Zcopyr   ZFeatureBlocklenlogwarningZScriptStatementZLanguageStatementZljustZLookupReferenceStatementr+   GlyphClassDefinitionGlyphClassNameZ
TableBlockZGlyphClassDefStatement)r   rQ   rP   rG   lookupfeaturesZfeature_tagZscriptsZ
script_taglangsZlanguage_taglZtrT   ZffeatureZscript_tagsZlanguage_tagsrb   r   Z	lookuprefZclasses	classname
glyphclassZgdefs   &&                       r   _buildFeatureFileZVoltToFea._buildFeatureFile   sl   oo^^
ckk*;<=d00779:ckk*<=>NF43D3D3J3J3L,MNN===ckk-89--..0!!&..1!!&) 1
 >>&&(#K+G%
+$)L#(#6+#6a'')t}}:T#6+E' %* 9>&Ktqt&K# & 7>mmo$KodaTQTo$KH! $ &.^^%5;%5TQDAD%5;8ckk,78(0(8$**;7$W2ST&(S-=-AKKR #.b/K"-J"f,**11#2E2Ej2QR$*+=%M #f,]1Ca1GX )6b(9(5&&06Bf6LdRWO#..55 # 5 5$0$6$6q$94C!" %,$7$E$ED%)]]4::<%@F(+(D(DV(LI#..55i@ %F )6 #.4 !!'*G )9J :::&F*GA4::% '$**, 6I!$!9!9)TZZPTEU!VJ%%j1NN3#5#5j#ABNN4( B >>&)DOO""3#=#=w#GHd#
{+ 'L$K;s0   9 V
V
 V
V
4V!V!(V'9V'c                sZ   V P                   f)   \        V P                  4      P                  4       V n         V P                   pVf   \        pV P
                  e    V P
                  P                  4       V n        V P                  W1V4       V P                  V4      pVP                  4       # r   )r&   
VoltParserr'   ZparseTABLESr(   ZgetGlyphOrderr*   rU   rv   ZasFea)r   rQ   rR   rP   fea   &&&  r   convertZVoltToFea.convert
  s    99"4#5#56<<>DIii>F::! $

 8 8 :D-HI$$V,yy{r   c                s     VP                   p\        P                  ! V P                  P                  W"4      4      #   \         d    Tp L>i ; ir   )glyphAttributeErrorr   	GlyphNamer)   get)r   r|   r   rA   r   
_glyphNameZVoltToFea._glyphName  sF    	;;D }}T__00<==  	D	s   = AAc                s     VP                   p\        P                  ! V P                  VP                  4       ,          4      #   \         d    Tp LDi ; ir   )r   r}   r   rn   r,   r   )r   r   r   rA   r   
_groupNameZVoltToFea._groupName  sJ    	;;D !!$"4"4TZZ\"BCC  	D	s   A AAc                s    VP                  4        Uu. uF<  p\        V\        \        P                  34      '       d   V P                  V4      MTNK>  	  up# u upi r   )glyphSetr   strr   r~   r   )r   r   r   rA   r   	_glyphSetZVoltToFea._glyphSet&  sR     ]]_
$ $.a#t~~1F#G#GT__QQN$
 	
 
s   AAc                s"   . pV EF  p\        V\        P                  4      '       d#   VP                  V P	                  V4      4       KF  \        V\        P
                  4      '       d#   VP                  V P                  V4      4       K  \        V\        P                  4      '       da   V P                  VP                  R R7      pV'       d   VP                  V4       K  VP                  \        P                  ! V4      4       EK  \        V\        P                  4      '       dV   V P                  V4      pV'       d   VP                  V4       EKU  VP                  \        P                  ! V4      4       EK}  \        V4      h	  V# Tflatten)r   r   r~   r
   r   r   r   ZEnum	_coverager   r   r   
GlyphClassZRanger   rM   )r   coverager   ri   r   rz   r   r   ZVoltToFea._coverage,  s    D$//T__T23D$..11T__T23D$)),,~~dii~>LL&LL!56D$**--~~d+LL&LL!56)$//% & r   c                s    . pV FW  pV P                  VR R7      p\        V4      ^8  d   \        P                  ! V4      pM	V^ ,          pVP	                  V4       KY  	  V# r   )r   rj   r   r   r
   )r   contextZoutr   r      &&   r   _contextZVoltToFea._contextC  sY    D~~dD~9H8}q >>(3#A;JJx   
r   c                s.   V P                  VP                  4      pV P                  VP                  P                  R R7      p\        P
                  ! V4      p\        P                  ! W$4      pWPP                  VP                  P                  4       &   R# )Tr   N)	rD   r   r   r   r   r   rm   r,   r   )r   r   r   glyphsru   Zclassdefs   &&    r   rI   ZVoltToFea._groupDefinitionN  sg    uzz*

>^^F+
++D=195::++-.r   c                s    V P                   VP                  ,          V P                  VP                  &   VP
                  R9   d   VP
                  V P                  9  d-   \        P                  ! 4       V P                  VP
                  &   V P                  VP
                  ,          P                  P                  V P                  VP                  4      4       VP
                  R8X  d(   V P                  P                  VP                  4       R# VP
                  R8X  d&   VP                  V P                  VP                  &   R# R#   \         d     EL%i ; i)re   rf   rg   Nrd   )r*   Zidr)   r   Z	TypeErrortyper+   r   r   r   r
   r   r0   Zadd
componentsr1   )r   r|   s   &&r   rH   ZVoltToFea._glyphDefinitionU  s    	*.*;*;EHH*EDOOEJJ' ::BBzz+),)9

5::&JJuzz"))001LM::KKOOEJJ'ZZ:%*/*:*:DOOEJJ' &  		s   4E EEc                s   VP                   pVP                   F  pVP                   pVP                   F  pVP                   Uu/ uF  qfP	                  R 4      ^ ,          RbK  	  ppVP                   pWP
                  9  d   / V P
                  V&   W P
                  V,          9  d   / V P
                  V,          V&   VP                  4       V P
                  V,          V,          V&   K  	  K  	  R# u upi )\TN)Ztagrq   rp   lookupssplitr-   Zkeys)	r   ZscriptZstagZlangZltagrs   rr   r   Zftags	   &&       r   rL   ZVoltToFea._scriptDefinitione  s    zzLLD88D==;B??K?a774=+T1?K{{~~-+-DNN4(~~d3313DNN4(.3:<<>t$T*40 ) ! Ls   !C5c                s    VP                   P                  R 4      '       d&   VP                  V P                  VP                   &   R# V'       g%   \        P                  RVP                    24       R# R# )Z	COMPILER_zUnsupported setting ignored: N)r   
startswithZvaluer4   rk   rl   )r   ZsettingZignore_unsupportedr9   r   rK   ZVoltToFea._settingDefinitions  sM    <<"";//+2==DNN7<<(#KK7~FG $r   c           	     s   Vw  r#rErgT;'       d    VP                  4       ;'       g    R pT;'       d    VP                  4       ;'       g    R p	T;'       d    VP                  4       ;'       g    R p
\        P                  ! VVVV	V
VR7      # )N)Z
xPlacementZ
yPlacementZxAdvanceZ
xPlaDeviceZ
yPlaDeviceZ
xAdvDevice)ri   r   ZValueRecord)r   
adjustmentadvdxdyadv_adjust_bydx_adjust_bydy_adjust_byZ
adv_device	dx_device	dy_devices   &&         r   _adjustmentZVoltToFea._adjustmenty  s    AK>L"<<}':':'<DD
 99\%7%7%9AAT	 99\%7%7%9AAT	  !
 	
r   c                s"   Vw  r#rErgT;'       d    VP                  4       ;'       g    R pT;'       d    VP                  4       ;'       g    R p	\        P                  ! T;'       g    ^ T;'       g    ^ T;'       g    R T	;'       g    R R7      # )N)ZxDeviceTableZyDeviceTable)ri   r   ZAnchor)
r   r   r   r   r   r   r   r   r   r   s
   &&        r   _anchorZVoltToFea._anchor  s    AK>L !99\%7%7%9AAT	 99\%7%7%9AAT	zzGG!GG!"**d"**d	
 	
r   c                s   VP                   pVP                  pV P                  VP                  4      pW0P                  9  d   / V P                  V&   VP                  R 4      '       d'   VR,          VR,          P                  4       ,           pMVP                  4       pW P                  V,          9  d   / V P                  V,          V&   W@P                  V,          V,          VP                  &   R# )MARK_:N   N:r   NNN)r   Z
glyph_namer   rN   r3   r   r   	component)r   Z	anchordef
anchorname	glyphnameanchorr   r   rJ   ZVoltToFea._anchorDefinition  s    ^^
((	imm,MM)')DMM)$  ))#B*R.*>*>*@@J#))+J]]95535DMM)$Z0DJi ,Y-@-@Ar   c                s  a  VP                   pVP                  p\        V\        P                  4      '       Ed   VP
                  P                  4        F  w  w  rVw  rxVP                  V^,
          ,          p	VP                  V^,
          ,          p
RpW,            F'  p\        V\        P                  4      '       d   K%  RpK)  	  S P                  V	4      pS P                  V
4      pS P                  V4      pS P                  V4      pVP                  \        P                  ! V^ ,          W^ ,          VVR7      4       K  	  R	# \        V\        P                  4      '       dm   VP                    FZ  w  ppS P                  V4      pS P                  V4      pVP                  \        P"                  ! V^ ,          V3.. . R4      4       K\  	  R	# \        V\        P$                  4      '       Ed   / p\'        4       pVP(                   EF  w  ppS P+                  V RVP,                   24      p\        P.                  ! V4      pVP1                  4       p\'        4       pV F"  pVP3                  VP5                  4       4       K$  	  VP7                  V4      '       g   VP9                  V4       V'       g   K  VP3                  V4       V Fa  pS P;                  V4      pS P<                  V,          RV 2,          ^,          p\        P>                  ! VVV4      p V S P@                  VV3&   Kc  	  VPB                   FR  p!V!P5                  4        F;  p"V"V9  d   . VV"&   VV3VV",          9  g   K!  VV",          P                  VV34       K=  	  KT  	  EK  	  \D        ;QJ d    V 3R lV 4       F  '       d   K   RM	  RM! V 3R lV 4       4      p#\D        ;QJ d    V 3R lV 4       F  '       d   K   RM	  RM! V 3R lV 4       4      p$V EFh  p"^p%V#'       d   S PF                  V",          p%\I        V%4       U&u. uF  p&. NK  	  pp&VV",           F  w  pp\        P.                  ! V4      p\I        ^V%^,           4       Ff  p'V'S P<                  V",          V,          9   g   K$  S P<                  V",          V,          V',          pVV'^,
          ,          P                  VV34       Kh  	  K  	  S P;                  V"4      p!V$'       d    \        PJ                  ! V!V^ ,          4      pM>V#'       d   \        PL                  ! V!V4      pM\        PN                  ! V!V^ ,          4      pVP                  V4       EKk  	  R	# \        V\        PP                  4      '       Ed   . p(VPR                   F4  pV F+  p!V!P5                  4        F  p"V(P                  V"4       K  	  K-  	  K6  	  . p)VPT                   F4  pV F+  p!V!P5                  4        F  p"V)P                  V"4       K  	  K-  	  K6  	  V( F  p"S P;                  V"4      pS P<                  V",          R,          ^,          p*R	p+V"V)9   dB   S P<                  V",          R
,          ^,          p+V)PW                  V)PY                  V"4      4       VP                  \        PZ                  ! VV*V+4      4       K  	  V) F\  p"S P;                  V"4      pS P<                  V",          R
,          ^,          p+VP                  \        PZ                  ! VR	V+4      4       K^  	  R	# \]        V4      hu up&i )rV   FT)
enumeratedZ.r   c              3   @   <"   T F  qSP                   9   x  K  	  R # 5ir   )r1   rX   nr      & r   rZ   (VoltToFea._gposLookup.<locals>.<genexpr>  s     DGq4??2G   c              3   r   r   )r0   r   r   r   rZ   r     s     <Gqt{{*Gr   entryNexit)/rG   rN   r   r   PositionAdjustPairDefinitionadjust_pairri   coverages_1coverages_2r   r   r   r
   r   ZPairPosStatementPositionAdjustSingleDefinitionadjust_singleZSinglePosStatementPositionAttachDefinitionr/   coverage_torD   r   Z	MarkClassr   Zupdater   Z
isdisjointZdifference_updater   r3   ZMarkClassDefinitionr2   r   Zallr1   ZrangeZMarkMarkPosStatementZMarkLigPosStatementZMarkBasePosStatementZPositionAttachCursiveDefinitionZcoverages_enterZcoverages_exitZpopZindexZCursivePosStatementrM   ),r   ro   	fealookuprG   rN   idx1idx2pos1pos2Z
coverage_1Z
coverage_2r   r   glyphs1glyphs2Zrecord1Zrecord2aZbr   ZrecordZanchorsZallmarksr   r   rt   Z	markclassZmarksZmarkr   r|   r   ZmarkdefZbaser   Zis_ligatureZis_markr   r<   r   Zenter_coverageZexit_coverager   r   s,   f&&                                         r   _gposLookupZVoltToFea._gposLookup  s   ))
jjc4<<==.1oo.C.C.E*lt __TAX6
 __TAX6
 #
&33D%dDNN;;%)
 4 ..4..4**40**40 !!((
GQZZ# /F, T@@AA))1*))!,!!**VAY,?+@"b%P	 * T::;;GuH(+$* !OOzl!FKK=,IJ	MM)4	 (--/
 $DLL1 %''11++H5  &!&I OOI6E!]]95j\6JKANF!55iOG@GD%%y)&<=	 "'  LLD $w.,.GDM&	2'$-G#DM00*i1HI	 !0 )C )8P #DGD###DGDDKc<G<ccc<G<<G
!%!6J%*:%67%6%67'.t}}OD) #i 8I%*1j1n%=	$d(;D(AA%)]]4%8%>y%IF!)a-0778KL &> (5 t,33D%(CD 224?D33D%(CD!!$')  * TAABBN//$D $&--d3 !0 % 0 M..$D $%,,T2 !0 % / '-d+G4Q7=(==.v6q9D!%%m&9&9$&?@!!#"9"9%"MN ' &-}}T*6215!!#"9"9%t"LM &
 &c**] 8s   ]c                sD   VP                   pVP                  p\        V\        P                  4      '       d   VP
                  P                  4        F  w  w  rw  rV P                  VP                  V	^,
          ,          4      pV P                  VP                  V
^,
          ,          4      pV^ ,          V^ ,          3pV'       d   \        P                  ! W/V3.4      pM\        P                  ! W/W6V.4      pVP                  V4       K  	  R# \        V\        P                  4      '       d   \        P                  ! 4       .pVP                    F/  w  ppV^ ,          P#                  V P                  VRR7      4       K1  	  V'       d   \        P                  ! W/V3.4      pM\        P                  ! W/W6.4      pVP                  V4       R# \        V\        P$                  4      '       d   \        P                  ! 4       .pVP&                   F/  w  ppV^ ,          P#                  V P                  VRR7      4       K1  	  V'       d   \        P                  ! W/V3.4      pM\        P                  ! W/W6.4      pVP                  V4       R# \)        V4      h)rV   Tr   N)rG   rN   r   r   r   r   ri   r   r   r   r   ZIgnorePosStatementZChainContextPosStatementr
   r   r   r   r   r   r   rM   )r   ro   prefixsuffixignorer   r   rG   rN   r   r   r   r   r   r   r   rS   r   r<   r   s   &&&&&&&             r   _gposContextLookupZVoltToFea._gposContextLookup+  s   ))
jjc4<<==.1oo.C.C.E*lt..)BC..)BC "!*gaj1 # 6 68P7Q RI # < <'0B!I !!), /F T@@AAnn&'F))1q	  4!@A * 22VV4L3MN	88FI	 i(T::;;nn&'F"!q	  $!GH  / 22VV4L3MN	88FI	 i(%c**r   c                s&	  a VP                   pVP                  p\        V\        P                  4      '       Edp   / pVP
                  P                  4        F  w  rgV'       d	   V'       g0   VP                  w  rp
\        P                  V R V	 R V
 R24       KD  V P                  V4      pV P                  V4      p\        V^ ,          P                  4       V^ ,          P                  4       4       FV  w  rVP                  \        V P                  V4      4      . 4      P!                  \        V P                  V4      4      4       KX  	  K  	  VP                  4        FC  w  r\"        P$                  ! . V. \"        P&                  ! V4      4      pVP!                  V4       KE  	  R# VP
                  P                  4        EF  w  rgV'       d	   V'       g0   VP                  w  rp
\        P                  V R V	 R V
 R24       KE  V P                  V4      pV P                  V4      p\        V\        P(                  4      '       d+   VP!                  \"        P*                  ! W. . R4      4       K  \        V\        P,                  4      '       d   K  \        V\        P.                  4      '       d3   VP!                  \"        P0                  ! . V^ ,          . V4      4       EK%  \        V\        P2                  4      '       Edl   \"        P4                  ! . V. V^ ,          R4      p\7        R V 4       4      oS^8  Ed   V Uu. uF  pVP                  4       NK  	  ppV Uu. uF&  p\9        V4      ^8X  d   V^ ,          .S,          MTNK(  	  ppV^ ,          P                  4       p\9        V4      ^8X  d   V^ ,          .S,          pVP!                  \"        P:                  ! RV 24      4       \        . VOVN5!   FV  pV Uu. uF  pV P                  V4      NK  	  ppVP!                  \"        P4                  ! . VRR . VR,          R4      4       KX  	  EK  VP!                  V4       EK  \=        V4      h	  R# u upi u upi u upi ):: Ignoring empty substitutionNFc              3   sT   "   T F  p\        VP                  4       4      x  K   	  R # 5ir   )rj   r   )rX   r   rY   r   rZ   Z(VoltToFea._gsubLookup.<locals>.<genexpr>  s     :6aAJJL))6s   &(# i)rG   r>   r   r   SubstitutionAlternateDefinitionmappingri   r   rk   rl   r   Zzipr   Z
setdefaultr   r   r
   r   ZAlternateSubstStatementr   SubstitutionSingleDefinitionZSingleSubstStatement+SubstitutionReverseChainingSingleDefinitionSubstitutionMultipleDefinitionZMultipleSubstStatementSubstitutionLigatureDefinitionZLigatureSubstStatementZmaxrj   rh   rM   )r   ro   r   rG   r>   Z
alternatesr`   valpathlinecolumnr   replacementsZ	src_glyphZ
repl_glyphr|   rS   r   ZreplacementZzippedr   s   &&&                 @r   _gsubLookupZVoltToFea._gsubLookupY  s   ))
jj
 c4??@@JKK--/#),&DKK4&$q8U VW,#~~c2-01I&&(,q/*B*B*D.)I ))#dooi.H*I2NUUDOOJ78. 0 (2'7'7'9#77r3>>,#?	 !!),	 (:
 ))+HCc%(\\"FtfAdV1VH4QRS^^C(F>>#.L#t@@AA !!,,V2r5Q C!Q!QRRC!D!DEE!!..r6!9b,O C!D!DEE66LOU	 :6::q5 5;;FqajjlFF;JPQ&QSVq[!vza?&FQ #/q/":":"<K;'1,'21~&6&: %%ckkByk2B&CD"%";v";{";>D!Ef$//!"4f!E"))66 "F3BKVBZ #< %%i0)#..{ ,F <Q  "Fs   	R(,R	Rc           	     s   VP                   pVP                  p\        V\        P                  4      '       d   VP
                  P                  4        F  w  rV	'       d	   V
'       g0   VP                  w  rp\        P                  V R V R V R24       KD  V P                  V	4      pV P                  V
4      pVP                  \        P                  ! W#W4      4       K  	  . Vn        R# \        V\        P                  \        P                   \        P"                  \        P$                  34      '       g   \'        \)        V4      4      h. pVP
                  P                  4        Ff  w  rV	'       d	   V
'       g0   VP                  w  rp\        P                  V R V R V R24       KD  VP+                  V P                  V	RR7      4       Kh  	  \-        V4      ^8  d   \        P.                  ! V4      .pV'       d+   VP                  \        P0                  ! W.V3.4      4       R# VP                  \        P2                  ! W.W6.4      4       R# )r   r   NTr   )rG   r>   r   r   r   r   ri   r   rk   rl   r   r
   r   Z ReverseChainSingleSubstStatementr   r   r   r   r   rM   r   r   rj   r   ZIgnoreSubstStatementZChainContextSubstStatement)r   ro   r   r   r   r   r   rG   r>   r`   r   r   r   r   r   r   s   &&&&&&&         r   _gsubContextLookupZVoltToFea._gsubContextLookup  s   ))
jjc4KKLLKK--/#),&DKK4&$q8U VW,#~~c2!!88 0 !#I11333344	
 
 &d3i00))+HCc%(\\"FtfAdV1VH4QRSMM$..d.;< , v;?nnV,-Fc668P7QRS..vvyQr   c           	     s0
   R pR p^ pVP                   R8X  d
   V^,          pVP                  '       g
   V^,          pVP                  '       g   V^,          pMe\        VP                  \        4      '       d   V P                  VP                  4      pM)VP                  e   V P                  VP                  4      pR pV'       g	   Vf   Ve   \        P                  ! WBV4      pRpV P                  P                  R4      '       d   RpRVP                  9   Edj   VP                  P                  R4      ^ ,          pVP                  4       V P                  9  d}   \        V P!                  V4      VR7      pVe   VP"                  P%                  V4       VP"                  P%                  \        P&                  ! RVP                  ,           4      4       MV P                  VP                  4       ,          pVP"                  P%                  \        P(                  ! 4       4       VP"                  P%                  \        P&                  ! RVP                  ,           4      4       WP                  VP                  4       &   Mk\        V P!                  VP                  4      VR7      pVe   VP"                  P%                  V4       WP                  VP                  P                  4       &   VP*                  eA   VP"                  P%                  \        P&                  ! RVP*                  ,           4      4       . p	VP,                   F  p
V P/                  V
P0                  4      pV P/                  V
P2                  4      pV
P4                  R8H  pV	P%                  WV.4       V'       g   Ke  \7        VP,                  4      ^8X  g   K  V	P%                  . . R.4       K  	  V	'       d   \        P8                  ! V P!                  VP                  R	,           4      VR7      pVP:                  P%                  V4       VP<                  e   V P?                  W4       MVP@                  e   V PC                  W4       V	 FL  w  rpVP<                  e   V PE                  WWW4       K)  VP@                  f   K9  V PG                  WWW4       KN  	  R # VP<                  e   V P?                  W4       R # VP@                  e   V PC                  W4       R # R # )
NZRTLFZCOMPILER_USEEXTENSIONLOOKUPSTr   )r   r   ZEXCEPT_CONTEXTz chained)$Z	directionZprocess_baseZprocess_marksr   r   r   Zmark_glyph_setr   ZLookupFlagStatementr4   r   r   r   r   r.   r   rB   rG   r
   rh   ZSubtableStatementZcommentsr   r   ZleftZrightZex_or_inrj   LookupBlockr   r>   r   rN   r   r   r   )r   ro   Zmark_attachementZmark_filteringZflagsZlookupflagsr   r   r   Zcontextsr   r   r   r   r   s   &&             r   rO   ZVoltToFea._lookupDefinition  s   u$QJE"""QJE ###QJE,,c22#v/C/CD"".!__V-B-BCN$0N4N11K >><== M6;; ;;$$T*1-Dzz|4==0"$$T*"/	 *((//<$$++CKKv{{8J,KL MM$**,7	$$++C,A,A,CD$$++CKKv{{8J,KL*3MM$**,'  -+I &$$++K81:MM&++++-.??&  ''D6??4J(KL~~G]]7<<0F]]7==1F%%)99FOOVV45 v#fnn-2R0 & oo  z!9:+G $$W-zz%  1'  1*2&::)++	 ZZ+++	 +3 zz%  3'  3 (r   )r3   r6   r&   r-   r'   r(   r+   r)   r*   r,   r1   r5   r.   r2   r0   r4   r   )F)NF)!r   r   r    r!   reZcompiler=   rC   r   rB   rD   rU   rv   r{   r   r   r   r   r   rI   rH   rL   rK   r   r   rJ   r   r   r   r   rO   r"   r#   )r$   s   @r   r%   r%   `   s     **%67$784('"2HVp>D
.	:; BH
 
KC+J,+\]/~0d]4 ]4r   r%   c           
     s   ^ RI p^ RIHp ^ RIHp VP                  R\        P                  R7      pVP                  RRVRR	7       VP                  R
RV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7       VP                  V 4      pT! VP                  '       d   RMRR7       VP                  pRp \        V4      pRV9   d-   \        VR,          P                  P!                  R4      4      pM\"        P%                  R4       ^# \)        Wg4      p VP+                  VP,                  4      p	\7        TP8                  R%4      ;_uu_ 4       pTP;                  T	4       RRR4       R#   \&         d     Lni ; i  \.         d   p
TP0                  '       d   h \3        T
P4                  ^ ,          R R4      pR!T
 R"2pT'       d'   Tw  rp\"        P%                  T R#T R#T R$T 24       M\"        P%                  T4        Rp
?
^# Rp
?
ii ; i  + '       g   i     R# ; i)&z'Convert MS VOLT to AFDKO feature files.N)Path)configLoggerzfonttools voltLib.voltToFea)ZdescriptioninputZINPUTzinput font/VTP file to process)Zmetavarr   helpfeaturefileZOUTPUTzoutput feature filez-tz--tabler
   rQ   z:List of tables to write, by default all tables are written)actionZchoicesZdestr   z-qz--quietZ
store_truezSuppress non-error messages)r   r   z--tracebacku   Don’t catch exceptionsZERRORZINFO)ZlevelZTSIVzutf-8z6"TSIV" table is missing, font was not saved from VOLT?r   Z"z" is not supportedr   z: Zw)argparseZpathlibr   Z	fontToolsr   ZArgumentParsermain__doc__Zadd_argumentrx   Z
parse_argsZquietr   r   r    ZdataZdecoderk   Zerrorr   r%   r{   rQ   rM   Z	tracebackZgetattrargsZopenr   Zwrite)r   r   r   r   ZparserZoptionsr7   r8   Z	converterry   Zer   Zmessager   r   r   Zfeafiles   &                r   r   r   J  s7    &$$%4<< % F t2R   xd9N   I   i3P   l1K   %G7===f>==LDl#T>#DL$5$5$<$<W$EFLIINO ,-I/ 
g!!3	'	'7c 
(	'#    
166!9j$7aS*+!)DIIavQvhb	:;IIg
 
(	'	's=   =F F >F$ 7H7F! F!$H4/A:H//H47I	Z__main__)rc   rF   rE   r   )r   Zloggingr   Zior    Zgraphlibr   ZfontTools.feaLibr   ZfontTools.ttLibr   r   ZfontTools.voltLibr   ZfontTools.voltLib.parserr   rw   Z	getLoggerrk   rx   r	   r   r   r   r%   r   r   Zsysr   rW   r   r   <module>r      s   +Z  	  &   . ) 956	!	?S__ g4 g4T?D zHHTV r   