U
    ºmœd�  ã                   @   s&   ddd„Z edkr"d dlZe ¡  dS )é    Nc                 C   s"  | |kr||  S |dk	r$|dk	s$t ‚|dk	r8|dk	s8t ‚|dkr”i }i }| ¡ D ]B\}}| d¡rv|D ]}|||< qfqP| d¡rP|D ]}|||< q„qP| \}	}
d }}|	 d¡r¸|	}d}	n
| |	¡}|
 d¡rÖ|
}d}
n
| |
¡}|	|
f|	|f||
f||fg}|D ]} | |k�r ||    S �q |S )aµ  
    Note: This expects kerning to be a flat dictionary
    of kerning pairs, not the nested structure used
    in kerning.plist.

    >>> 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
    Nzpublic.kern1.zpublic.kern2.)ÚAssertionErrorÚitemsÚ
startswithÚget)ÚpairZkerningÚgroupsÚfallbackZglyphToFirstGroupZglyphToSecondGroupÚgroupZgroupMembersZglyphÚfirstÚsecondZ
firstGroupZsecondGroupÚpairs© r   úQ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/fontTools/ufoLib/kerning.pyÚlookupKerningValue   sF    *





ü
r   Ú__main__)r   NN)r   Ú__name__ÚdoctestÚtestmodr   r   r   r   Ú<module>   s        ÿ
W