ó
    {ñ:iÆ3  ã                   óä   • S SK Jr  S SKrS SKrS SKrS SKJrJ	r	  S SK
JrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  \R2                  " \5      r " S
 S5      r\" 5       r " S S\5      rg)é    )ÚOrderedDictN)Ú_text_helpersÚdviread)ÚFontPropertiesÚget_fontÚfontManager)Ú	LoadFlags)ÚMathTextParser)ÚPath)Ú
TexManager)ÚAffine2Dc                   ó‚   • \ rS rSrSrSrSrS rS rS r	S r
S	 rSS
 jr  SS jr  SS jr  SS jr\S 5       rSrg)Ú
TextToPathé   z'A class that converts strings to paths.g      Y@éH   c                 ó2   • [        S5      U l        S U l        g )NÚpath)r
   Úmathtext_parserÚ_texmanager©Úselfs    ÚV/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/matplotlib/textpath.pyÚ__init__ÚTextToPath.__init__   s   € Ü-¨fÓ5ˆÔØˆÕó    c                 ó”   • [         R                  " U5      n[        U5      nUR                  U R                  U R
                  5        U$ )zH
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_fontÚTextToPath._get_font   s9   € ô !×5Ò5°dÓ;ˆ	Ü˜	Ó"ˆØ�‰�d—o‘o t§x¡xÔ0Øˆr   c                 ó"   • [         R                  $ )N)r	   Ú
NO_HINTINGr   s    r   Ú_get_hinting_flagÚTextToPath._get_hinting_flag'   s   € Ü×#Ñ#Ð#r   c                 ó`   • [         R                  R                  UR                   SUS 35      $ )z?
Return a unique id for the given font and character-code set.
Ú-Úx)ÚurllibÚparseÚquoteÚpostscript_name)r   r$   Úccodes      r   Ú_get_char_idÚTextToPath._get_char_id*   s-   € ô �|‰|×!Ñ! T×%9Ñ%9Ð$:¸!¸EÀ!¸9Ð"EÓFÐFr   c                 ó  • UR                  5       nUS:X  a  [        5       R                  X5      $ X@R                  -  nU(       aU  UR	                  5       nUR                  U R                  5        U R                  R                  USU5      tpgp‰Xe-  Xu-  X…-  4$ U R                  U5      n
U
R                  US[        R                  S9  U
R                  5       u  p¼US-  nUS-  nU
R                  5       nUS-  nXµ-  XÅ-  XÕ-  4$ )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   r:   Ú(TextToPath.get_text_width_height_descent0   sú   € Ø×*Ñ*Ó,ˆà�U‹?Ü“<×=Ñ=¸aÓJÐJàŸ?™?Ñ*ˆæØ—9‘9“;ˆDØ�M‰M˜$Ÿ/™/Ô*à×$Ñ$×*Ñ*¨1¨b°$Ó7ð 'ˆE˜7à‘= &¡.°'±/ÐAÐAà�~‰~˜dÓ#ˆØ�‰�a˜¤I×$8Ñ$8ˆÑ9Ø×$Ñ$Ó&‰ˆØ	ˆT‰	ˆØ	ˆT‰	ˆØ×ÑÓˆØ	ˆT‰	ˆØ‰y˜!™) Q¡YÐ.Ð.r   c                 óÎ  • US:X  a  U R                  X5      u  pEnOAU(       d&  U R                  U5      nU R                  Xr5      u  pEnOU R                  X5      u  pEn/ / p˜U H4  u  p«pÍXZ   u  pïUR	                  Xí-  X¼/-   5        U	R	                  U5        M6     U H'  u  pïUR	                  U5        U	R	                  U5        M)     U(       d  [
        R                  " S5      nX‰4$ )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.
r6   )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Ú	ypositionrB   Úverts1Úcodes1s                   r   Úget_text_pathÚTextToPath.get_text_pathH   sà   € ðH �U‹?Ø+/×+>Ñ+>¸tÓ+GÑ(ˆJ¡5ÞØ—>‘> $Ó'ˆDØ+/×+DÑ+DÀTÓ+MÑ(ˆJ¡5à+/×+CÑ+CÀDÓ+LÑ(ˆJ 5à˜2ˆuÛ5?Ñ1ˆH Ø&Ñ0‰NˆFØ�L‰L˜™¨9Ð*@Ñ@ÔAØ�L‰L˜Ö ñ 6@ó $‰NˆFØ�L‰L˜Ô Ø�L‰L˜Ö ñ $ö Ü—H’H˜VÓ$ˆEàˆ|Ðr   Nc                 óð  • Uc
  [        5       nU(       a  [        5       nOUn/ n/ n[        R                  " X!5       H�  nU R                  UR                  [        UR                  5      5      n	UR                  U	5        UR                  UR                  5        X“;  d  Me  UR                  R                  5       XY'   Mƒ     S/[        U5      -  n
S/[        U5      -  n/ n[        [        XvX«5      5      X\4$ )zG
Convert string *s* to vertices and codes using the provided ttf font.
r   g      ð?)r   r   Úlayoutr3   Ú	ft_objectÚordÚcharÚappendr-   Úget_pathÚlenÚlistÚzip)r   r$   r?   rT   Úreturn_new_glyphs_onlyÚglyph_map_newÚ
xpositionsÚ	glyph_idsÚitemÚchar_idÚ
ypositionsÚsizesrU   s                r   rN   ÚTextToPath.get_glyphs_with_font„   sÛ   € ð ÑÜ#›ˆIæ!Ü'›M‰Mà%ˆMàˆ
Øˆ	Ü!×(Ò(¨Ö1ˆDØ×'Ñ'¨¯©¼¸D¿I¹I»ÓGˆGØ×Ñ˜WÔ%Ø×Ñ˜dŸf™fÔ%ØÕ'Ø)-¯©×)@Ñ)@Ó)B�Ó&ñ 2ð �Sœ3˜z›?Ñ*ˆ
Ø�”s˜:“Ñ&ˆàˆä”S˜°
ÓBÓCØð&ð 	&r   c                 ó2  • UR                  5       nUR                  U R                  5        U R                  R	                  X R
                  U5      u  pVpxn	U(       d
  [        5       nU(       a  [        5       n
OUn
/ n/ n/ n/ nU HÛ  u  nnnnnU R                  UU5      nUU;  ag  UR                  5         UR                  U R                  U R
                  5        UR                  U[        R                  S9  UR                  5       U
U'   UR                  U5        UR                  U5        UR                  U5        UU R                  -  nUR                  U5        MÝ     / nU	 H•  u  nnnnUU4UUU-   4UU-   UU-   4UU-   U4UU4S/n[        R                  [        R                   [        R                   [        R                   [        R                   [        R"                  /nUR                  UU45        M—     [%        ['        XÛXÎ5      5      U
U4$ )zG
Parse mathtext string *s* and convert it to a (vertices, codes) pair.
r7   ©r   r   )r;   r   r    r   r/   r!   r   r3   ÚclearÚ	load_charr	   r(   re   rd   r   ÚMOVETOÚLINETOÚ	CLOSEPOLYrg   rh   )r   r"   r?   rT   ri   rC   rD   rE   ÚglyphsrU   rj   rk   ro   rl   rp   r$   rA   r2   ÚoxÚoyrn   ÚsizeÚmyrectsrG   rH   Úvert1Úcode1s                              r   rO   ÚTextToPath.get_glyphs_mathtext£   sß  € ð �y‰y‹{ˆØ�‰�d—o‘oÔ&à04×0DÑ0D×0JÑ0JØ�x‰x˜ó1Ñ-ˆ�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˜Öñ .4ð ˆÛ!‰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˜°
ÓBÓCØ˜wð(ð 	(r   c                 óä  • [        5       R                  X R                  5      n[        R                  " XPR
                  5       nUu  nSSS5        Uc
  [        5       nU(       a  [        5       nOUn/ / / / 4u  pšp¼WR                   GH•  n[        UR                  5      nU R                  XíR                  5      nXó;  aí  UR                  5         UR                  U R                  U R
                  5        UR                  n[        U[         5      (       a0  UR#                  U5      nUR%                  U[&        R(                  S9  OT[        U[*        5      (       a0  U R-                  U5        UR/                  U[&        R(                  S9  O[1        SU< 35      eUR3                  5       X�'   U	R5                  U5        U
R5                  UR6                  5        UR5                  UR8                  5        UR5                  UR:                  U R                  -  5        GM˜     / nUR<                   H•  u  nnnnUU4UU-   U4UU-   UU-   4UUU-   4UU4S/n[>        R@                  [>        RB                  [>        RB                  [>        RB                  [>        RB                  [>        RD                  /nUR5                  UU45        M—     [G        [I        XšX¼5      5      UU4$ ! , (       d  f       GNž= f)z?Convert the string *s* to vertices and codes using usetex mode.Nr7   zGlyph spec of unexpected type: rs   )%r   Úmake_dvir    r   ÚDvir!   r   Útextr   Ú	font_pathr3   Úglyphrt   r   Úglyph_name_or_indexÚ
isinstanceÚstrÚget_name_indexÚ
load_glyphr	   ÚTARGET_LIGHTÚintÚ_select_native_charmapru   Ú	TypeErrorre   rd   r-   ÚyÚ	font_sizeÚboxesr   rv   rw   rx   rg   rh   )r   r"   r?   rT   ri   ÚdvifileÚdviÚpagerj   rl   rk   ro   rp   r„   r$   rn   r‡   Úindexr}   rz   r{   rH   rG   r~   r   s                            r   rM   ÚTextToPath.get_glyphs_texÖ   sr  € ô
 “,×'Ñ'¨¯?©?Ó;ˆÜ�[Š[˜§(¡(Ô+¨sØ‰EˆD÷ ,ð ÑÜ#›ˆIæ!Ü'›M‰Mà%ˆMà35°r¸2¸r°>Ñ0ˆ	˜zð —I•IˆDÜ˜DŸN™NÓ+ˆDØ×'Ñ'¨¯j©jÓ9ˆGØÓ'Ø—
‘
”Ø—‘˜dŸo™o¨t¯x©xÔ8Ø&*×&>Ñ&>Ð#ÜÐ1´3×7Ñ7Ø ×/Ñ/Ð0CÓD�EØ—O‘O E´×1GÑ1G�OÒHÜÐ 3´S×9Ñ9Ø×/Ñ/°Ô5Ø—N‘NØ+´9×3IÑ3Ið #ò Kô $Ð&EØ':Ñ&=ð%?ó @ð @à)-¯©«�Ñ&à×Ñ˜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˜°
ÓBÓCØ˜wð(ð 	(÷c ,Ö+ús   ÁK Ë 
K/c                 ó¨   • S H  n U R                  U5          g    [        R	                  SU R
                  5        g ! [        [        4 a     MM  f = f)N)iCBDAiBODAz#No supported encoding in font (%s).)Úselect_charmapÚ
ValueErrorÚRuntimeErrorÚ_logÚwarningÚfname)r$   Úcharmap_codes     r   rŽ   Ú!TextToPath._select_native_charmap  sT   € ó
ˆLðØ×#Ñ# LÔ1ñ ñ
ô �L‰LÐ>ÀÇ
Á
ÕKøô ¤Ð-ó Úðús   ‡=½AÁA)r   r   )F)NF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r    r!   r   r%   r)   r3   r:   r]   rN   rO   rM   ÚstaticmethodrŽ   Ú__static_attributes__© 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                   óf   ^ • \ rS rSrSr  S
U 4S jjrS rS r\S 5       r	\S 5       r
S rS	rU =r$ )ÚTextPathi%  z
Create a path from the text.
c                 ó"  >• SSK Jn  [        R                  " U5      nUc  UR	                  5       nXl        U R                  U5        SU l        U" US9R                  U5      u  p([        T	U ](  " [        R                  XBUS9USS.6  SU l        g)	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_anyr9   Ú_xyr   Ú_cached_verticesÚ_preprocess_mathÚsuperr   Útext_to_pathr]   Ú_should_simplify)
r   Úxyr?   r|   r"   r®   r­   r¬   r@   Ú	__class__s
            €r   r   ÚTextPath.__init__*  sŒ   ø€ õZ 	)ä×'Ò'¨Ó-ˆØ‰<Ø×*Ñ*Ó,ˆDàŒØ�‰�dÔà $ˆÔÙ Ñ'×8Ñ8¸Ó;‰	ˆÜ‰ÒÜ×'Ñ'¨¸Ð'Ð?Ø!5Øó	ð !&ˆÕr   c                 ó   • Xl         SU l        g)zSet the text size.TN)Ú_sizeÚ_invalid)r   r|   s     r   r   ÚTextPath.set_sizeh  s   € àŒ
Øˆ�r   c                 ó   • U R                   $ )zGet the text size.)r¼   r   s    r   Úget_sizeÚTextPath.get_sizem  s   € à�z‰zÐr   c                 ó:   • U R                  5         U R                  $ )z8
Return the cached path after updating it if necessary.
)Ú_revalidate_pathr³   r   s    r   ÚverticesÚTextPath.verticesq  s   € ð
 	×ÑÔØ×$Ñ$Ð$r   c                 ó   • U R                   $ )z
Return the codes
)Ú_codesr   s    r   rW   ÚTextPath.codesy  s   € ð
 �{‰{Ðr   c                 ó\  • U R                   (       d  U R                  cŽ  [        5       R                  U R                  [
        R                  -  5      R                  " U R                  6 nUR                  U R                  5      U l        SU R                  R                  l        SU l         gg)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   rB   r¼   r¶   r    Ú	translater²   Ú	transformÚ	_verticesr8   Ú	writeable)r   Útrs     r   rÃ   ÚTextPath._revalidate_path€  sƒ   € ð �=�=˜D×1Ñ1Ñ9Ü“*ß‘5˜Ÿ™¤l×&=Ñ&=Ñ=Ó>ß‘9ðà"Ÿh™hð(ˆBð %'§L¡L°·±Ó$@ˆDÔ!Ø49ˆD×!Ñ!×'Ñ'Ô1Ø!ˆD�Mð :r   )r³   r½   r·   r¼   r²   )NNé   F)r¡   r¢   r£   r¤   r¥   r   r   rÀ   ÚpropertyrÄ   rW   rÃ   r§   Ú__classcell__)r¹   s   @r   rª   rª   %  sR   ø† ñð /3Ø05÷<&ò|ò
ð ñ%ó ð%ð ñó ð÷"ð "r   rª   )Úcollectionsr   ÚloggingÚurllib.parser.   ÚnumpyrQ   Ú
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ß      se   ðÝ #Û Û ã ç -÷ñ õ )Ý .Ý  Ý ,Ý *à×Ò˜Ó"€÷KLñ KLñ\ ‹|€ôh"ˆtõ h"r   