U
    Evf	                     @   sX   d Z ddlZddlmZ ddlmZmZ edddd	d
dgZdd Z	edddZ
dS )z"
Low-level text helper utilities.
    N   )_api)KERNING_DEFAULTLOAD_NO_HINTING
LayoutItemZ	ft_objectchar	glyph_idxxZ	prev_kernc              	   C   s  t d| t| ddd d|   kr8dkrBn ndnNd|   krVdkr`n nd	n0d
|   krtdkr~n ndnd|   krdkrn ndnd|   krdkrn ndnd|   krdkrn ndnd|   krdkrn ndnd|   krdkrn ndnd|   kr&dkr.n ndnbd|   krFd krNn nd!nBd"|   krfd#krnn nd$n"d%|   krd&krn nd'nd }|rt d(| d) d S )*Nz(Glyph {} ({}) missing from current font.asciinamereplacei  i  Hebrewi   i  Arabici 	  i	  
Devanagarii	  i	  ZBengalii 
  i
  ZGurmukhii
  i
  ZGujaratii   i  ZOriyai  i  ZTamili   i  ZTelugui  i  ZKannadai   i  Z	Malayalami  i  ZSinhalaz&Matplotlib currently does not support z
 natively.)r   Zwarn_externalformatchrencodedecode)	codepointblock r   </tmp/pip-unpacked-wheel-7vhvci0g/matplotlib/_text_helpers.pywarn_on_missing_glyph   s0         
r   )	kern_modec                c   s   d}d}| | }|}| D ]v}|||}|t|}|dk	rR||||d nd}	||	7 }|j|td}
t|||||	V  ||
jd 7 }|}qdS )a  
    Render *string* with *font*.  For each character in *string*, yield a
    (glyph-index, x-position) pair.  When such a pair is yielded, the font's
    glyph is set to the corresponding character.

    Parameters
    ----------
    string : str
        The string to be rendered.
    font : FT2Font
        The font.
    kern_mode : int
        A FreeType kerning mode.

    Yields
    ------
    glyph_index : int
    x_position : float
    r   N@   g        )flagsi   )	Z_get_fontmapgetZget_char_indexordZget_kerningZ
load_glyphr   r   ZlinearHoriAdvance)stringfontr   r	   Zprev_glyph_idxZchar_to_fontZ	base_fontr   r   kernZglyphr   r   r   layout&   s     
r    )__doc__Zdataclasses r   Zft2fontr   r   Zmake_dataclassr   r   r    r   r   r   r   <module>   s    