
    rbi                        d dl mZ d dlmZ d dlmZmZmZmZ e	e
e
f         Z	 	 	 dddZedk    rd dlZ ej                     dS dS )    )annotations)Optional)KerningPairKerningDictKerningGroupsIntFloatNpairr   kerningr   groupsr   fallbackr   glyphToFirstGroupOptional[StrDict]glyphToSecondGroupreturnc                @   | |v r||          S |du |du k    rt          d          |]i }i }|                                D ]D\  }}|                    d          r|D ]}|||<   %|                    d          r
|D ]}|||<   E|J |J | \  }	}
dx}|	                    d          r|	}d}n|                    |	          }|	}|
                    d          r|
dn|                    |
          |
fd||fD             }|D ]} | |v r
||          c S |S )a	  Retrieve the kerning value (if any) between a pair of elements.

    The elments can be either individual glyphs (by name) or kerning
    groups (by name), or any combination of the two.

    Args:
      pair:
          A tuple, in logical order (first, second) with respect
          to the reading direction, to query the font for kerning
          information on. Each element in the tuple can be either
          a glyph name or a kerning group name.
      kerning:
          A dictionary of kerning pairs.
      groups:
          A set of kerning groups.
      fallback:
          The fallback value to return if no kern is found between
          the elements in ``pair``. Defaults to 0.
      glyphToFirstGroup:
          A dictionary mapping glyph names to the first-glyph kerning
          groups to which they belong. Defaults to ``None``.
      glyphToSecondGroup:
          A dictionary mapping glyph names to the second-glyph kerning
          groups to which they belong. Defaults to ``None``.

    Returns:
      The kerning value between the element pair. If no kerning for
      the pair is found, the fallback value is returned.

    Note: This function expects the ``kerning`` argument to be a flat
    dictionary of kerning pairs, not the nested structure used in a
    kerning.plist file.

    Examples::

      >>> groups = {
      ...     "public.kern1.O" : ["O", "D", "Q"],
      ...     "public.kern2.E" : ["E", "F"]
      ... }
      >>> kerning = {
      ...     ("public.kern1.O", "public.kern2.E") : -100,
      ...     ("public.kern1.O", "F") : -200,
      ...     ("D", "F") : -300
      ... }
      >>> lookupKerningValue(("D", "F"), kerning, groups)
      -300
      >>> lookupKerningValue(("O", "F"), kerning, groups)
      -200
      >>> lookupKerningValue(("O", "E"), kerning, groups)
      -100
      >>> lookupKerningValue(("O", "O"), kerning, groups)
      0
      >>> lookupKerningValue(("E", "E"), kerning, groups)
      0
      >>> lookupKerningValue(("E", "O"), kerning, groups)
      0
      >>> lookupKerningValue(("X", "X"), kerning, groups)
      0
      >>> lookupKerningValue(("public.kern1.O", "public.kern2.E"),
      ...     kerning, groups)
      -100
      >>> lookupKerningValue(("public.kern1.O", "F"), kerning, groups)
      -200
      >>> lookupKerningValue(("O", "public.kern2.E"), kerning, groups)
      -100
      >>> lookupKerningValue(("public.kern1.X", "public.kern2.X"), kerning, groups)
      0
    NzKMust provide both 'glyphToFirstGroup' and 'glyphToSecondGroup', or neither.zpublic.kern1.zpublic.kern2.c                .    g | ]}fD ]
}||||fS )N ).0absecondGlyphsecondGroups      h/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/fontTools/ufoLib/kerning.py
<listcomp>z&lookupKerningValue.<locals>.<listcomp>|   sI       {+  =Q] 
A +]]]    )
ValueErroritems
startswithget)r	   r
   r   r   r   r   groupgroupMembersglyphfirstsecond
firstGroup
firstGlyphpairsr   r   s                 @@r   lookupKerningValuer(   
   s   Z wt}T!'9T'ABBY
 
 	
  #)<<>> 	6 	6E<00 6) 5 5E/4%e,,5!!/22 6) 6 6E05&u--((()))ME6##J(( 


&**511

)) (,,V44    j)  E  ! !7??4=     Or   __main__)r   NN)r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   )
__future__r   typingr   fontTools.annotationsr   r   r   r   dictstrStrDictr(   __name__doctesttestmodr   r   r   <module>r3      s    " " " " " "       S S S S S S S S S S S S
sCx. +/,0} } } } }@ zNNNGO r   