ó
    oñ:i„4  ã                  ó®   • S SK Jr  S SKJrJr  S SKJr  S SKJr    S       SS jjr	SS jr
SSS jjrS r\S	:X  a  S S
Kr\R                  " 5         g
g
)é    )Úannotations)ÚMappingÚAny)Ú	Container)ÚKerningNestedc                ó   • [        U5      u  p4[        U R                  5       5       H�  u  pVXQ;   a,  XR;  a'  UR                  S5      (       d  UR	                  U5        [        UR                  5       5       H:  nXq;   d  M
  Xr;  d  M  UR                  S5      (       a  M)  UR	                  U5        M<     M�     0 nU H\  n[        UR                  5       5      [        UR                  5       5      -   n	UR                  SS5      n
SU
-   n
[        X©5      n
X¨U'   M^     0 nU H\  n[        UR                  5       5      [        UR                  5       5      -   n	UR                  SS5      n
SU
-   n
[        X©5      n
X«U'   M^     0 n[        U R                  5       5       HS  u  pVUR                  XU5      n0 n[        UR                  5       5       H  u  p~UR                  Xw5      nXíU'   M     XÜU'   MU     [        UR                  5       5      nU[        UR                  5       5      -  nU H  u  nn
[        UU   5      nUX'   M     XÁ[        X‹S94$ )ao  Convert kerning data in UFO1 or UFO2 syntax into UFO3 syntax.

Args:
  kerning:
      A dictionary containing the kerning rules defined in
      the UFO font, as used in :class:`.UFOReader` objects.
  groups:
      A dictionary containing the groups defined in the UFO
      font, as used in :class:`.UFOReader` objects.
  glyphSet:
    Optional; a set of glyph objects to skip (default: None).

Returns:
  1. A dictionary representing the converted kerning data.
  2. A copy of the groups dictionary, with all groups renamed to UFO3 syntax.
  3. A dictionary containing the mapping of old group names to new group names.

zpublic.kern1.zpublic.kern2.ú@MMK_L_Ú ú@MMK_R_)Úside1Úside2)
ÚfindKnownKerningGroupsÚlistÚitemsÚ
startswithÚaddÚkeysÚreplaceÚmakeUniqueGroupNameÚgetÚdict)ÚkerningÚgroupsÚglyphSetÚfirstReferencedGroupsÚsecondReferencedGroupsÚfirstÚsecondsÚsecondÚfirstRenamedGroupsÚexistingGroupNamesÚnewNameÚsecondRenamedGroupsÚ
newKerningÚ
newSecondsÚvalueÚallRenamedGroupsÚoldNameÚgroups                     Ú^/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/fontTools/ufoLib/converters.pyÚ%convertUFO1OrUFO2KerningToUFO3Kerningr+      s,  € ô, 5KÈ6Ó4RÑ1Ðä˜wŸ}™}›Ö/‰ˆØ‹?˜uÓ4Ø×#Ñ# O×4Ñ4Ø%×)Ñ)¨%Ô0Ü˜7Ÿ<™<›>Ö*ˆFØÕ FÕ$:Ø×(Ñ(¨×9Ó9Ø*×.Ñ.¨vÖ6ó +ñ	 0ð *,ÐÛ&ˆä! &§+¡+£-Ó0´4Ð8J×8OÑ8OÓ8QÓ3RÑRÐà—-‘- 	¨2Ó.ˆà! GÑ+ˆä% gÓBˆà$+˜5Ó!ñ 'ð +-ÐÛ(ˆä! &§+¡+£-Ó0´4Ð8K×8PÑ8PÓ8RÓ3SÑSÐà—.‘. ¨BÓ/ˆà! GÑ+ˆä% gÓBˆà&-˜FÓ#ñ )ð €JÜ˜wŸ}™}›Ö/‰ˆØ"×&Ñ& uÓ4ˆØˆ
Ü! '§-¡-£/Ö2‰MˆFØ(×,Ñ,¨VÓ<ˆFØ!&�vÓñ 3ð '�5Óñ 0ô Ð.×4Ñ4Ó6Ó7ÐØœÐ0×6Ñ6Ó8Ó9Ñ9ÐÛ,Ñˆ�Ü�V˜G‘_Ó%ˆØˆ‹ñ -ð œtÐ*<ÑXÐXÐXó    c                óF  • S/nS/n[        5       n[        5       n[        U R                  5       5       Hh  nU H,  nUR                  U5      (       d  M  UR	                  U5          O   U H-  nUR                  U5      (       d  M  UR	                  U5          Mf     Mj     X44$ )aï  Find all kerning groups in a UFO1 or UFO2 font that use known prefixes.

In some cases, not all kerning groups will be referenced
by the kerning pairs in a UFO. The algorithm for locating
groups in :func:`convertUFO1OrUFO2KerningToUFO3Kerning` will
miss these unreferenced groups. By scanning for known prefixes,
this function will catch all of the prefixed groups.

The prefixes and sides by this function are:

@MMK_L_ - side 1
@MMK_R_ - side 2

as defined in the UFO1 specification.

Args:
    groups:
      A dictionary containing the groups defined in the UFO
      font, as read by :class:`.UFOReader`.

Returns:
    Two sets; the first containing the names of all
    first-side kerning groups identified in the ``groups``
    dictionary, and the second containing the names of all
    second-side kerning groups identified.

    "First-side" and "second-side" are with respect to the
    writing direction of the script.

    Example::

      >>> testGroups = {
      ...     "@MMK_L_1" : None,
      ...     "@MMK_L_2" : None,
      ...     "@MMK_L_3" : None,
      ...     "@MMK_R_1" : None,
      ...     "@MMK_R_2" : None,
      ...     "@MMK_R_3" : None,
      ...     "@MMK_l_1" : None,
      ...     "@MMK_r_1" : None,
      ...     "@MMK_X_1" : None,
      ...     "foo" : None,
      ... }
      >>> first, second = findKnownKerningGroups(testGroups)
      >>> sorted(first) == ['@MMK_L_1', '@MMK_L_2', '@MMK_L_3']
      True
      >>> sorted(second) == ['@MMK_R_1', '@MMK_R_2', '@MMK_R_3']
      True
r	   r   )Úsetr   r   r   r   )r   ÚknownFirstGroupPrefixesÚknownSecondGroupPrefixesÚfirstGroupsÚsecondGroupsÚ	groupNameÚfirstPrefixÚsecondPrefixs           r*   r   r   `   s›   € ðd  )˜kÐØ )˜{ÐÜ“%€KÜ“5€LÜ˜&Ÿ+™+›-Ö(ˆ	Û2ˆKØ×#Ñ# K×0Ó0Ø—‘ 	Ô*Ùñ 3ó 5ˆLØ×#Ñ# L×1Ó1Ø× Ñ  Ô+Úó 5ñ )ð Ð$Ð$r,   c                óJ   • U nUS:”  a  SX24-  nX1;   a  [        XUS-   5      $ U$ )a  Make a kerning group name that will be unique within the set of group names.

If the requested kerning group name already exists within the set, this
will return a new name by adding an incremented counter to the end
of the requested name.

Args:
    name:
      The requested kerning group name.
    groupNames:
      A list of the existing kerning group names.
    counter:
      Optional; a counter of group names already seen (default: 0). If
      :attr:`.counter` is not provided, the function will recurse,
      incrementing the value of :attr:`.counter` until it finds the
      first unused ``name+counter`` combination, and return that result.

Returns:
    A unique kerning group name composed of the requested name suffixed
    by the smallest available integer counter.
r   z%s%dé   )r   )ÚnameÚ
groupNamesÚcounterr"   s       r*   r   r   ¢   s9   € ð. €GØ�ƒ{Ø˜GÐ-Ñ-ˆàÓÜ" 4°W¸q±[ÓAÐAà€Nr,   c                 ó   • g)a2  
Tests for :func:`.convertUFO1OrUFO2KerningToUFO3Kerning`.

No known prefixes.

>>> testKerning = {
...     "A" : {
...         "A" : 1,
...         "B" : 2,
...         "CGroup" : 3,
...         "DGroup" : 4
...     },
...     "BGroup" : {
...         "A" : 5,
...         "B" : 6,
...         "CGroup" : 7,
...         "DGroup" : 8
...     },
...     "CGroup" : {
...         "A" : 9,
...         "B" : 10,
...         "CGroup" : 11,
...         "DGroup" : 12
...     },
... }
>>> testGroups = {
...     "BGroup" : ["B"],
...     "CGroup" : ["C"],
...     "DGroup" : ["D"],
... }
>>> kerning, groups, maps = convertUFO1OrUFO2KerningToUFO3Kerning(
...     testKerning, testGroups, [])
>>> expected = {
...     "A" : {
...         "A": 1,
...         "B": 2,
...         "public.kern2.CGroup": 3,
...         "public.kern2.DGroup": 4
...     },
...     "public.kern1.BGroup": {
...         "A": 5,
...         "B": 6,
...         "public.kern2.CGroup": 7,
...         "public.kern2.DGroup": 8
...     },
...     "public.kern1.CGroup": {
...         "A": 9,
...         "B": 10,
...         "public.kern2.CGroup": 11,
...         "public.kern2.DGroup": 12
...     }
... }
>>> kerning == expected
True
>>> expected = {
...     "BGroup": ["B"],
...     "CGroup": ["C"],
...     "DGroup": ["D"],
...     "public.kern1.BGroup": ["B"],
...     "public.kern1.CGroup": ["C"],
...     "public.kern2.CGroup": ["C"],
...     "public.kern2.DGroup": ["D"],
... }
>>> groups == expected
True

Known prefixes.

>>> testKerning = {
...     "A" : {
...         "A" : 1,
...         "B" : 2,
...         "@MMK_R_CGroup" : 3,
...         "@MMK_R_DGroup" : 4
...     },
...     "@MMK_L_BGroup" : {
...         "A" : 5,
...         "B" : 6,
...         "@MMK_R_CGroup" : 7,
...         "@MMK_R_DGroup" : 8
...     },
...     "@MMK_L_CGroup" : {
...         "A" : 9,
...         "B" : 10,
...         "@MMK_R_CGroup" : 11,
...         "@MMK_R_DGroup" : 12
...     },
... }
>>> testGroups = {
...     "@MMK_L_BGroup" : ["B"],
...     "@MMK_L_CGroup" : ["C"],
...     "@MMK_L_XGroup" : ["X"],
...     "@MMK_R_CGroup" : ["C"],
...     "@MMK_R_DGroup" : ["D"],
...     "@MMK_R_XGroup" : ["X"],
... }
>>> kerning, groups, maps = convertUFO1OrUFO2KerningToUFO3Kerning(
...     testKerning, testGroups, [])
>>> expected = {
...     "A" : {
...         "A": 1,
...         "B": 2,
...         "public.kern2.CGroup": 3,
...         "public.kern2.DGroup": 4
...     },
...     "public.kern1.BGroup": {
...         "A": 5,
...         "B": 6,
...         "public.kern2.CGroup": 7,
...         "public.kern2.DGroup": 8
...     },
...     "public.kern1.CGroup": {
...         "A": 9,
...         "B": 10,
...         "public.kern2.CGroup": 11,
...         "public.kern2.DGroup": 12
...     }
... }
>>> kerning == expected
True
>>> expected = {
...     "@MMK_L_BGroup": ["B"],
...     "@MMK_L_CGroup": ["C"],
...     "@MMK_L_XGroup": ["X"],
...     "@MMK_R_CGroup": ["C"],
...     "@MMK_R_DGroup": ["D"],
...     "@MMK_R_XGroup": ["X"],
...     "public.kern1.BGroup": ["B"],
...     "public.kern1.CGroup": ["C"],
...     "public.kern1.XGroup": ["X"],
...     "public.kern2.CGroup": ["C"],
...     "public.kern2.DGroup": ["D"],
...     "public.kern2.XGroup": ["X"],
... }
>>> groups == expected
True

>>> from .validators import kerningValidator
>>> kerningValidator(kerning)
(True, None)

Mixture of known prefixes and groups without prefixes.

>>> testKerning = {
...     "A" : {
...         "A" : 1,
...         "B" : 2,
...         "@MMK_R_CGroup" : 3,
...         "DGroup" : 4
...     },
...     "BGroup" : {
...         "A" : 5,
...         "B" : 6,
...         "@MMK_R_CGroup" : 7,
...         "DGroup" : 8
...     },
...     "@MMK_L_CGroup" : {
...         "A" : 9,
...         "B" : 10,
...         "@MMK_R_CGroup" : 11,
...         "DGroup" : 12
...     },
... }
>>> testGroups = {
...     "BGroup" : ["B"],
...     "@MMK_L_CGroup" : ["C"],
...     "@MMK_R_CGroup" : ["C"],
...     "DGroup" : ["D"],
... }
>>> kerning, groups, maps = convertUFO1OrUFO2KerningToUFO3Kerning(
...     testKerning, testGroups, [])
>>> expected = {
...     "A" : {
...         "A": 1,
...         "B": 2,
...         "public.kern2.CGroup": 3,
...         "public.kern2.DGroup": 4
...     },
...     "public.kern1.BGroup": {
...         "A": 5,
...         "B": 6,
...         "public.kern2.CGroup": 7,
...         "public.kern2.DGroup": 8
...     },
...     "public.kern1.CGroup": {
...         "A": 9,
...         "B": 10,
...         "public.kern2.CGroup": 11,
...         "public.kern2.DGroup": 12
...     }
... }
>>> kerning == expected
True
>>> expected = {
...     "BGroup": ["B"],
...     "@MMK_L_CGroup": ["C"],
...     "@MMK_R_CGroup": ["C"],
...     "DGroup": ["D"],
...     "public.kern1.BGroup": ["B"],
...     "public.kern1.CGroup": ["C"],
...     "public.kern2.CGroup": ["C"],
...     "public.kern2.DGroup": ["D"],
... }
>>> groups == expected
True
N© r<   r,   r*   Útestr=   Ã   s   � r,   Ú__main__N)r<   )r   r   r   zdict[str, list[str]]r   zContainer[str]ÚreturnzEtuple[KerningNested, dict[str, list[str]], dict[str, dict[str, str]]])r   zMapping[str, Any]r?   ztuple[set[str], set[str]])r   )r8   Ústrr9   z	list[str]r:   Úintr?   r@   )Ú
__future__r   Útypingr   r   Úcollections.abcr   ÚfontTools.annotationsr   r+   r   r   r=   Ú__name__ÚdoctestÚtestmodr<   r,   r*   Ú<module>rI      s|   ðÝ "ç Ý %å /ðð VXðJYØðJYØ$8ðJYØDRðJYàJõJYôZ?%öDòBNðb ˆzÓÛà‡O‚OÕð r,   