ó
    “’¤j¥1  ã                   óä   • 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
S
S.S jjr  SS
S
S.S jjr  SS jr  SS j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    Ú¡C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\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      $ )z6Return a unique id for the given font and glyph index.Ú-Úx)ÚurllibÚparseÚquoteÚpostscript_name)r   r$   Úglyphs      r   Ú_get_glyph_reprÚTextToPath._get_glyph_repr*   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_descent.   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   N©ÚfeaturesÚlanguagec                óÒ  • US:X  a  U R                  X5      u  pgnO@U(       d%  U R                  U5      n	U R                  X’XES9u  pgnOU R                  X5      u  pgn/ / pºU H6  u  pÍpïX|   u  nnU
R	                  UU-  XÞ/-   5        UR	                  U5        M8     U H(  u  nnU
R	                  U5        UR	                  U5        M*     U
(       d  [
        R                  " S5      n
X«4$ )ah  
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.
language : str, optional
    The language of the text in a format accepted by libraqm, namely `a BCP47
    language code <https://www.w3.org/International/articles/language-tags/>`_.

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   rK   )r   é   )Úget_glyphs_texr%   Úget_glyphs_with_fontÚget_glyphs_mathtextÚextendÚnpÚempty)r   r"   r?   r@   rL   rM   Ú
glyph_infoÚ	glyph_mapÚrectsr$   ÚvertsÚcodesÚ
glyph_reprÚ	xpositionÚ	ypositionrB   Úverts1Úcodes1s                     r   Úget_text_pathÚTextToPath.get_text_pathF   só   € ðN �U‹?Ø+/×+>Ñ+>¸tÓ+GÑ(ˆJ¡5ÞØ—>‘> $Ó'ˆDØ+/×+DÑ+DØ (ð ,Eð ,?Ñ(ˆJ¡5ð ,0×+CÑ+CÀDÓ+LÑ(ˆJ 5à˜2ˆuÛ7AÑ3ˆJ 9Ø&Ñ2‰NˆF�FØ�L‰L˜ %™¨9Ð*@Ñ@ÔAØ�L‰L˜Ö ñ 8Bó $‰NˆF�FØ�L‰L˜Ô Ø�L‰L˜Ö ñ $ö Ü—H’H˜VÓ$ˆEàˆ|Ðr   c                óø  • Uc
  [        5       nU(       a  [        5       nOUn/ n/ n	/ n
[        R                  " X!XVS9 H“  nU R                  UR                  UR
                  5      nU
R                  U5        UR                  UR                  5        U	R                  UR                  5        XÃ;  d  Mw  UR                  R                  5       X|'   M•     S/[        U5      -  n/ n[        [        X¨X�5      5      X~4$ )zG
Convert string *s* to vertices and codes using the provided ttf font.
rK   g      ð?)r   r   Úlayoutr3   Ú	ft_objectÚglyph_indexÚappendr-   ÚyÚget_pathÚlenÚlistÚzip)r   r$   r?   rW   Úreturn_new_glyphs_onlyrL   rM   Úglyph_map_newÚ
xpositionsÚ
ypositionsÚglyph_reprsÚitemr[   ÚsizesrX   s                  r   rQ   ÚTextToPath.get_glyphs_with_font†   sã   € ð ÑÜ#›ˆIæ!Ü'›M‰Mà%ˆMàˆ
Øˆ
ØˆÜ!×(Ò(¨¸8ÔWˆDØ×-Ñ-¨d¯n©n¸d×>NÑ>NÓOˆJØ×Ñ˜zÔ*Ø×Ñ˜dŸf™fÔ%Ø×Ñ˜dŸf™fÔ%ØÕ*Ø,0¯N©N×,CÑ,CÓ,E�Ó)ñ Xð �”s˜:“Ñ&ˆàˆä”S˜°*ÓDÓEØð&ð 	&r   c                 ó4  • 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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_glyphr	   r(   rh   rf   r   ÚMOVETOÚLINETOÚ	CLOSEPOLYrj   rk   )r   r"   r?   rW   rl   rC   rD   rE   ÚglyphsrX   rm   rn   ro   rp   rr   r$   rA   Úccodere   ÚoxÚoyr[   ÚsizeÚmyrectsrG   rH   Úvert1Úcode1s                               r   rR   ÚTextToPath.get_glyphs_mathtext§   sâ  € ð �y‰y‹{ˆØ�‰�d—o‘oÔ&à04×0DÑ0D×0JÑ0JØ�x‰x˜ó1Ñ-ˆ�w¨ö Ü#›ˆIæ!Ü'›M‰Mà%ˆMàˆ
Øˆ
ØˆØˆã:@Ñ6ˆD�(˜E ;°°BØ×-Ñ-¨d°KÓ@ˆJØ Ó*Ø—
‘
”Ø—‘˜dŸo™o¨t¯x©xÔ8Ø—‘ ´9×3GÑ3G�ÑHØ,0¯M©M«O�˜jÑ)à×Ñ˜bÔ!Ø×Ñ˜bÔ!Ø×Ñ˜zÔ*Ø˜dŸo™oÑ-ˆDØ�L‰L˜Öñ ;Að ˆÛ!‰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˜°*ÓDÓEØ˜wð(ð 	(r   c                 óR  • [        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HL  n[        UR                  R                  5       5      nUR                  R                  (       a  [        S5      eU R                  XíR                  5      nXó;  ap  UR                  5         UR!                  U R                  U R
                  5        UR#                  UR                  [$        R&                  S9  UR)                  5       X�'   U	R+                  U5        U
R+                  UR,                  5        UR+                  UR.                  5        UR+                  UR0                  U R                  -  5        GMO     / nUR2                   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[4        R6                  [4        R8                  [4        R8                  [4        R8                  [4        R8                  [4        R:                  /nUR+                  UU45        M—     [=        [?        XšX¼5      5      UU4$ ! , (       d  f       GNU= f)z?Convert the string *s* to vertices and codes using usetex mode.Nz'Indexing TTC fonts is not supported yetr7   ru   ) r   Úmake_dvir    r   ÚDvir!   r   Útextr   r$   Úresolve_pathÚsubfontÚNotImplementedErrorr3   Úindexrv   r   rw   r	   ÚTARGET_LIGHTrh   rf   r-   rg   Ú	font_sizeÚboxesr   rx   ry   rz   rj   rk   )r   r"   r?   rW   rl   ÚdvifileÚdviÚpagerm   rp   rn   ro   rr   r‡   r$   r[   r€   r}   r~   rH   rG   r�   r‚   s                          r   rP   ÚTextToPath.get_glyphs_texÚ   s  € ô
 “,×'Ñ'¨¯?©?Ó;ˆÜ�[Š[˜§(¡(Ô+¨sØ‰EˆD÷ ,ð ÑÜ#›ˆIæ!Ü'›M‰Mà%ˆMà57¸¸RÀ°^Ñ2ˆ ð —I•IˆDÜ˜DŸI™I×2Ñ2Ó4Ó5ˆDØ�y‰y× × Ü)Ð*SÓTÐTØ×-Ñ-¨d·J±JÓ?ˆJØÓ*Ø—
‘
”Ø—‘˜dŸo™o¨t¯x©xÔ8Ø—‘ §
¡
´)×2HÑ2H�ÑIØ,0¯M©M«O�Ñ)à×Ñ˜zÔ*Ø×Ñ˜dŸf™fÔ%Ø×Ñ˜dŸf™fÔ%Ø�L‰L˜Ÿ™¨$¯/©/Ñ9×:ñ ð  ˆà Ÿ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˜°*ÓDÓEØ˜wð(ð 	(÷S ,Ö+ús   ÁJÊ
J&)r   r   )F)NF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r    r!   r   r%   r)   r3   r:   r`   rQ   rR   rP   Ú__static_attributes__© r   r   r   r      sl   † Ù1à€JØ
€Cò òò$òGò/ð0>¸tÈdö >ð@ 7;Ø49ð&ØGKØ&*ö&ðB 6:Ø38ô1(ðf 15Ø.3÷0(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_sizeS  s   € àŒ
Øˆ�r   c                 ó   • U R                   $ )zGet the text size.)r­   r   s    r   Úget_sizeÚTextPath.get_sizeX  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.vertices\  s   € ð
 	×ÑÔØ×$Ñ$Ð$r   c                 ó   • U R                   $ )z
Return the codes
)Ú_codesr   s    r   rZ   ÚTextPath.codesd  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_pathk  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µ   rZ   r´   r˜   Ú__classcell__)rª   s   @r   r›   r›     sR   ø† ñð /3Ø05÷<&ò|ò
ð ñ%ó ð%ð ñó ð÷"ð "r   r›   )Úcollectionsr   ÚloggingÚurllib.parser.   ÚnumpyrT   Ú
matplotlibr   r   Úmatplotlib.font_managerr   r   r   r   Úmatplotlib.ft2fontr	   Úmatplotlib.mathtextr
   Úmatplotlib.pathr   Úmatplotlib.texmanagerr   Úmatplotlib.transformsr   Ú	getLoggerr“   Ú_logr   r§   r›   r™   r   r   Ú<module>rÑ      sc   ðÝ #Û Û ã ç -÷ñ õ )Ý .Ý  Ý ,Ý *à×Ò˜Ó"€÷v(ñ v(ñr ‹|€ôh"ˆtõ h"r   