ó
    oñ:iDf  ã                   ó  • S r SSKJr  SSKJr  SSKJr  SSKJr	  SSK
Jr  SSKJrJr  SSKJr  S	S
KJrJr  S%S jrS rS rS rS rS rS%S jrS rS r " S S\5      r\R=                  \	R>                  S5      S 5       r \R=                  \	RB                  \	RD                  4S5      S 5       r S&S jr#S r$S r%S r&S r'S r(S r)S  r*S! r+S" r,\-S#:X  a4  SS$K.r.SS$K/r/\/R`                  " \.Rb                  " 5       Rd                  5        g$g$)'zºModule to build FeatureVariation tables:
https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#featurevariations-table

NOTE: The API is experimental and subject to change.
é    )Úhashdict©Ú	bit_count)ÚnewTable)ÚotTables)Ú	TTVisitor)ÚbuildLookupÚbuildSingleSubstSubtable)ÚOrderedDicté   )ÚVarLibErrorÚVarLibValidationErrorc           	      óÂ  • [        U[        5      (       a  U/O
[        U5      nSU;  =(       d    [        U5      S:„  n[	        [        U R                  5       5      US9  [        U5      n[        U5      u  pSU ;  a  [        5       U S'   O<[        U S   R                  5      R                  U5      nU(       a  [        SU 35      e[        U S   R                  Xd5      n/ n	U H*  u  p¥U	R                  X¥ Vs/ s H  o¸U   PM	     sn45        M,     [!        X S   R                  X“5        U R#                  S5      =nb  [%        SUR&                  5      Ul        ggs  snf )aó  Add conditional substitutions to a Variable Font.

The `conditionalSubstitutions` argument is a list of (Region, Substitutions)
tuples.

A Region is a list of Boxes. A Box is a dict mapping axisTags to
(minValue, maxValue) tuples. Irrelevant axes may be omitted and they are
interpretted as extending to end of axis in each direction.  A Box represents
an orthogonal 'rectangular' subset of an N-dimensional design space.
A Region represents a more complex subset of an N-dimensional design space,
ie. the union of all the Boxes in the Region.
For efficiency, Boxes within a Region should ideally not overlap, but
functionality is not compromised if they do.

The minimum and maximum values are expressed in normalized coordinates.

A Substitution is a dict mapping source glyph names to substitute glyph names.

Example:

# >>> f = TTFont(srcPath)
# >>> condSubst = [
# ...     # A list of (Region, Substitution) tuples.
# ...     ([{"wdth": (0.5, 1.0)}], {"cent": "cent.rvrn"}),
# ...     ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
# ... ]
# >>> addFeatureVariations(f, condSubst)
# >>> f.save(dstPath)

The `featureTag` parameter takes either a str or a iterable of str (the single str
is kept for backwards compatibility), and defines which feature(s) will be
associated with the feature variations.
Note, if this is "rvrn", then the substitution lookup will be inserted at the
beginning of the lookup list so that it is processed before others, otherwise
for any other feature tags it will be appended last.
Úrvrnr   )Ú
glyphNamesÚsubstitutionsÚGSUBz4FeatureVariations already exist for feature tag(s): zOS/2N)Ú
isinstanceÚstrÚsortedÚlenÚ_checkSubstitutionGlyphsExistÚsetÚgetGlyphOrderÚoverlayFeatureVariationsÚmakeSubstitutionsHashableÚ	buildGSUBÚ_existingVariableFeaturesÚtableÚintersectionr   ÚbuildSubstitutionLookupsÚappendÚaddFeatureVariationsRawÚgetÚmaxÚusMaxContext)ÚfontÚconditionalSubstitutionsÚ
featureTagÚfeatureTagsÚprocessLastr   ÚallSubstitutionsÚexistingTagsÚ	lookupMapÚconditionsAndLookupsÚconditionSetÚsÚos2s                Ú_/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/fontTools/varLib/featureVars.pyÚaddFeatureVariationsr4      sn  € ôN #-¨Z¼×"=Ñ"=�:‘,Ä6È*ÓCU€KØ Ñ+×C¬s°;Ó/?À!Ñ/C€Kä!Ü�t×)Ñ)Ó+Ó,Ø.òô
 -Ð-EÓF€Mô 2KØó2Ñ.Ðð �TÓÜ “{ˆˆVŠä0°°f±×1CÑ1CÓD×QÑQØó
ˆö ÜØFÀ|ÀnÐUóð ô
 )ØˆV‰×ÑÐ,ó€Ið ÐÛ'?Ñ#ˆØ×#Ñ#Ø°-Ó@²-¨Q aœL±-Ñ@ÐAö	
ñ (@ô
 ˜D v¡,×"4Ñ"4Ð6JÔXð �x‰x˜ÓÐˆÑ,Ü˜q #×"2Ñ"2Ó3ˆÕð -ùò As   Ã8Ec                 óD  • [        5       n[        U S5      (       a„  U R                  bw  U R                  R                  nU R                  R
                   HG  nUR                  R                   H*  nUR                  X$R                     R                  5        M,     MI     U$ )NÚFeatureVariations)r   Úhasattrr6   ÚFeatureListÚFeatureRecordÚFeatureVariationRecordÚFeatureTableSubstitutionÚSubstitutionRecordÚaddÚFeatureIndexÚ
FeatureTag)r   ÚexistingFeatureVarsTagsÚfeaturesÚfvrÚftsrs        r3   r   r   k   s‡   € Ü!›eÐÜˆuÐ)×*Ñ*¨u×/FÑ/FÑ/RØ×$Ñ$×2Ñ2ˆØ×*Ñ*×AÔAˆCØ×4Ñ4×GÔG�Ø'×+Ñ+¨H×5FÑ5FÑ,G×,RÑ,RÖSó Hñ Bð #Ð"ó    c                 óÚ   • [        5       nU H3  u  p4X$R                  5       -  nU[        UR                  5       5      -  nM5     X -
  nU(       a  [        SSR	                  U5       35      eg )NzAMissing glyphs are referenced in conditional substitution rules: z, )r   ÚkeysÚvaluesr   Újoin)r   r   ÚreferencedGlyphNamesÚ_ÚsubstitutionÚmissings         r3   r   r   u   sy   € Ü›5ÐÛ(‰ˆØ× 1Ñ 1Ó 3Ñ3ÐØ¤ L×$7Ñ$7Ó$9Ó :Ñ:Òñ )ð #Ñ/€GÞÜ#ðØ—	‘	˜'Ó"Ð#ð%ó
ð 	
ð rD   c                 ó„  • [        5       nU  H.  u  p#[        U5      nX1;   a  X   R                  U5        M*  X!U'   M0     UR                  5        VVs/ s H  u  pEU[	        U5      4PM     n nnA[        5       n[        U 5       HG  u  p2[        [        S U 5       S S95      nX1;   a  X   R                  U5        M:  [	        U5      X'   MI     [        [        UR                  5       5      5      n A[        5       S44n[        U5      n[        U 5       H›  u  nu  pš[        U5      nSU-  nUR                  5        Hm  u  pÞU	 Hb  n[        Xý5      u  nnUb&  [        U5      nUR                  US5      U-  U-  UU'   Uc  M?  [        U5      nUR                  US5      U-  UU'   Md     Mo     UnM�     / n[        UR                  5       S S9 Hg  u  pÞUS:X  a  M  / nSnU(       a3  US-  (       a  UR                  X   S   5        US-  nUS-  nU(       a  M3  UR                  [	        U5      U45        Mi     U$ s  snnf )a  Compute overlaps between all conditional substitutions.

The `conditionalSubstitutions` argument is a list of (Region, Substitutions)
tuples.

A Region is a list of Boxes. A Box is a dict mapping axisTags to
(minValue, maxValue) tuples. Irrelevant axes may be omitted and they are
interpretted as extending to end of axis in each direction.  A Box represents
an orthogonal 'rectangular' subset of an N-dimensional design space.
A Region represents a more complex subset of an N-dimensional design space,
ie. the union of all the Boxes in the Region.
For efficiency, Boxes within a Region should ideally not overlap, but
functionality is not compromised if they do.

The minimum and maximum values are expressed in normalized coordinates.

A Substitution is a dict mapping source glyph names to substitute glyph names.

Returns data is in similar but different format.  Overlaps of distinct
substitution Boxes (*not* Regions) are explicitly listed as distinct rules,
and rules with the same Box merged.  The more specific rules appear earlier
in the resulting list.  Moreover, instead of just a dictionary of substitutions,
a list of dictionaries is returned for substitutions corresponding to each
unique space, with each dictionary being identical to one of the input
substitution dictionaries.  These dictionaries are not merged to allow data
sharing when they are converted into font tables.

Example::

    >>> condSubst = [
    ...     # A list of (Region, Substitution) tuples.
    ...     ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
    ...     ([{"wght": (0.5, 1.0)}], {"dollar": "dollar.rvrn"}),
    ...     ([{"wdth": (0.5, 1.0)}], {"cent": "cent.rvrn"}),
    ...     ([{"wght": (0.5, 1.0), "wdth": (-1, 1.0)}], {"dollar": "dollar.rvrn"}),
    ... ]
    >>> from pprint import pprint
    >>> pprint(overlayFeatureVariations(condSubst))
    [({'wdth': (0.5, 1.0), 'wght': (0.5, 1.0)},
      [{'dollar': 'dollar.rvrn'}, {'cent': 'cent.rvrn'}]),
     ({'wdth': (0.5, 1.0)}, [{'cent': 'cent.rvrn'}]),
     ({'wght': (0.5, 1.0)}, [{'dollar': 'dollar.rvrn'}])]

c              3   óJ   #   • U  H  n[        [        U5      5      v •  M     g 7f©N)r   Ú
cleanupBox)Ú.0Úks     r3   Ú	<genexpr>Ú+overlayFeatureVariations.<locals>.<genexpr>Ä   s   é € Ð6²#¨Q”œ* Q›-×(Ð(²#ùs   ‚!#c                 óF   • [        [        U R                  5       5      5      $ rO   )Útupler   Úitems)Úds    r3   Ú<lambda>Ú*overlayFeatureVariations.<locals>.<lambda>Å   s   € œe¤F¨1¯7©7«9Ó$5Ô6rD   )Úkeyr   r   c                 ó    • [        U S   5      * $ )Nr   r   )Ú
BoxAndRanks    r3   rY   rZ   å   s   € ´¸:Àa¹=Ó1IÑ0IrD   )r   r   ÚextendrW   ÚdictÚreversedrV   r   ÚupdateÚlistÚ	enumerateÚ
overlayBoxr$   r"   )r(   ÚmergedÚvaluer[   rR   ÚvÚinitMapInitÚboxMapÚiÚ
currRegionrJ   ÚnewMapÚcurrRankÚboxÚrankÚcurrBoxr    Ú	remainderrW   Ú
substsLists                       r3   r   r   ‚   sG  € ô^ ‹]€FÛ.‰
ˆÜ�s‹mˆØ‹=Ø‰K×Ñ˜uÖ%à�3‹Kñ /ð :@¿¹¼ÔHº±° ¤D¨£G£¹ÐÑHØô ‹]€FÜÐ7Ö8‰
ˆÜÜÙ6±#Ó6Ù6ñó
ˆð ‹=Ø‰K×Ñ˜uÖ%ä˜u›+ˆF‹Kñ 9ô  $¤H¨V¯\©\«^Ó$<Ó=ÐØô
 “J �?Ð$€KÜ˜Ó%€FÜ'Ð(@ÖAÑˆ‰?ˆJÜ˜[Ó)ˆØ˜‘6ˆØŸ™ž‰IˆCÛ%�Ü*4°WÓ*BÑ'�˜iØÑ+Ü#+¨LÓ#9�LØ+1¯:©:°lÀAÓ+FÈÑ+MÐPXÑ+X�F˜<Ñ(ØÓ(Ü (¨Ó 3�IØ(.¯
©
°9¸aÓ(@À4Ñ(G�F˜9Ó%ó &ñ (ð Šñ Bð €EÜØ�‰‹ÑIô‰	ˆð �1‹9ÙØˆ
ØˆÞØ�a�xØ×!Ñ!Ð":Ñ"=¸aÑ"@ÔAØ�Q‰JˆDØ�‰FˆA÷	 ˆdð
 	�‰”d˜3“i Ð,Ö-ñð €Lùóu  Is   ÁH<c                 ó  • 0 nUR                  U 5        UR                  U5        [        U 5      [        U5      -   H5  nX   u  pEX   u  pg[        XF5      n[        XW5      n	X‰:  d  SU4s  $ X‰4X#'   M7     [	        U5      n
SnSnU  H  nX1;   a  M
  SnSn  O   U Hb  nX0;  a  M
  X#   u  pEX   u  pgXF::  a  Xu::  a  M"  U(       a  X!4s  $ SnSnXF::  a  [        XV5      nUn	OXu::  a  Un[        XG5      n	OX!4s  $ X‰4X£'   Md     U(       a  US4$ X*4$ )a1  Overlays ``top`` box on top of ``bot`` box.

Returns two items:

* Box for intersection of ``top`` and ``bot``, or None if they don't intersect.
* Box for remainder of ``bot``.  Remainder box might not be exact (since the
  remainder might not be a simple box), but is inclusive of the exact
  remainder.
NFT)ra   r   r%   Úminr_   )ÚtopÚbotr    ÚaxisTagÚmin1Úmax1Úmin2Úmax2ÚminimumÚmaximumrq   Ú	extrudingÚfullyInsides                r3   rd   rd   ÿ   sT  € ð €LØ×Ñ˜ÔØ×Ñ˜ÔÜ�s“8œc #›hÔ&ˆØ‘\‰
ˆØ‘\‰
ˆÜ�d“/ˆÜ�d“/ˆØÓ Ø˜�9ÒØ 'Ð 0ˆÓñ 'ô( �S“	€IØ€IØ€KÛˆØ‹>ÙØˆ	ØˆÙñ ó ˆØÓÙØ!Ñ*‰
ˆØ‘\‰
ˆØ‹<˜D›LÙö ØÐ$Ò$Øˆ	Øˆð ‹<ä˜$“oˆGØ‰GØ‹\àˆGÜ˜$“o‰Gð  Ð$Ò$à$Ð-ˆ	ÓñA öD à˜TÐ!Ð!àÐ"Ð"rD   c                 óh   • U R                  5        VVs0 s H  u  pUS:w  d  M  X_M     snn$ s  snnf )z¾Return a sparse copy of `box`, without redundant (default) values.

>>> cleanupBox({})
{}
>>> cleanupBox({'wdth': (0.0, 1.0)})
{'wdth': (0.0, 1.0)}
>>> cleanupBox({'wdth': (-1.0, 1.0)})
{}

)g      ð¿g      ð?)rW   )rn   ÚtagÚlimits      r3   rP   rP   T  s/   € ð *-¯©¬ÔMª™:˜3¸ÀÑ8L‹JˆCŠJ©ÒMÐMùÓMs   ”.¤.c                 ó‚
  ^ • [        U[        5      (       a  U/O
[        U5      nSU;  =(       d    [        U5      S:„  nUR                  S:  a  SUl        [        5       nUR                  R                   Vs1 s H!  nUR                  U;   d  M  UR                  iM#     snm [        U5      T -
  nU(       GaÊ  / n	[        U5       HE  n[        U/ 5      n
UR                  R                  R                  U
5        U	R                  U
5        MG     [        UR                  R                  5      UR                  l        [        U5        U	 GH4  n
UR                  R                  R                  U
5      nUR                  R                   Hà  nUR                   R"                  cA  [$        R&                  " 5       nSUl        SUl        / Ul        SUl        XÜR                   l        UR                   R.                   Vs/ s H  oîR&                  PM     nnUR                   R"                  /U-    H8  nUR,                  R                  U5        [        UR,                  5      Ul        M:     Mâ     UR1                  U5        GM7     T (       a8  UR3                  U 4S j[5        UR                  R                  5       5       5        [5        U S   R6                  5       VVs0 s H  u  nnUR8                  U_M     nnn[;        US	5      =(       a    UR<                  SLn/ nU GHc  u  nn/ n[        UR?                  5       5       H;  u  nu  nnUU:”  a  [A        S
5      e[C        UU   UU5      nUR                  U5        M=     / n[        U5       H\  nUR                  R                  U   RD                  RF                  nU(       a  UU-   OUU-   nUR                  [I        UU5      5        M^     U(       as  [K        UR<                  U5      =n(       aV  URL                  RN                  RQ                  U5        [        URL                  RN                  5      URL                  l)        GMH  UR                  [U        UU5      5        GMf     U(       a’  UR<                  R                  S:w  a$  [W        SUR<                  R                  S S35      eUR<                  RX                  RQ                  U5        [        UR<                  RX                  5      UR<                  l-        g[]        U5      Ul        gs  snf s  snf s  snnf )zwLow level implementation of addFeatureVariations that directly
models the possibilities of the FeatureVariations table.r   r   é  Néÿÿ  r   c              3   óP   >#   • U  H  u  pUR                   T;   d  M  Uv •  M     g 7frO   )r?   )rQ   ÚindexÚfeaturer-   s      €r3   rS   Ú*addFeatureVariationsRaw.<locals>.<genexpr>£  s*   øé € ð !
â"L‘�Ø×!Ñ! \Ñ1÷ ‰EÚ"Lùs   ƒ&�	&Úfvarr6   z<A condition set has a minimum value above the maximum value.é   ú/Unsupported FeatureVariations table version: 0xÚ08xú (expected 0x00010000).)/r   r   r   r   ÚVersionr   r8   r9   r?   ÚbuildFeatureRecordr"   ÚFeatureCountÚsortFeatureListr‡   Ú
ScriptListÚScriptRecordÚScriptÚDefaultLangSysÚotÚLangSysÚLookupOrderÚReqFeatureIndexr>   ÚLangSysRecordr=   ra   rc   Úaxesrw   r7   r6   rW   r   ÚbuildConditionTableÚFeatureÚLookupListIndexÚ#buildFeatureTableSubstitutionRecordÚfindFeatureVariationRecordr;   r<   r^   ÚSubstitutionCountÚbuildFeatureVariationRecordr   r:   ÚFeatureVariationCountÚbuildFeatureVariations)!r'   r   r(   r)   r*   r+   ÚvarFeatureIndicesrˆ   ÚnewTagsÚvarFeaturesÚ
varFeatureÚvarFeatureIndexÚscriptRecordÚlangSysÚlsrÚlangSystemsÚ	axisIndexÚaxisÚaxisIndicesÚhasFeatureVariationsÚfeatureVariationRecordsr0   ÚlookupIndicesÚconditionTablerw   ÚminValueÚmaxValueÚctÚrecordsÚexistingLookupIndicesÚcombinedLookupIndicesrB   r-   s!                                   @r3   r#   r#   g  s·  ø€ ô #-¨Z¼×"=Ñ"=�:‘,Ä6È*ÓCU€KØ Ñ+×C¬s°;Ó/?À!Ñ/C€Kð ‡}�}�zÓ!Ø"ˆŒä›Ðð ×(Ñ(×6Ò6óâ6ˆGØ×Ñ Ñ,ó 	ˆ×ÔÙ6ñ€Lô �+Ó Ñ-€GßØˆÜ  ž/ˆJÜ+¨J¸Ó;ˆJØ×Ñ×+Ñ+×2Ñ2°:Ô>Ø×Ñ˜zÖ*ñ *ô *-¨U×->Ñ->×-LÑ-LÓ)Mˆ×ÑÔ&ä˜Ôä%ˆJØ#×/Ñ/×=Ñ=×CÑCÀJÓOˆOà %× 0Ñ 0× =Ô =�Ø×&Ñ&×5Ñ5Ñ=ä Ÿjšj›l�GØ*.�GÔ'Ø.4�GÔ+Ø+-�GÔ(Ø+,�GÔ(Ø9@×'Ñ'Ô6Ø6B×6IÑ6I×6WÒ6WÓXÒ6W¨sŸ{œ{Ñ6W�ÐXØ ,× 3Ñ 3× BÑ BÐCÀkÔQ�GØ×(Ñ(×/Ñ/°Ô@Ü+.¨w×/CÑ/CÓ+D�GÖ(ó  Rñ !>ð ×!Ñ! /×2ñ! &ö$ ð 	× Ñ ô !
ä"+¨E×,=Ñ,=×,KÑ,KÔ"Ló!
ô 	
ô 8AÀÀfÁ×ARÑARÔ7SôÚ7S¡O I¨tˆ�‰�iÒÑ7Sð ñ ô
 	�Ð*Ó+×S°×0GÑ0GÈtÐ0Sð ð !ÐÜ'?Ñ#ˆ�mØˆÜ-3°L×4FÑ4FÓ4HÖ-IÑ)ˆGÑ)�h Ø˜(Ó"Ü+ØRóð ô % [°Ñ%9¸8ÀXÓNˆBØ×!Ñ! "Ö%ñ .Jð ˆÜ%Ð&7Ö8ˆOØ$)×$5Ñ$5×$CÑ$CØñ%ç‰g—o‘oð "ö
 ð &¨Ò5à"Ð%:Ñ:ð "ð �N‰NÜ3Ø#Ð%:óöñ  9ö  Ü-¨e×.EÑ.EÀ~ÓVÐVˆCÕVà×(Ñ(×;Ñ;×BÑBÀ7ÔKÜ=@Ø×,Ñ,×?Ñ?ó>ˆC×(Ñ(×:ð $×*Ñ*Ü+¨N¸GÓD÷ñC (@öJ Ø×"Ñ"×*Ñ*¨jÓ8ÜðØ×,Ñ,×4Ñ4°SÐ9Ð9PðRóð ð 	×Ñ×6Ñ6×=Ñ=Ð>UÔVÜ8;Ø×#Ñ#×:Ñ:ó9
ˆ×ÑÕ5ô #9Ð9PÓ"QˆÕùòKùò: Yùós   Á8T1ÂT1Ç<T6ËT;c                  ó†  • [        S5      n [        R                  " 5       =ol        SUl        [        R
                  " 5       Ul        / UR
                  l        [        R                  " 5       Ul        / UR                  l        [        R                  " 5       Ul	        / UR                  l
        [        R                  " 5       nSUl        [        R                  " 5       Ul        SUR                  l        / UR                  l        SUR                  l        [        R                  " 5       n[        R                   " 5       Ul        SUR                   l        / UR                   l        UR                   UR                  l        UR
                  R                  R'                  U5        SUR
                  l        SUl        U $ )z Build a GSUB table from scratch.r   r„   ÚDFLTNr   r…   r   )r   r—   r   r   r�   r“   r”   r8   r9   Ú
LookupListÚLookupÚ	ScriptTagr•   r–   r›   ÚLangSysCountr˜   rš   r>   r"   ÚScriptCountr6   )Ú	fontTableÚgsubÚsrecÚlangrecs       r3   r   r   ê  s+  € ä˜Ó €IÜŸWšW›YÐ&€DŒ?Ø€D„Lä—m’m“o€D„OØ#%€D‡O�OÔ Ü—~’~Ó'€DÔØ%'€D×ÑÔ"Ü—m’m“o€D„OØ€D‡O�OÔä�?Š?Ó€DØ€D„NÜ—)’)“+€D„KØ!%€D‡K�KÔØ "€D‡K�KÔØ €D‡K�KÔä×ÒÓ €GÜ—j’j“l€G„OØ&,€G‡O�OÔ#Ø#%€G‡O�OÔ Ø!(§¡€D‡K�KÔà‡O�O× Ñ ×'Ñ'¨Ô-Ø"#€D‡O�OÔØ!€DÔàÐrD   c                 ó  • [        5       n/ nU  Hf  u  p4/ nU HG  n[        [        UR                  5       5      5      nUR	                  U5        UR                  U5        MI     UR	                  X545        Mh     U[        U5      4$ )z’Turn all the substitution dictionaries in sorted tuples of tuples so
they are hashable, to detect duplicates so we don't write out redundant
data.)r   rV   r   rW   r"   r=   )r(   r,   Ú	condSubstr0   ÚsubstitutionMapsr   ÚsubstitutionMapÚsubsts           r3   r   r     sˆ   € ô “uÐØ€IÛ*BÑ&ˆØˆÛ/ˆOÜœ& ×!6Ñ!6Ó!8Ó9Ó:ˆEØ× Ñ  Ô'Ø× Ñ  Ö'ñ  0ð 	×Ñ˜,Ð6Ö7ñ +Cð ”fÐ-Ó.Ð.Ð.rD   c                   ó   • \ rS rSrS rSrg)ÚShifterVisitori  c                 ó   • Xl         g rO   ©Úshift)ÚselfrÐ   s     r3   Ú__init__ÚShifterVisitor.__init__  s   € Ø�
rD   rÏ   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rÒ   Ú__static_attributes__© rD   r3   rÍ   rÍ     s   † õrD   rÍ   rŸ   c                 óf   • U R                   nU Vs/ s H  oUU-   PM	     nn[        XU5        g s  snf rO   )rÐ   Úsetattr)ÚvisitorÚobjÚattrrf   rÐ   Úls         r3   Úvisitrà      s0   € à�M‰M€EÙ %Ó&¢˜1�ŒY¡€EÐ&ÜˆC�uÕùò 's   ‘.c                 ó6   • [        XU R                  U-   5        g rO   )rÛ   rÐ   )rÜ   rÝ   rÞ   rf   s       r3   rà   rà   '  s   € ô ˆC�w—}‘} uÑ,Õ-rD   c                 ó  • U(       a  [        U R                  R                  5      OSn0 n[        U5       H  u  pVX5-   XF'   M     U(       d`  [        U5      n[	        U5      nUR                  U R                  R                  5        UR                  U R                  R                  5        [        U5       H—  u  pY[        U	5      n
[        [        U
5      /5      nU(       a&  U R                  R                  R                  U5        O%U R                  R                  R                  X[5        U R                  R                  XI      UL a  M—   e   [        U R                  R                  5      U R                  l        U$ )zhBuild the lookups for the glyph substitutions, return a dict mapping
the substitution to lookup indices.r   )r   r¾   r¿   rc   rÍ   rà   r8   r9   r_   r	   r
   r"   ÚinsertÚLookupCount)rÄ   r,   r+   Ú
firstIndexr.   rj   rÊ   rÐ   rÜ   rË   ÚsubstMapÚlookups               r3   r!   r!   .  s*  € ö 1<”�T—_‘_×+Ñ+Ô,À€JØ€IÜ'Ð(8Ö9ÑˆØ%/¡^ˆ	Ó"ñ :ö äÐ$Ó%ˆÜ  Ó'ˆØ�‰�d×&Ñ&×4Ñ4Ô5Ø�‰�d—o‘o×,Ñ,Ô-äÐ.Ö/‰ˆÜ˜“;ˆÜÔ6°xÓ@ÐAÓBˆÞØ�O‰O×"Ñ"×)Ñ)¨&Õ1à�O‰O×"Ñ"×)Ñ)¨!Ô4Ø�‰×%Ñ% iÑ&6Ñ7¸6ÔAÐAÐAñ 0ô #& d§o¡o×&<Ñ&<Ó"=€D‡O�OÔØÐrD   c                 ój   • [         R                  " 5       nSUl        Xl        [	        U 5      Ul        U$ )z%Build the FeatureVariations subtable.r‹   )r—   r6   r�   r:   r   r¤   )r³   Úfvs     r3   r¥   r¥   M  s0   € ä	×	Ò	Ó	€BØ€B„JØ 7ÔÜ"Ð#:Ó;€BÔØ€IrD   c                 óÄ   • [         R                  " 5       nXl        [         R                  " 5       Ul        XR                  l        UR                  R                  5         U$ )zBuild a FeatureRecord.)r—   r9   r?   rž   rŸ   ÚpopulateDefaults)r)   ÚlookupListIndicesÚfrs      r3   r�   r�   V  sA   € ä	×	Ò	Ó	€BØ„MÜ—’“€B„JØ!2‡J�JÔØ‡J�J×ÑÔ!Ø€IrD   c                 ó�  • [         R                  " 5       n[        U 5      S:w  aE  [         R                  " 5       Ul        XR                  l        [        U 5      UR                  l        OSUl        [         R                  " 5       Ul        SUR                  l        XR                  l        [        U5      UR                  l	        U$ )zBuild a FeatureVariationRecord.r   Nr‹   )
r—   r:   r   ÚConditionSetÚConditionTableÚConditionCountr;   r�   r<   r¢   )rµ   ÚsubstitutionRecordsrB   s      r3   r£   r£   `  s—   € ä
×
#Ò
#Ó
%€CÜ
ˆ>Ó˜aÓÜŸ?š?Ó,ˆÔØ*8×ÑÔ'Ü*-¨nÓ*=ˆ×ÑÕ'àˆÔÜ#%×#>Ò#>Ó#@€CÔ Ø+5€C× Ñ Ô(Ø6I× Ñ Ô3Ü58Ð9LÓ5M€C× Ñ Ô2Ø€JrD   c                 óÄ   • [         R                  " 5       nXl        [         R                  " 5       Ul        XR                  l        [        U5      UR                  l        U$ )z'Build a FeatureTableSubstitutionRecord.)r—   ÚFeatureTableSubstitutionRecordr>   rž   rŸ   r   rä   )ÚfeatureIndexrì   rC   s      r3   r    r    p  sD   € ä×,Ò,Ó.€DØ$ÔÜ—:’:“<€D„LØ#4‡L�LÔ Ü"Ð#4Ó5€D‡L�LÔØ€KrD   c                 ób   • [         R                  " 5       nSUl        Xl        Xl        X#l        U$ )zBuild a ConditionTable.r   )r—   rð   ÚFormatÚ	AxisIndexÚFilterRangeMinValueÚFilterRangeMaxValue)r¯   ÚfilterRangeMinValueÚfilterRangeMaxValuer¸   s       r3   r�   r�   z  s-   € ä	×	Ò	Ó	€BØ€B„IØ„LØ0ÔØ0ÔØ€IrD   c                 ó¸   • U R                   S:w  a  [        SU R                   S S35      eU R                   H   nXR                  R                  :X  d  M  Us  $    g)z?Find a FeatureVariationRecord that has the same conditionTable.r‹   rŒ   r�   rŽ   N)r�   r   r:   rï   rð   )ÚfeatureVariationsrµ   rB   s      r3   r¡   r¡   „  sg   € à× Ñ  JÓ.ÜðØ"×*Ñ*¨3Ð/Ð/FðHó
ð 	
ð
 !×7Ô7ˆØ×-Ñ-×<Ñ<Õ<ØŠJñ 8ð rD   c                 ó¬  • [        U R                  R                  5       VVs/ s H  u  pUR                  X4PM     nnnUR	                  5         U VVVs/ s H  u  pAo"PM	     snnnU R                  l        [        [        U VVVs/ s H  u  pAo!PM	     snnn[        [        U5      5      5      5      n[        X5        gs  snnf s  snnnf s  snnnf )zˆSort the feature list by feature tag, and remap the feature indices
elsewhere. This is needed after the feature list has been modified.
N)
rc   r8   r9   r?   Úsortr_   ÚzipÚranger   ÚremapFeatures)r   r‡   ÚfeaÚtagIndexFear�   ÚfeatureRemaps         r3   r’   r’   “  s¸   € ô $ E×$5Ñ$5×$CÑ$CÔDôâD‰JˆEð 
�‰˜Ó$ÙDð ñ ð ×ÑÔÙBMÕ&NÂ+©¨s¸3¢sÁ+Ó&N€E×ÑÔ#ÜÜ©+Õ6ª+‘�s 3ŠU©+Ó6¼¼cÀ+Ó>NÓ8OÓPó€Lô
 �%Õ&ùóùô
 'Oùä6s   £CÁCÂCc                 óô  • [        U R                  R                  5       Hh  u  p#UR                  R                  nUb  [        XA5        [        UR                  R                  5       H  u  pVUR                  n[        Xq5        M     Mj     [        U S5      (       a\  U R                  bN  U R                  R                   H3  nUR                  R                   H  n	XR                     U	l        M     M5     ggg)z7Go through the scripts list, and remap feature indices.Nr6   )rc   r“   r”   r•   r–   Ú_remapLangSysr›   r˜   r7   r6   r:   r;   r<   r>   )
r   r  ÚscriptIndexÚscriptÚdefaultLangSysÚlangSysRecordIndexÚ
langSysRecr¬   rB   rC   s
             r3   r  r  ¦  sÒ   € ä(¨×)9Ñ)9×)FÑ)FÖGÑˆØŸ™×5Ñ5ˆØÑ%Ü˜.Ô7Ü.7¸¿¹×8SÑ8SÖ.TÑ*ÐØ ×(Ñ(ˆGÜ˜'Ö0ó /Uñ	  Hô ˆuÐ)×*Ñ*¨u×/FÑ/FÑ/RØ×*Ñ*×AÔAˆCØ×4Ñ4×GÔG�Ø$0×1BÑ1BÑ$C�Ö!ó Hò Bð 0SÐ*rD   c                 óœ   • U R                   S:w  a  XR                      U l         U R                   Vs/ s H  o!U   PM	     snU l        g s  snf )Nr…   )rš   r>   )r¬   r  r‡   s      r3   r  r  ¶  sF   € Ø×Ñ &Ó(Ø".×/FÑ/FÑ"GˆÔØ=D×=QÒ=QÓRÒ=Q°E¨Ô/Ñ=QÑR€GÕùÒRs   ²A	Ú__main__N)r   )F)3Ú__doc__ÚfontTools.misc.dictToolsr   ÚfontTools.misc.intToolsr   ÚfontTools.ttLibr   ÚfontTools.ttLib.tablesr   r—   ÚfontTools.ttLib.ttVisitorr   ÚfontTools.otlLib.builderr	   r
   Úcollectionsr   Úerrorsr   r   r4   r   r   r   rd   rP   r#   r   r   rÍ   Úregister_attrrž   rà   ÚSubstLookupRecordÚPosLookupRecordr!   r¥   r�   r£   r    r�   r¡   r’   r  r  rÔ   ÚdoctestÚsysÚexitÚtestmodÚfailedrÙ   rD   r3   Ú<module>r!     s#  ðñõ .Ý -Ý $Ý 1Ý /ß JÝ #ç 6ôV4òr#ò

òpòzR#òjNô&{RòFòB/ô �Yô ð
 ×Ñ˜bŸj™jÐ*;Ó<ñó =ðð ×ÑØ×Ñ˜2×-Ñ-Ð.Ð0Aóñ.óð.ôò>òòò òòò'ò&Dò Sð ˆzÓßà‡H‚HˆW�_Š_Ó×%Ñ%Õ&ð rD   