• File: textpath.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyc
  • Date Modified: 07/22/2015 11:41 PM
  • File size: 13.38 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

)Uc@sddlZddlmZddljZddlmZmZmZm	Z	ddl
mZddlj
Z
ddlZdefdYZddlmZddlmZdd	lmZeZd
efdYZdS(iN(tPath(tFT2FonttKERNING_DEFAULTtLOAD_NO_HINTINGtLOAD_TARGET_LIGHT(tMathTextParsert
TextToPathcBseZdZdZdZdZdZdZdZdZ	dd	Z
eed
ZdedZdedZd
ZdedZRS(sF
    A class that convert a given text to a path using ttf fonts.
    gI@iHcCsDtd|_d|_ddlm}|d|_d|_dS(s 
        Initialization
        tpathi(tmaxdicti2N(Rtmathtext_parsertNonettex_font_maptmatplotlib.cbookRt	_ps_fontdt_texmanager(tselfR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt__init__s
	cCs;tj|}tt|}|j|j|j|S(s"
        find a ttf font.
        (tfont_managertfindfontRtstrtset_sizet
FONT_SCALEtDPI(Rtproptfnametfont((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt	_get_font#scCstS(N(R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt_get_hinting_flag-scCs-|jd}tjd||f}|S(sO
        Return a unique id for the given font and character-code set.
        iiis%s-%d(iiii(tget_sfntturllibtquote(RRtccodetps_nametchar_id((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt_get_char_id0scCs-|jd}tjd||f}|S(sY
        Return a unique id for the given font and character-code set (for tex).
        is%s-%d(tget_ps_font_infoRR(RRRR R!((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt_get_char_id_ps8sgcCsgg}}x|jD]}|ddkr[|j|d|df|jtjq|ddkr|j|d|df|jtjq|ddkr|j|d|df|d|dfg|jtjtjgq|ddkrf|j|d|df|d|df|d|dfg|jtjtjtjgq|ddkr|jd|jtjqqWg|D]\}}|||f^q}||fS(	sB
        convert the ft2font glyph to vertices and codes.
        iiiiiii(ii(	RtappendRtMOVETOtLINETOtextendtCURVE3tCURVE4t	CLOSEPOLY(Rtglyphtcurrxtvertstcodeststeptxty((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt
glyph_to_pathAs,
"
)cCs3|tkrc|tkrE|j|}|j||\}}}q~|j||\}}}n|j||\}}}gg}	}
xj|D]b\}}}
}||\}}|rtj||||
g}n|	j||
j|qWx.|D]&\}}|	j||
j|qW|	|
fS(sX
        convert text *s* to path (a tuple of vertices and codes for matplotlib.math.Path).

        *prop*
          font property

        *s*
          text to be converted

        *usetex*
          If True, use matplotlib usetex mode.

        *ismath*
          If True, use mathtext parser. Effective only if usetex == False.


        (tFalseRtget_glyphs_with_fonttget_glyphs_mathtexttget_glyphs_textnptarrayR((RRtstismathtusetexRt
glyph_infot	glyph_maptrectsR.R/tglyph_idt	xpositiont	ypositiontscaletverts1tcodes1((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt
get_text_path`s"
 

cCs|j}d}d}g}g}	|dkr<t}n|rNt}
n|}
x|D]}t|}|j|}
|
dkrtd}d}
n|dk	r|j||
t}nd}|j|dt}|j	d}|j
||}||kr|j||
|<n||d7}|j||	j|||7}|
}q[Wdgt
|}dgt
|}g}t|	||||
|fS(sc
        convert the string *s* to vertices and codes using the
        provided ttf font.
        it?tflagsg@gP@g?N(tget_charmapR
tdicttordtgettget_kerningRt	load_charRtlinearHoriAdvanceR"R3R%tlentzip(RRR:R>treturn_new_glyphs_onlytcmaptlastgindR-t
xpositionst	glyph_idst
glyph_map_newtcRtgindtkernR,t
horiz_advanceR!t
ypositionstsizesR?((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyR5sB	
	




cCs2|j}|j|j|jj||j|\}}}}}	|dkr^t}n|rpt}
n|}
g}g}g}
g}d\}}x|D]\}}}}}t|}|j	||}||kr+|j
|j|j|j|j|dt}|j
||
|<n|j||j||
j|||j}|j|qWg}x|	D]\}}}}||f|||f||||f|||f||fdg}tjtjtjtjtjtjg}|j||fq}Wt|
|||||fS(s[
        convert the string *s* to vertices and codes by parsing it with mathtext.
        iRHN(ii(ii(tcopyRRR	tparseRR
RJRKR"tclearRNRR3R%RR&R'R+RQ(RRR:R>RRtwidththeighttdescenttglyphsR?RWRUR\RVR]R-tcurryRtfontsizetoxtoyRR!R,tsizetmyrectstwthtvert1tcode1((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyR6sF	!




FcCs5|jdkr.ddlm}||_n|jS(sO
        return the :class:`matplotlib.texmanager.TexManager` instance
        i(t
TexManagerN(RR
tmatplotlib.texmanagerRo(RRo((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pytget_texmanagersc#Csk|j}|jdkr9tjtjd|_n|j}t|dr|j||j	}tj
||j}n*|j||j	}	tj
|	|j}t|j}
|j|dkrt}n|rt}n|}ggggf\}}
}}x|
jD]\}}}}}|jj|j}|dkr|j|j}tt|j}y|jdWntk
r|jdnX|jrtj|j}nd}||f|j|j<n|\}}t}|j||}||krd|j |j!|j	|j|j"|d|}|j#|||<n|j$||
j$||j$||j$|j%|j	qWg}x|
j&D]\}}}} ||f|| |f|| ||f|||f||fdg}!t'j(t'j)t'j)t'j)t'j)t'j*g}"|j$|!|"fqWt+||
||||fS(s^
        convert the string *s* to vertices and codes using matplotlib's usetex mode.
        s
pdftex.maptget_dviiCBDAiRHN(ii(,RqRR
tdvireadt
PsfontsMapt
find_tex_filetget_size_in_pointsthasattrRrRtDviFromFileLikeRtmake_dvitDvititertnexttcloseRJttextR
RLttexnameRRtfilenametselect_charmapt
ValueErrortset_charmaptencodingtEncodingRR$R`RRNR3R%RitboxesRR&R'R+RQ(#RRR:R>RRt
texmanagerRftdvifileliketdvitdvifiletpageRWRVRUR\R]tx1ty1tdvifontR,Ratfont_and_encodingt
font_bunchRtenctft2font_flagR!tglyph0RjRgRhRlRkRmRn((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyR7sf

	



FN(t__name__t
__module__t__doc__RRRRRR"R$R3R4RFR
R5R6RqR7(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRs"		
				+B6	
(tFontProperties(trcParams(tAffine2DtTextPathcBszeZdZd
d
dedZdZdZdZdZ	e
eZe
e	ZdZ
dZd	ZRS(s&
    Create a path from the text.
    ic	Os|dkrt}n|dkr3|j}n||_|j|d|_|j||d|\|_|_t	|_
td|_t	|_
||_dS(sK
        Create a path from the text. No support for TeX yet. 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.

        xy : position of the text.
        s : text
        size : font size
        prop : font property
        R<spath.simplify_thresholdN(R
RRvt_xyRt_cached_verticesttext_get_vertices_codest	_verticest_codesR4tshould_simplifyRtsimplify_thresholdt
has_nonfinitet_interpolation_steps(	RtxyR:RiRRR<tkltkwargs((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRvs	
	$	
	cCs||_t|_dS(s*
        set the size of the text
        N(t_sizetTruet_invalid(RRi((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRs	cCs|jS(s*
        get the size of the text
        (R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pytget_sizescCs|j|jS(sH
        Return the cached path after updating it if necessary.
        (t_revalidate_pathR(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt
_get_verticess
cCs|jS(s"
        Return the codes
        (R(R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt
_get_codesscCsr|js|jdkrntj|jtj|jtjj|j	}|j
|j|_t|_ndS(s
        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.

        N(
RRR
RRCRttext_to_pathRt	translateRt	transformRR4(Rttr((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRs		cCsv|jd|jd}|dko5|ddk}tdrL|dfS|r\|tfS|jddtfSdS(sM
        Returns True if the given string *s* contains any mathtext.
        t$s\$iistext.usetextTeXN(tcountRRtreplaceR4(RR:tdollar_countteven_dollars((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pytis_math_texts


cCsd|r'tj||dt\}}n3|j|\}}tj||d|\}}||fS(s
        convert the string *s* to vertices and codes using the
        provided font property *prop*. Mostly copied from
        backend_svg.py.
        R<R;(RRFRR(RRR:R<R.R/t
clean_lineR;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRs
!N(RRRR
R4RRRRRtpropertytverticesR/RRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyRqs#						(Rtmatplotlib.pathRtmatplotlib.font_managerRtmatplotlib.ft2fontRRRRtmatplotlib.mathtextRtmatplotlib.dvireadRstnumpyR8tobjectRRt
matplotlibRtmatplotlib.transformsRRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/textpath.pyt<module>s"]