Ë
    ¨ehÆ3  ã                   óä   — d dl mZ d dlZd dlZd dlZd dlmZm	Z	 d dl
mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ  ej2                  e«      Z G d
„ d«      Z e«       Z G d„ de«      Zy)é    )ÚOrderedDictN)Ú_text_helpersÚdviread)ÚFontPropertiesÚget_fontÚfontManager)Ú	LoadFlags)ÚMathTextParser)ÚPath)Ú
TexManager)ÚAffine2Dc                   ór   — e Zd ZdZdZdZd„ Zd„ Zd„ Zd„ Z	d„ Z
dd	„Z	 	 dd„Z	 	 dd„Z	 	 dd„Zed„ «       Zy
)Ú
TextToPathz'A class that converts strings to paths.g      Y@éH   c                 ó2   — t        d«      | _        d | _        y )NÚpath)r
   Úmathtext_parserÚ_texmanager©Úselfs    úQ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/textpath.pyÚ__init__zTextToPath.__init__   s   € Ü-¨fÓ5ˆÔØˆÕó    c                 ó’   — t        j                  |«      }t        |«      }|j                  | j                  | j
                  «       |S )zX
        Find the `FT2Font` matching font properties *prop*, with its size set.
        )Ú_fontManagerÚ_find_fonts_by_propsr   Úset_sizeÚ
FONT_SCALEÚDPI)r   ÚpropÚ	filenamesÚfonts       r   Ú	_get_fontzTextToPath._get_font   s9   € ô !×5Ñ5°dÓ;ˆ	Ü˜	Ó"ˆØ�‰�d—o‘o t§x¡xÔ0Øˆr   c                 ó"   — t         j                  S )N)r	   Ú
NO_HINTINGr   s    r   Ú_get_hinting_flagzTextToPath._get_hinting_flag'   s   € Ü×#Ñ#Ð#r   c                 ó`   — t         j                  j                  |j                  › d|d›�«      S )zO
        Return a unique id for the given font and character-code set.
        ú-Úx)ÚurllibÚparseÚquoteÚpostscript_name)r   r"   Úccodes      r   Ú_get_char_idzTextToPath._get_char_id*   s-   € ô �|‰|×!Ñ! T×%9Ñ%9Ð$:¸!¸EÀ!¸9Ð"EÓFÐFr   c                 ó  — |j                  «       }|dk(  rt        «       j                  ||«      S || j                  z  }|rZ|j	                  «       }|j                  | j                  «       | j                  j                  |d|«      ^}}}}	||z  ||z  ||z  fS | j                  |«      }
|
j                  |dt        j                  ¬«       |
j                  «       \  }}|dz  }|dz  }|
j                  «       }|dz  }||z  ||z  ||z  fS )NÚTeXr   g        ©Úflagsg      P@)Úget_size_in_pointsr   Úget_text_width_height_descentr   Úcopyr   r   r+   r#   Úset_textr	   r%   Úget_width_heightÚget_descent)r   Úsr    ÚismathÚfontsizeÚscaleÚwidthÚheightÚdescentÚ_r"   ÚwÚhÚds                 r   r5   z(TextToPath.get_text_width_height_descent0   s  € Ø×*Ñ*Ó,ˆà�UŠ?Ü“<×=Ñ=¸aÀÓJÐJà˜4Ÿ?™?Ñ*ˆáØ—9‘9“;ˆDØ�M‰M˜$Ÿ/™/Ô*à×$Ñ$×*Ñ*¨1¨b°$Ó7ð 'ˆE�6˜7 Qà˜5‘= &¨5¡.°'¸E±/ÐAÐAà�~‰~˜dÓ#ˆØ�‰�a˜¤I×$8Ñ$8ˆÔ9Ø×$Ñ$Ó&‰ˆˆ1Ø	ˆT‰	ˆØ	ˆT‰	ˆØ×ÑÓˆØ	ˆT‰	ˆØ�5‰y˜!˜e™) Q¨¡YÐ.Ð.r   c                 óÌ  — |dk(  r| j                  ||«      \  }}}n@|s(| j                  |«      }| j                  ||«      \  }}}n| j                  ||«      \  }}}g g }	}|D ]9  \  }
}}}||
   \  }}|j	                  ||z  ||gz   «       |	j	                  |«       Œ; |D ]'  \  }}|j	                  |«       |	j	                  |«       Œ) |st        j                  d«      }||	fS )a‘  
        Convert text *s* to path (a tuple of vertices and codes for
        matplotlib.path.Path).

        Parameters
        ----------
        prop : `~matplotlib.font_manager.FontProperties`
            The font properties for the text.
        s : str
            The text to be converted.
        ismath : {False, True, "TeX"}
            If True, use mathtext parser.  If "TeX", use tex for rendering.

        Returns
        -------
        verts : list
            A list of arrays containing the (x, y) coordinates of the vertices.
        codes : list
            A list of path codes.

        Examples
        --------
        Create a list of vertices and codes from a text, and create a `.Path`
        from those::

            from matplotlib.path import Path
            from matplotlib.text import TextToPath
            from matplotlib.font_manager import FontProperties

            fp = FontProperties(family="Comic Neue", style="italic")
            verts, codes = TextToPath().get_text_path(fp, "ABC")
            path = Path(verts, codes, closed=False)

        Also see `TextPath` for a more direct way to create a path from a text.
        r1   )r   é   )Úget_glyphs_texr#   Úget_glyphs_with_fontÚget_glyphs_mathtextÚextendÚnpÚempty)r   r    r:   r;   Ú
glyph_infoÚ	glyph_mapÚrectsr"   ÚvertsÚcodesÚglyph_idÚ	xpositionÚ	ypositionr=   Úverts1Úcodes1s                   r   Úget_text_pathzTextToPath.get_text_pathH   s  € ðH �UŠ?Ø+/×+>Ñ+>¸tÀQÓ+GÑ(ˆJ˜	¡5ÙØ—>‘> $Ó'ˆDØ+/×+DÑ+DÀTÈ1Ó+MÑ(ˆJ˜	¡5à+/×+CÑ+CÀDÈ!Ó+LÑ(ˆJ˜	 5à˜2ˆuˆØ5?ò 	!Ñ1ˆH�i ¨EØ& xÑ0‰NˆF�FØ�L‰L˜ %™¨9°iÐ*@Ñ@ÔAØ�L‰L˜Õ ð	!ð $ò 	!‰NˆF�FØ�L‰L˜Ô Ø�L‰L˜Õ ð	!ñ Ü—H‘H˜VÓ$ˆEà�eˆ|Ðr   Nc                 óä  — |€
t        «       }|rt        «       }n|}g }g }t        j                  ||«      D ]  }| j                  |j                  t        |j                  «      «      }	|j                  |	«       |j                  |j                  «       |	|vsŒc|j                  j                  «       ||	<   Œ� dgt        |«      z  }
dgt        |«      z  }g }t        t        |||
|«      «      ||fS )zW
        Convert string *s* to vertices and codes using the provided ttf font.
        r   g      ð?)r   r   Úlayoutr/   Ú	ft_objectÚordÚcharÚappendr)   Úget_pathÚlenÚlistÚzip)r   r"   r:   rN   Úreturn_new_glyphs_onlyÚglyph_map_newÚ
xpositionsÚ	glyph_idsÚitemÚchar_idÚ
ypositionsÚsizesrO   s                r   rH   zTextToPath.get_glyphs_with_font„   sî   € ð ÐÜ#›ˆIá!Ü'›M‰Mà%ˆMàˆ
Øˆ	Ü!×(Ñ(¨¨DÓ1ò 	CˆDØ×'Ñ'¨¯©¼¸D¿I¹I»ÓGˆGØ×Ñ˜WÔ%Ø×Ñ˜dŸf™fÔ%Ø˜iÒ'Ø)-¯©×)@Ñ)@Ó)B�˜gÒ&ð	Cð �Sœ3˜z›?Ñ*ˆ
Ø�”s˜:“Ñ&ˆàˆä”S˜ J°
¸EÓBÓCØ˜uð&ð 	&r   c                 ó"  — |j                  «       }|j                  | j                  «       | j                  j	                  || j
                  |«      \  }}}}}	|s
t        «       }|rt        «       }
n|}
g }g }g }g }|D ]Û  \  }}}}}| j                  ||«      }||vrj|j                  «        |j                  | j                  | j
                  «       |j                  |t        j                  ¬«       |j                  «       |
|<   |j                  |«       |j                  |«       |j                  |«       || j                  z  }|j                  |«       ŒÝ g }|	D ]”  \  }}}}||f|||z   f||z   ||z   f||z   |f||fdg}t        j                  t        j                   t        j                   t        j                   t        j                   t        j"                  g}|j                  ||f«       Œ– t%        t'        ||||«      «      |
|fS )zW
        Parse mathtext string *s* and convert it to a (vertices, codes) pair.
        r2   ©r   r   )r6   r   r   r   r+   r   r   r/   ÚclearÚ	load_charr	   r%   r^   r]   r   ÚMOVETOÚLINETOÚ	CLOSEPOLYr`   ra   )r   r    r:   rN   rb   r>   r?   r@   ÚglyphsrO   rc   rd   rh   re   ri   r"   r<   r.   ÚoxÚoyrg   ÚsizeÚmyrectsrB   rC   Úvert1Úcode1s                              r   rI   zTextToPath.get_glyphs_mathtext£   só  € ð �y‰y‹{ˆØ�‰�d—o‘oÔ&à04×0DÑ0D×0JÑ0JØˆt�x‰x˜ó1Ñ-ˆˆv�w ¨ñ Ü#›ˆIá!Ü'›M‰Mà%ˆMàˆ
Øˆ
Øˆ	Øˆà-3ò 	Ñ)ˆD�(˜E 2 rØ×'Ñ'¨¨eÓ4ˆGØ˜iÑ'Ø—
‘
”Ø—‘˜dŸo™o¨t¯x©xÔ8Ø—‘˜u¬I×,@Ñ,@�ÔAØ)-¯©«�˜gÑ&à×Ñ˜bÔ!Ø×Ñ˜bÔ!Ø×Ñ˜WÔ%Ø˜dŸo™oÑ-ˆDØ�L‰L˜Õð	ð ˆØ!ò 	+‰LˆB��A�qØ˜"�X  B¨¡F˜|¨b°1©f°b¸1±fÐ-=Ø˜1‘f˜b�\ B¨ 8¨Vð5ˆEä—[‘[Ü—[‘[¤$§+¡+¬t¯{©{¼D¿K¹KÜ—^‘^ð%ˆEð �N‰N˜E 5˜>Õ*ð	+ô ”S˜ J°
¸EÓBÓCØ˜wð(ð 	(r   c                 óÈ  — t        «       j                  || j                  «      }t        j                  || j
                  «      5 }|\  }ddd«       |€
t        «       }|rt        «       }n|}g g g g f\  }	}
}}j                  D �]�  }t        |j                  «      }| j                  ||j                  «      }||vré|j                  «        |j                  | j                  | j
                  «       |j                  }t        |t         «      r3|j#                  |«      }|j%                  |t&        j(                  ¬«       nQt        |t*        «      r3| j-                  |«       |j/                  |t&        j(                  ¬«       nt1        d|›�«      ‚|j3                  «       ||<   |	j5                  |«       |
j5                  |j6                  «       |j5                  |j8                  «       |j5                  |j:                  | j                  z  «       �Œ“ g }|j<                  D ]”  \  }}}}||f||z   |f||z   ||z   f|||z   f||fdg}t>        j@                  t>        jB                  t>        jB                  t>        jB                  t>        jB                  t>        jD                  g}|j5                  ||f«       Œ– tG        tI        |	|
||«      «      ||fS # 1 sw Y   �Œ�xY w)z?Convert the string *s* to vertices and codes using usetex mode.Nr2   zGlyph spec of unexpected type: rk   )%r   Úmake_dvir   r   ÚDvir   r   Útextr   Ú	font_pathr/   Úglyphrl   r   Úglyph_name_or_indexÚ
isinstanceÚstrÚget_name_indexÚ
load_glyphr	   ÚTARGET_LIGHTÚintÚ_select_native_charmaprm   Ú	TypeErrorr^   r]   r)   ÚyÚ	font_sizeÚboxesr   rn   ro   rp   r`   ra   )r   r    r:   rN   rb   ÚdvifileÚdviÚpagerc   re   rd   rh   ri   r{   r"   rg   r~   Úindexru   rr   rs   rC   rB   rv   rw   s                            r   rG   zTextToPath.get_glyphs_texÖ   s�  € ô
 “,×'Ñ'¨¨4¯?©?Ó;ˆÜ�[‰[˜ $§(¡(Ó+ð 	¨sØ‰EˆD÷	ð ÐÜ#›ˆIá!Ü'›M‰Mà%ˆMà35°r¸2¸r°>Ñ0ˆ	�:˜z¨5ð —I‘Ió 	;ˆDÜ˜DŸN™NÓ+ˆDØ×'Ñ'¨¨d¯j©jÓ9ˆGØ˜iÑ'Ø—
‘
”Ø—‘˜dŸo™o¨t¯x©xÔ8Ø&*×&>Ñ&>Ð#ÜÐ1´3Ô7Ø ×/Ñ/Ð0CÓD�EØ—O‘O E´×1GÑ1G�OÕHÜÐ 3´SÔ9Ø×/Ñ/°Ô5Ø—N‘NØ+´9×3IÑ3Ið #õ Kô $Ð&EØ':Ð&=ð%?ó @ð @à)-¯©«�˜gÑ&à×Ñ˜WÔ%Ø×Ñ˜dŸf™fÔ%Ø×Ñ˜dŸf™fÔ%Ø�L‰L˜Ÿ™¨$¯/©/Ñ9Ö:ð-	;ð0 ˆà ŸJ™Jò 	+‰LˆB��A�qØ˜"�X  Q¡¨˜|¨b°1©f°b¸1±fÐ-=Ø˜"˜q™&�\ B¨ 8¨Vð5ˆEä—[‘[Ü—[‘[¤$§+¡+¬t¯{©{¼D¿K¹KÜ—^‘^ð%ˆEð �N‰N˜E 5˜>Õ*ð	+ô ”S˜ J°
¸EÓBÓCØ˜wð(ð 	(÷c	ñ 	ús   ÁKËK!c                 ó¢   — dD ]  }	 | j                  |«        y  t        j	                  d| j
                  «       y # t        t        f$ r Y ŒJw xY w)N)iCBDAiBODAz#No supported encoding in font (%s).)Úselect_charmapÚ
ValueErrorÚRuntimeErrorÚ_logÚwarningÚfname)r"   Úcharmap_codes     r   r…   z!TextToPath._select_native_charmap  s[   € ð
ò 	LˆLðØ×#Ñ# LÔ1ñ ð	Lô �L‰LÐ>ÀÇ
Á
ÕKøô ¤Ð-ò Ùðús   ‡<¼AÁA)F)NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r#   r&   r/   r5   rW   rH   rI   rG   Ústaticmethodr…   © r   r   r   r      sn   „ Ù1à€JØ
€Cò òò$òGò/ó0:ðx 7;Ø49ó&ð> 6:Ø38ó1(ðf 15Ø.3ó8(ðt ñLó ñLr   r   c                   óZ   ‡ — e Zd ZdZ	 	 dˆ fd„	Zd„ Zd„ Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )	ÚTextPathz&
    Create a path from the text.
    c                 ó.  •— ddl m} t        j                  |«      }|€|j	                  «       }|| _        | j                  |«       d| _         ||¬«      j                  |«      \  }}t        ‰	| �(  t        j                  |||¬«      |ddœŽ d| _        y)	a  
        Create a path from the text. Note that it simply is a path,
        not an artist. You need to use the `.PathPatch` (or other artists)
        to draw this path onto the canvas.

        Parameters
        ----------
        xy : tuple or array of two float values
            Position of the text. For no offset, use ``xy=(0, 0)``.

        s : str
            The text to convert to a path.

        size : float, optional
            Font size in points. Defaults to the size specified via the font
            properties *prop*.

        prop : `~matplotlib.font_manager.FontProperties`, optional
            Font property. If not provided, will use a default
            `.FontProperties` with parameters from the
            :ref:`rcParams<customizing-with-dynamic-rc-settings>`.

        _interpolation_steps : int, optional
            (Currently ignored)

        usetex : bool, default: False
            Whether to use tex rendering.

        Examples
        --------
        The following creates a path from the string "ABC" with Helvetica
        font face; and another path from the latex fraction 1/2::

            from matplotlib.text import TextPath
            from matplotlib.font_manager import FontProperties

            fp = FontProperties(family="Helvetica", style="italic")
            path1 = TextPath((12, 12), "ABC", size=12, prop=fp)
            path2 = TextPath((0, 0), r"$\frac{1}{2}$", size=12, usetex=True)

        Also see :doc:`/gallery/text_labels_and_annotations/demo_text_path`.
        r   )ÚTextN)Úusetex)r;   T)Ú_interpolation_stepsÚreadonlyF)Úmatplotlib.textrŸ   r   Ú	_from_anyr4   Ú_xyr   Ú_cached_verticesÚ_preprocess_mathÚsuperr   Útext_to_pathrW   Ú_should_simplify)
r   Úxyr:   rt   r    r¡   r    rŸ   r;   Ú	__class__s
            €r   r   zTextPath.__init__*  s’   ø€ õZ 	)ä×'Ñ'¨Ó-ˆØˆ<Ø×*Ñ*Ó,ˆDàˆŒØ�‰�dÔà $ˆÔÙ Ô'×8Ñ8¸Ó;‰	ˆˆ6Ü‰ÑÜ×'Ñ'¨¨a¸Ð'Ó?Ø!5Øó	ð !&ˆÕr   c                 ó    — || _         d| _        y)zSet the text size.TN)Ú_sizeÚ_invalid)r   rt   s     r   r   zTextPath.set_sizeh  s   € àˆŒ
Øˆ�r   c                 ó   — | j                   S )zGet the text size.)r®   r   s    r   Úget_sizezTextPath.get_sizem  s   € à�z‰zÐr   c                 ó:   — | j                  «        | j                  S )zH
        Return the cached path after updating it if necessary.
        )Ú_revalidate_pathr¦   r   s    r   ÚverticeszTextPath.verticesq  s   € ð
 	×ÑÔØ×$Ñ$Ð$r   c                 ó   — | j                   S )z"
        Return the codes
        )Ú_codesr   s    r   rQ   zTextPath.codesy  s   € ð
 �{‰{Ðr   c                 óP  — | j                   s| j                  €Ž t        «       j                  | j                  t
        j                  z  «      j                  | j                  Ž }|j                  | j                  «      | _        d| j                  j                  _        d| _         yy)zÇ
        Update the path if necessary.

        The path for the text is initially create with the font size of
        `.FONT_SCALE`, and this path is rescaled to other size when necessary.
        NF)r¯   r¦   r   r=   r®   r©   r   Ú	translater¥   Ú	transformÚ	_verticesr3   Ú	writeable)r   Útrs     r   r³   zTextPath._revalidate_path€  s�   € ð �=Š=˜D×1Ñ1Ð9ð”(“*ß‘5˜Ÿ™¤l×&=Ñ&=Ñ=Ó>ß‘9˜dŸh™hð(ˆBð %'§L¡L°·±Ó$@ˆDÔ!Ø49ˆD×!Ñ!×'Ñ'Ô1Ø!ˆD�Mð :r   )NNé   F)r–   r—   r˜   r™   r   r   r±   Úpropertyr´   rQ   r³   Ú__classcell__)r¬   s   @r   r�   r�   %  sM   ø„ ñð /3Ø05õ<&ò|ò
ð ñ%ó ð%ð ñó ðö"r   r�   )Úcollectionsr   ÚloggingÚurllib.parser*   ÚnumpyrK   Ú
matplotlibr   r   Úmatplotlib.font_managerr   r   r   r   Úmatplotlib.ft2fontr	   Úmatplotlib.mathtextr
   Úmatplotlib.pathr   Úmatplotlib.texmanagerr   Úmatplotlib.transformsr   Ú	getLoggerr–   r’   r   r©   r�   r›   r   r   ú<module>rÌ      sg   ðÝ #Û Û ã ç -÷ñ õ )Ý .Ý  Ý ,Ý *à€w×Ñ˜Ó"€÷KLñ KLñ\ ‹|€ôh"ˆtõ h"r   