§
    †Ûgî4  ã                   óü   — d dl mZ d dlZd dlZd dlZd dlmZm	Z	m
Z
 d dlmZmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ  ej        e¦  «        Z G d
„ d¦  «        Z e¦   «         Z G d„ de¦  «        Z dS )é    )ÚOrderedDictN)Ú_apiÚ_text_helpersÚdviread)ÚFontPropertiesÚget_fontÚfontManager)ÚLOAD_NO_HINTINGÚLOAD_TARGET_LIGHT)ÚMathTextParser)ÚPath)Ú
TexManager)ÚAffine2Dc                   ó°   — 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 ej        dd¬¦  «        d„ ¦   «         Z	 	 dd„Zed„ ¦   «         ZdS )Ú
TextToPathz'A class that converts strings to paths.g      Y@éH   c                 ó<   — t          d¦  «        | _        d | _        d S )NÚpath)r   Úmathtext_parserÚ_texmanager©Úselfs    úI/granary/edev/quantum/lib/python3.11/site-packages/matplotlib/textpath.pyÚ__init__zTextToPath.__init__   s    € Ý-¨fÑ5Ô5ˆÔØˆÔÐÐó    c                 óŒ   — t          j        |¦  «        }t          |¦  «        }|                     | 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   s>   € õ !Ô5°dÑ;Ô;ˆ	Ý˜	Ñ"Ô"ˆØ�Š�d”o t¤xÑ0Ô0Ð0Øˆr   c                 ó   — t           S )N)r
   r   s    r   Ú_get_hinting_flagzTextToPath._get_hinting_flag'   s   € ÝÐr   c                 óV   — t           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Ð"EÐ"E¸EÐ"EÐ"EÐ"EÑFÔFÐFr   c                 ó>  — |                      ¦   «         }|dk    r"t          ¦   «                              ||¦  «        S || j        z  }|r\|                     ¦   «         }|                     | j        ¦  «         | j                             |d|¦  «        ^}}}}	||z  ||z  ||z  fS |                      |¦  «        }
|
 	                    |dt          ¬¦  «         |
                     ¦   «         \  }}|dz  }|dz  }|
                     ¦   «         }|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
   Úget_width_heightÚget_descent)r   Úsr"   ÚismathÚfontsizeÚscaleÚwidthÚheightÚdescentÚ_r$   ÚwÚhÚds                 r   r6   z(TextToPath.get_text_width_height_descent0   s-  € Ø×*Ò*Ñ,Ô,ˆà�UŠ?ˆ?Ý‘<”<×=Ò=¸aÀÑJÔJÐJà˜4œ?Ñ*ˆàð 	BØ—9’9‘;”;ˆDØ�MŠM˜$œ/Ñ*Ô*Ð*àÔ$×*Ò*¨1¨b°$Ñ7Ô7ð 'ˆE�6˜7 Qà˜5‘= &¨5¡.°'¸E±/ÐAÐAà�~Š~˜dÑ#Ô#ˆØ�Š�a˜¥OˆÑ4Ô4Ð4Ø×$Ò$Ñ&Ô&‰ˆˆ1Ø	ˆT‰	ˆØ	ˆT‰	ˆØ×ÒÑÔˆØ	ˆT‰	ˆØ�5‰y˜!˜e™) Q¨¡YÐ.Ð.r   Fc                 ó
  — |dk    r|                       ||¦  «        \  }}}nL|s0|                      |¦  «        }|                      ||¦  «        \  }}}n|                      ||¦  «        \  }}}g g }	}|D ]D\  }
}}}||
         \  }}|                     ||z  ||gz   ¦  «         |	                     |¦  «         ŒE|D ]/\  }}|                     |¦  «         |	                     |¦  «         Œ0|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 numpy arrays containing the x and 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="Humor Sans", 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.
        r2   )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   sA  € ðP �UŠ?ˆ?Ø+/×+>Ò+>¸tÀQÑ+GÔ+GÑ(ˆJ˜	 5 5Øð 	MØ—>’> $Ñ'Ô'ˆDØ+/×+DÒ+DÀTÈ1Ñ+MÔ+MÑ(ˆJ˜	 5 5à+/×+CÒ+CÀDÈ!Ñ+LÔ+LÑ(ˆJ˜	 5à˜2ˆuˆØ5?ð 	!ð 	!Ñ1ˆH�i ¨EØ& xÔ0‰NˆF�FØ�LŠL˜ %™¨9°iÐ*@Ñ@ÑAÔAÐAØ�LŠL˜Ñ Ô Ð Ð Ø#ð 	!ð 	!‰NˆF�FØ�LŠL˜Ñ Ô Ð Ø�LŠL˜Ñ Ô Ð Ð ð ð 	%Ý”H˜VÑ$Ô$ˆEà�eˆ|Ðr   Nc                 ó  — |€t          ¦   «         }|rt          ¦   «         }n|}g }g }t          j        ||¦  «        D ]~}|                      |j        t          |j        ¦  «        ¦  «        }	|                     |	¦  «         |                     |j        ¦  «         |	|vr|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.
        Nr   g      ð?)r   r   Úlayoutr0   Ú	ft_objectÚordÚcharÚappendr*   Úget_pathÚlenÚlistÚzip)r   r$   r;   rO   Úreturn_new_glyphs_onlyÚglyph_map_newÚ
xpositionsÚ	glyph_idsÚitemÚchar_idÚ
ypositionsÚsizesrP   s                r   rI   zTextToPath.get_glyphs_with_fontˆ   s  € ð ÐÝ#™œˆIà!ð 	&Ý'™MœMˆMˆMà%ˆMàˆ
Øˆ	Ý!Ô(¨¨DÑ1Ô1ð 	Cð 	CˆDØ×'Ò'¨¬½¸D¼I¹¼ÑGÔGˆGØ×Ò˜WÑ%Ô%Ð%Ø×Ò˜dœfÑ%Ô%Ð%Ø˜iÐ'Ð'Ø)-¬×)@Ò)@Ñ)BÔ)B�˜gÑ&øà�S�3˜z™?œ?Ñ*ˆ
Ø�•s˜:‘”Ñ&ˆàˆå•S˜ J°
¸EÑBÔBÑCÔCØ˜uð&ð 	&r   c                 ó$  — |                      ¦   «         }|                     | j        ¦  «         | j                             || j        |¦  «        \  }}}}}	|st          ¦   «         }|rt          ¦   «         }
n|}
g }g }g }g }|D ]ç\  }}}}}|                      ||¦  «        }||vrg|                     ¦   «          |                     | j        | j        ¦  «         | 	                    |t          ¬¦  «         |                     ¦   «         |
|<   |                     |¦  «         |                     |¦  «         |                     |¦  «         || j        z  }|                     |¦  «         Œè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}|                     ||f¦  «         Œ�t#          t%          ||||¦  «        ¦  «        |
|fS )zW
        Parse mathtext string *s* and convert it to a (vertices, codes) pair.
        r3   ©r   r   )r7   r   r    r   r,   r!   r   r0   ÚclearÚ	load_charr
   r_   r^   r   ÚMOVETOÚLINETOÚ	CLOSEPOLYra   rb   )r   r"   r;   rO   rc   r?   r@   rA   ÚglyphsrP   rd   re   ri   rf   rj   r$   r=   r/   ÚoxÚoyrh   ÚsizeÚmyrectsrC   rD   Úvert1Úcode1s                              r   rJ   zTextToPath.get_glyphs_mathtext§   s/  € ð �yŠy‰{Œ{ˆØ�Š�d”oÑ&Ô&Ð&à04Ô0D×0JÒ0JØˆtŒx˜ñ1ô 1Ñ-ˆˆv�w ¨ð ð 	&Ý#™œˆIà!ð 	&Ý'™MœMˆMˆMà%ˆMàˆ
Øˆ
Øˆ	Øˆà-3ð 	ð 	Ñ)ˆD�(˜E 2 rØ×'Ò'¨¨eÑ4Ô4ˆGØ˜iÐ'Ð'Ø—
’
‘”�Ø—’˜dœo¨t¬xÑ8Ô8Ð8Ø—’˜u­O�Ñ<Ô<Ð<Ø)-¯ª©¬�˜gÑ&à×Ò˜bÑ!Ô!Ð!Ø×Ò˜bÑ!Ô!Ð!Ø×Ò˜WÑ%Ô%Ð%Ø˜dœ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Ý”^ð%ˆEð �NŠN˜E 5˜>Ñ*Ô*Ð*Ð*å•S˜ J°
¸EÑBÔBÑCÔCØ˜wð(ð 	(r   z3.6zTexManager())Úalternativec                 óD   — | j         €t          ¦   «         | _         | j         S )z5Return the cached `~.texmanager.TexManager` instance.)r   r   r   s    r   Úget_texmanagerzTextToPath.get_texmanagerÚ   s"   € ð ÔÐ#Ý)™|œ|ˆDÔØÔÐr   c                 ó¨  — t          ¦   «                              || j        ¦  «        }t          j        || j        ¦  «        5 }|\  }ddd¦  «         n# 1 swxY w Y   |€t          ¦   «         }|rt          ¦   «         }n|}g g g g f\  }	}
}}|j        D �]“}t          |j	        ¦  «        }|  
                    ||j        ¦  «        }||vrò|                     ¦   «          |                     | j        | j        ¦  «         |j        }t          |t           ¦  «        r2|                     |¦  «        }|                     |t&          ¬¦  «         nYt          |t(          ¦  «        r2|                      |¦  «         |                     |t&          ¬¦  «         nt/          d|›�¦  «        ‚|                     ¦   «         ||<   |	                     |¦  «         |
                     |j        ¦  «         |                     |j        ¦  «         |                     |j        | j        z  ¦  «         �Œ•g }|j        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}|                     ||f¦  «         Œ�tE          tG          |	|
||¦  «        ¦  «        ||fS )z?Convert the string *s* to vertices and codes using usetex mode.Nr3   zGlyph spec of unexpected type: rl   )$r   Úmake_dvir    r   ÚDvir!   r   Útextr   Ú	font_pathr0   Úglyphrm   r   Úglyph_name_or_indexÚ
isinstanceÚstrÚget_name_indexÚ
load_glyphr   ÚintÚ_select_native_charmaprn   Ú	TypeErrorr_   r^   r*   ÚyÚ	font_sizeÚboxesr   ro   rp   rq   ra   rb   )r   r"   r;   rO   rc   ÚdvifileÚdviÚpagerd   rf   re   ri   rj   r   r$   rh   r‚   Úindexrv   rs   rt   rD   rC   rw   rx   s                            r   rH   zTextToPath.get_glyphs_texá   s'  € õ
 ‘,”,×'Ò'¨¨4¬?Ñ;Ô;ˆÝŒ[˜ $¤(Ñ+Ô+ð 	¨sØ‰EˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð ÐÝ#™œˆIà!ð 	&Ý'™MœMˆMˆMà%ˆMà35°r¸2¸r°>Ñ0ˆ	�:˜z¨5ð ”Ið 	;ñ 	;ˆDÝ˜DœNÑ+Ô+ˆDØ×'Ò'¨¨d¬jÑ9Ô9ˆGØ˜iÐ'Ð'Ø—
’
‘”�Ø—’˜dœo¨t¬xÑ8Ô8Ð8Ø&*Ô&>Ð#ÝÐ1µ3Ñ7Ô7ð 	@Ø ×/Ò/Ð0CÑDÔD�EØ—O’O EÕ1B�OÑCÔCÐCÐCÝÐ 3µSÑ9Ô9ð @Ø×/Ò/°Ñ5Ô5Ð5Ø—N’NØ+Õ3Dð #ñ Fô Fð Fð Fõ $ð %?Ø':ð%?ð %?ñ @ô @ð @à)-¯ª©¬�˜gÑ&à×Ò˜WÑ%Ô%Ð%Ø×Ò˜dœfÑ%Ô%Ð%Ø×Ò˜dœfÑ%Ô%Ð%Ø�LŠL˜œ¨$¬/Ñ9Ñ:Ô:Ð:Ñ:àˆà œJð 	+ð 	+‰LˆB��A�qØ˜"�X  Q¡¨˜|¨b°1©f°b¸1±fÐ-=Ø˜"˜q™&�\ B¨ 8¨Vð5ˆEå”[Ý”[¥$¤+­t¬{½D¼KÝ”^ð%ˆEð �NŠN˜E 5˜>Ñ*Ô*Ð*Ð*å•S˜ J°
¸EÑBÔBÑCÔCØ˜wð(ð 	(s   ÁAÁAÁAc                 ó®   — dD ]1}	 |                       |¦  «          d S # t          t          f$ r Y Œ.w xY wt                               d| j        ¦  «         d S )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ðØ×#Ò# LÑ1Ô1Ð1ð ��øõ ¥Ð-ð ð ð Ø�ðøøøõ
 �LŠLÐ>ÀÄ
ÑKÔKÐKÐKÐKs   †ž2±2)F)NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r!   r   r%   r'   r0   r6   rX   rI   rJ   r   Ú
deprecatedr{   rH   Ústaticmethodrˆ   © r   r   r   r      s*  € € € € € Ø1Ð1à€JØ
€Cð ð  ð  ðð ð ðð ð ðGð Gð Gð/ð /ð /ð0>ð >ð >ð >ð@ 7;Ø49ð&ð &ð &ð &ð> 6:Ø38ð1(ð 1(ð 1(ð 1(ðf €T„_�U¨Ð7Ñ7Ô7ð ð  ñ 8Ô7ð ð 15Ø.3ð8(ð 8(ð 8(ð 8(ðt ðLð Lñ „\ðLð Lð Lr   r   c                   óf   ‡ — 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.
    Né   Fc                 ój  •— ddl m} t          j        |¦  «        }|€|                     ¦   «         }|| _        |                      |¦  «         d| _         ||¬¦  «                             |¦  «        \  }} t          ¦   «         j
        t                               |||¬¦  «        |ddœŽ d| _        dS )	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_anyr5   Ú_xyr   Ú_cached_verticesÚ_preprocess_mathÚsuperr   Útext_to_pathrX   Ú_should_simplify)
r   Úxyr;   ru   r"   r¦   r¥   r¤   r<   Ú	__class__s
            €r   r   zTextPath.__init__5  sÑ   ø€ ðZ 	)Ð(Ð(Ð(Ð(Ð(åÔ'¨Ñ-Ô-ˆØˆ<Ø×*Ò*Ñ,Ô,ˆDàˆŒØ�Š�dÑÔÐà $ˆÔØ�D Ð'Ñ'Ô'×8Ò8¸Ñ;Ô;‰	ˆˆ6Ø�‰ŒÔÝ×'Ò'¨¨a¸Ð'Ñ?Ô?Ø!5Øð	ð 	ð 	ð 	ð !&ˆÔÐÐr   c                 ó"   — || _         d| _        dS )zSet the text size.TN)Ú_sizeÚ_invalid)r   ru   s     r   r   zTextPath.set_sizes  s   € àˆŒ
ØˆŒˆˆr   c                 ó   — | j         S )zGet the text size.)r³   r   s    r   Úget_sizezTextPath.get_sizex  s
   € àŒzÐr   c                 ó8   — |                       ¦   «          | j        S )zH
        Return the cached path after updating it if necessary.
        )Ú_revalidate_pathr«   r   s    r   ÚverticeszTextPath.vertices|  s   € ð
 	×ÒÑÔÐØÔ$Ð$r   c                 ó   — | j         S )z"
        Return the codes
        )Ú_codesr   s    r   rR   zTextPath.codes„  s   € ð
 Œ{Ðr   c                 ó  — | j         s| j        €y t          ¦   «                              | j        t
          j        z  ¦  «        j        | j        Ž }| 	                    | j
        ¦  «        | _        d| j        j        _        d| _         dS dS )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Ú	_verticesr4   Ú	writeable)r   Útrs     r   r¸   zTextPath._revalidate_path‹  s   € ð Œ=ð 	"˜DÔ1Ð9ð•(‘*”*ß’5˜œ¥lÔ&=Ñ=Ñ>Ô>Ü˜dœhð(ˆBð %'§L¢L°´Ñ$@Ô$@ˆDÔ!Ø49ˆDÔ!Ô'Ô1Ø!ˆDŒMˆMˆMð :Ð9r   )NNr¢   F)r™   rš   r›   rœ   r   r   r¶   Úpropertyr¹   rR   r¸   Ú__classcell__)r±   s   @r   r¡   r¡   0  s³   ø€ € € € € ðð ð /3Ø05ð<&ð <&ð <&ð <&ð <&ð <&ð|ð ð ð
ð ð ð ð%ð %ñ „Xð%ð ðð ñ „Xðð"ð "ð "ð "ð "ð "ð "r   r¡   )!Úcollectionsr   ÚloggingÚurllib.parser+   ÚnumpyrL   Ú
matplotlibr   r   r   Úmatplotlib.font_managerr   r   r	   r   Úmatplotlib.ft2fontr
   r   Úmatplotlib.mathtextr   Úmatplotlib.pathr   Úmatplotlib.texmanagerr   Úmatplotlib.transformsr   Ú	getLoggerr™   r•   r   r®   r¡   rŸ   r   r   ú<module>rÐ      s�  ðØ #Ð #Ð #Ð #Ð #Ð #Ø €€€Ø Ð Ð Ð à Ð Ð Ð à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð BÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ .Ð .Ð .Ð .Ð .Ð .Ø  Ð  Ð  Ð  Ð  Ð  Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø *Ð *Ð *Ð *Ð *Ð *à€wÔ˜Ñ"Ô"€ðVLð VLð VLð VLð VLñ VLô VLð VLðr ˆz‰|Œ|€ðh"ð h"ð h"ð h"ð h"ˆtñ h"ô h"ð h"ð h"ð h"r   