)Uc@ s;dZddlmZddlZddlmZddlmZyeWn!e k rmddl m ZnXddl Z ddl mZddlmZmZddlZdd lmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$e$j%dd l&m'Z'dd l(m)Z)m*Z*m+Z+m,Z,dd l-m.Z.m/Z/m0Z0m1Z1m2Z2dd l3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;ddl<m=Z=m>Z>ddl?j@ZAddlBjCZCdZDdZEdeFfdYZGdeGfdYZHdeGfdYZIdZJdeIfdYZKdZLdeGfdYZMdeGfdYZNd eGfd!YZOd"eGfd#YZPd$eGfd%YZQd&eFfd'YZRd(eRfd)YZSd*eSfd+YZTd,eSfd-YZUd.eUfd/YZVd0eVfd1YZWd2eRfd3YZXd4ZYd5eYZZd6Z[d7Z\d8Z]d9Z^d:Z_d;Z`d<eafd=YZbd>eFfd?YZcd@ecfdAYZddBedfdCYZedDedfdEYZfdFecfdGYZgdHegfdIYZhdJedfdKYZidLeifdMYZjdNeifdOYZkdPedfdQYZldRelfdSYZmdTelfdUYZndVecfdWYZodXeFfdYYZpiepd:d5dZd:d[d\6epd:d5d]d:d[d^6epd:d5d_d:d[d`6epd:d:d[d5dZda6epd:d:d[d5d]db6epd:d:d[d5d_dc6epd:d:d[d:d[dd6epd:d5dZdedZdf6ep_qdgeofdhYZrdieofdjYZsdkeofdlYZtdmeofdnYZudoeofdpYZvdqeofdrYZwdseofdtYZxduejfdvYZydwejfdxYZzdyecfdzYZ{d{ejfd|YZ|d}ejfd~YZ}dejfdYZ~deFfdYZeZdZdeFfdYZdeFfdYZdS(s :mod:`~matplotlib.mathtext` is a module for parsing a subset of the TeX math syntax and drawing them to a matplotlib backend. For a tutorial of its usage see :ref:`mathtext-tutorial`. This document is primarily concerned with implementation details. The module uses pyparsing_ to parse the TeX expression. .. _pyparsing: http://pyparsing.wikispaces.com/ The Bakoma distribution of the TeX Computer Modern fonts, and STIX fonts are supported. There is experimental support for using arbitrary fonts, but results may vary without proper tweaking and metrics for those fonts. If you find TeX expressions that don't parse or render properly, please email mdroe@stsci.edu, but please check KNOWN ISSUES below first. i(tdivisionN(tStringIO(tceil(tSet(twarn(tinftisinf(tCombinetGrouptOptionaltForwardtLiteralt OneOrMoret ZeroOrMoretParseExceptiontEmptyt ParseResultstSuppresstoneOft StringEndtParseFatalExceptiont FollowedBytRegext ParserElement(tAFM(tBunchtget_realpath_and_stattis_string_liketmaxdict(tFT2FonttFT2ImagetKERNING_DEFAULTtLOAD_FORCE_AUTOHINTtLOAD_NO_HINTING(tfindfonttFontProperties(tlatex_to_bakomatlatex_to_standardttex2unit latex_to_cmextstix_virtual_fonts(t get_data_pathtrcParamscC su|dkrdSyt|SWntk r1nXyt|jdSWn'tk rpdt}t|nXdS(sget_unicode_index(symbol) -> integer Return the integer index (from the Unicode table) of symbol. *symbol* can be a single unicode character, a TeX command (i.e. r'\pi'), or a Type1 symbol name (i.e. 'phi'). t-i"s\sA'%(symbol)s' is not a valid Unicode character or TeX/Type1 symbolN(tordt TypeErrorR&tstriptKeyErrortlocalst ValueError(tsymboltmessage((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytget_unicode_index<s    cC s-yt|SWntk r(tdSXdS(sReturn the Unicode character corresponding to the index, or the replacement character if this is a narrow build of Python and the requested character is outside the BMP.iN(tunichrR1(tindex((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt unichr_safeUs tMathtextBackendcB sDeZdZdZdZdZdZdZdZRS(s The base class for the mathtext backend-specific code. The purpose of :class:`MathtextBackend` subclasses is to interface between mathtext and a specific matplotlib graphics backend. Subclasses need to override the following: - :meth:`render_glyph` - :meth:`render_filled_rect` - :meth:`get_results` And optionally, if you need to use a Freetype hinting style: - :meth:`get_hinting_type` cC s d|_dS(N(tNonet fonts_object(tself((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt__init__nscC s||_||_||_dS(sDimension the drawing canvasN(twidththeighttdepth(R;twthtd((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytset_canvas_sizeqs  cC s tdS(s_ Draw a glyph described by *info* to the reference point (*ox*, *oy*). N(tNotImplementedError(R;toxtoytinfo((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt render_glyphwscC s tdS(sR Draw a filled black rectangle from (*x1*, *y1*) to (*x2*, *y2*). N(RD(R;tx1ty1tx2ty2((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytrender_filled_rect~scC s tdS(sp Return a backend-specific tuple to return to the backend after all processing is done. N(RD(R;tbox((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt get_resultsscC stS(s\ Get the Freetype hinting type to use with this particular backend. (R!(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytget_hinting_types( t__name__t __module__t__doc__R<RCRHRMRORP(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR8^s     tMathtextBackendBboxcB sMeZdZdZdZdZdZdZdZdZ RS(so A backend whose only purpose is to get a precise bounding box. Only required for the Agg backend. cC s/tj|ddddg|_||_dS(Ni(R8R<tbboxt real_backend(R;RV((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s cC sYt|jd|t|jd|t|jd|t|jd|g|_dS(Niiii(tminRUtmax(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt _update_bboxscC sB|j||jj||jj||jj||jjdS(N(RYtmetricstxmintymaxtxmaxtymin(R;RERFRG((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHs  cC s|j||||dS(N(RY(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytrender_rect_filledscC s|j}|j}tdd||j}|dd|dd|dd|ddg}|j|jj|d|d|d|d||d|d|t|d |d ||jj|S(Niiii(R>R?tshipRUt_switch_to_real_backendR:RCRO(R;RNt orig_heightt orig_depthRU((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROs   2  cC s |jjS(N(RVRP(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRPscC sH|j|j_|j|j_|jd|j_|jd|j_dS(Nii(RVR:tmathtext_backendRURERF(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRas( RQRRRSR<RYRHR_RORPRa(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRTs      tMathtextBackendAggRendercB sDeZdZdZdZdZdZdZdZRS(s Render glyphs and rectangles to an FTImage buffer, which is later transferred to the Agg image by the Agg backend. cC s,d|_d|_d|_tj|dS(Ni(RERFR9timageR8R<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s   cC s<tj||||tt|t|||_dS(N(R8RCRRRf(R;R@RARB((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRCscC s-|jj|j|||jj|jdS(N(tfonttdraw_glyph_to_bitmapRfRZticebergtglyph(R;RERFRG((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHs cC stt||dd}|dkrR||d}t||dd}n t|}|jjt||t|||dS(Niig@(RXtintRftdraw_rect_filledR(R;RIRJRKRLR>tcenterty((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_s   cC s;|j|j|j|j|j|j|j|jjfS(N(RERFR=R>R?RfR:tget_used_characters(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROs cC stdrtStSdS(Ns text.hinting(R*R R!(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRPs ( RQRRRSR<RCRHR_RORP(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRes    cC s ttS(N(RTRe(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytMathtextBackendAggstMathtextBackendBitmapRendercB seZdZRS(cC s|j|jfS(N(RfR?(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROs(RQRRRO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRqscC s ttS(sn A backend to generate standalone mathtext images. No additional matplotlib backend is required. (RTRq(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytMathtextBackendBitmapstMathtextBackendPscB s2eZdZdZdZdZdZRS(sX Store information to write a mathtext rendering to the PostScript backend. cC st|_d|_dS(N(RtpswriterR9tlastfont(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s cC s|j||j}|j}|j}|j}||f|jkrsdt}||f|_|jj|ndt}|jj|dS(Ns=/%(postscript_name)s findfont %(fontsize)s scalefont setfont s1%(ox)f %(oy)f moveto /%(symbol_name)s glyphshow ( R>toffsettpostscript_nametfontsizet symbol_nameRuR0Rttwrite(R;RERFRGRwRxRytps((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHs     cC s9d||j|||||f}|jj|dS(Ns%f %f %f %f rectfill (R>RtRz(R;RIRJRKRLR{((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_s%cC sCtd|j ||j|j|j|j|j|jjfS(Ni(R`R?R=R>RtR:Ro(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROs  (RQRRRSR<RHR_RO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRss    tMathtextBackendPdfcB s2eZdZdZdZdZdZRS(sQ Store information to write a mathtext rendering to the PDF backend. cC sg|_g|_dS(N(tglyphstrects(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<*s cC sO|jj}|j||j}|jj||||j|j|jfdS(N( RgtfnameR>RvR}tappendRxtnumRy(R;RERFRGtfilename((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRH.s   cC s/|jj||j|||||fdS(N(R~RR>(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_5scC sItd|j ||j|j|j|j|j|j|jjfS(Ni(R`R?R=R>R}R~R:Ro(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRO8s (RQRRRSR<RHR_RO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR|%s    tMathtextBackendSvgcB s2eZdZdZdZdZdZRS(sQ Store information to write a mathtext rendering to the SVG backend. cC sg|_g|_dS(N(t svg_glyphst svg_rects(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<Fs cC sR|j||j}t|j}|jj|j|j||||jfdS(N( R>RvR7RRRRgRxRZ(R;RERFRGtthetext((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHJs cC s3|jj||j|d||||fdS(Ni(RRR>(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_Qs cC s[td|j |td|jd|j}|j|j|j|j||jjfS(NiRR( R`R?RRRR=R>R:Ro(R;RNt svg_elements((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROUs  (RQRRRSR<RHR_RO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRAs    tMathtextBackendPathcB s2eZdZdZdZdZdZRS(sS Store information to write a mathtext rendering to the Cairo backend. cC sg|_g|_dS(N(R}R~(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<es cC sL|j||j}t|j}|jj|j|j|||fdS(N(R>RvR7RR}RRgRx(R;RERFRGR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHis cC s/|jj||j|||||fdS(N(R~RR>(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_os cC s=td|j ||j|j|j|j|j|jfS(Ni(R`R?R=R>R}R~(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROss  (RQRRRSR<RHR_RO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_s    tMathtextBackendCairocB s2eZdZdZdZdZdZRS(sS Store information to write a mathtext rendering to the Cairo backend. cC sg|_g|_dS(N(R}R~(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s cC sL||j|j}t|j}|jj|j|j|||fdS(N(RvR>R7RR}RRgRx(R;RERFRGR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHs cC s/|jj|||j||||fdS(N(R~RR>(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_s cC s=td|j ||j|j|j|j|j|jfS(Ni(R`R?R=R>R}R~(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyROs  (RQRRRSR<RHR_RO(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR{s    tFontscB szeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( s An abstract base class for a system of fonts to use for mathtext. The class must be able to take symbol keys and font file names and return the character metrics. It also delegates to a backend class to do the actual drawing. cC s+||_||_||j_i|_dS(sH *default_font_prop*: A :class:`~matplotlib.font_manager.FontProperties` object to use for the default non-math font, or the base font for Unicode (generic) font rendering. *mathtext_backend*: A subclass of :class:`MathTextBackend` used to delegate the actual rendering. N(tdefault_font_propRdR:tused_characters(R;RRd((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s   cC s d|_dS(sa Fix any cyclical references before the object is about to be destroyed. N(R9R(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytdestroysc C sdS(su Get the kerning distance for font between *sym1* and *sym2*. *fontX*: one of the TeX font names:: tt, it, rm, cal, sf, bf or default/regular (non-math) *fontclassX*: TODO *symX*: a symbol in raw TeX form. e.g. '1', 'x' or '\sigma' *fontsizeX*: the fontsize in points *dpi*: the current dots-per-inch g(( R;tfont1t fontclass1tsym1t fontsize1tfont2t fontclass2tsym2t fontsize2tdpi((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytget_kernscC s"|j|||||}|jS(s *font*: one of the TeX font names:: tt, it, rm, cal, sf, bf or default/regular (non-math) *font_class*: TODO *sym*: a symbol in raw TeX form. e.g. '1', 'x' or '\sigma' *fontsize*: font size in points *dpi*: current dots-per-inch Returns an object with the following attributes: - *advance*: The advance distance (in points) of the glyph. - *height*: The height of the glyph in points. - *width*: The width of the glyph in points. - *xmin*, *xmax*, *ymin*, *ymax* - the ink rectangle of the glyph - *iceberg* - the distance from the baseline to the top of the glyph. This corresponds to TeX's definition of "height". (t _get_infoRZ(R;Rgt font_classtsymRxRRG((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt get_metricsscC sRt|t|t||_|_|_|jj|j|j|jdS(s Set the size of the buffer used to render the math expression. Only really necessary for the bitmap backends. N(RR=R>R?RdRC(R;R@RARB((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRCs/c C s|j|||||}t|jj\} } |jj| | tf} | dj|j|j j |||dS(s Draw a glyph at - *ox*, *oy*: position - *facename*: One of the TeX face names - *font_class*: - *sym*: TeX symbol name or single character - *fontsize*: fontsize in points - *dpi*: The dpi to draw at. iN( RRRgRRt setdefaulttsettaddRRdRH( R;RERFtfacenameRRRxRRGtrealpathtstat_keyR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRHs  cC s|jj||||dS(sL Draw a filled rectangle from (*x1*, *y1*) to (*x2*, *y2*). N(RdR_(R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_scC s tdS(sF Get the xheight for the given *font* and *fontsize*. N(RD(R;RgRxR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt get_xheightscC s tdS(s Get the line thickness that matches the given font. Used as a base unit for drawing lines such as in a fraction or radical. N(RD(R;RgRxR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytget_underline_thicknessscC s|jS(s Get the set of characters that were used in the math expression. Used by backends that need to subset fonts so they know which glyphs to include. (R(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRoscC s|jj|S(s Get the data needed by the backend to render the math expression. The return value is backend-specific. (RdRO(R;RN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRO#scC s ||fgS(s Override if your font provides multiple sizes of the same symbol. Should return a list of symbols matching *sym* in various sizes. The expression renderer will select the most appropriate size for a given situation from this list. ((R;tfontnameR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt!get_sized_alternatives_for_symbol*s(RQRRRSR<RRRRCRHR_RRRoROR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs           t TruetypeFontscB sieZdZdd dYZdZdZdZdZdZdZ d Z d Z RS( sa A generic base class for all font setups that use Truetype fonts (through FT2Font). t CachedFontcB seZdZdZRS(cC sS||_|j|_tg|jjD]\}}||f^q+|_dS(N(Rgt get_charmaptcharmaptdictt iteritemstglyphmap(R;Rgtccodetglyphind((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<9s cC s t|jS(N(treprRg(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt__repr__?s(RQRRR<R(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR8s cC sjtj|||i|_i|_t|}|jtt|}||jd<||jd(R;RRjRxR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt _get_offset_scC s|||||f}|jj|}|dk r7|S|j||||\}} } }} |j} | j||| j| d|jj} g| j D]}|d^q\}}}}|j || ||}t d| j dd| j dd| jdd|d|d ||d ||d | jd|d | }t d | d|d| jd|d| d| d| d|}|j|<|S(NtflagsgP@tadvanceg@R>R=R[R]R^R\RitslantedRgRxRwRZRyRRjRv(RRR9t _get_glyphRgtset_sizet load_charRdRPRURRtlinearHoriAdvanceR>R=t horiBearingYRw(R;RRRRxRtkeytbunchRRRyRRgRjtvalR[R^R]R\RvRZtresult((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRds@ ' ,       cC s|j|}|jj|||jjd}|dkrf|j|tdd||}|jS|dd|d|d}|S(Ntpcltsmathtext.defaulttxtxHeightgP@g(@gY@(RRgRtget_sfnt_tableR9RR*Ri(R;RgRxRRRRZR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs cC sd||dS(Ng?g(@gR@g?((R;RgRxR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsc C s||krt||krt|j||||| } |j||||| } | j} | j| j| jtdStj|||||||||| S(NgP@(RRgt get_kerningRRRR( R;RRRRRRRRRtinfo1tinfo2Rg((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs (( RQRRRSRR<RRRRRRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR3s    * t BakomaFontscB seZdZidd6dd6dd6dd6d d 6d d 6d d6ZdZedjZdZidkdldmdndogd6dpdqdrdsdtgd6dudvdwdxdygd6dzd{d|d}d~gd 6ddddgd$6ddddgd(6ddddgd06ddddgd56ddddgd:6ddddgd?6ddddgdD6ddddgdI6ddddgdN6ddddgdS6dddddgdP6ddddgd\6ddddgda6ddgdb6ddgdc6Z x4ddddddgD]\Z Z e e e e WdS(N(t StixFontst_stix_fallbackRR<Rt_fontmapRR"(R;targstkwargsRRtfullpath((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s   s \int \ointc C s[d}||jkr|tkrt|\}}|dkpI||jk}y|j|} Wntk rrq#X| jj|}| j|}nt |dkr#|dk}y|j|} Wntk rq#Xt |}| j j |} | dk r#| jj| j |}q#n|dkrH|j j||||S| ||||fS(NRiR(R9RR$t_slanted_symbolsRt RuntimeErrorRgtget_glyph_nameRtlenR,RRRR( R;RRRRxRyRRRRtgid((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs2        t(sssst)ssss!t{stnst}stost[sRAs"t]stis#stjss$s\lfloorstkss%s\rfloorstlss&s\lceilstmss's\rceilstDss*s\langlestEss+s\rangletptqtrtss \__sqrt__ss/ss-s \backslashss.ss,s^tbtcRBs\widehats~tetftgs \widetildets \leftparens ightparents \leftbraces ightbraces \leftbrackets ightbracketcC s|jj|||fgS(N(t_size_alternativesR(R;RR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs(RR(Rs(Rs(Rs(Rs(RR(Rs(Rs(Rs(Rs!(RR(Rs(Rsn(Rs(RR(RR(Rs(Rso(Rs(RR(RR(Rs(Rsh(Rs"(RR(Rs(Rsi(Rs#(Rs(Rsj(Rs(Rs$(Rs(Rsk(Rs(Rs%(Rs(Rsl(Rs(Rs&(Rs(Rsm(Rs(Rs'(Rs(RsD(Rs(Rs*(Rs(RsE(Rs(Rs+(Rsp(Rsq(Rsr(Rss(Rs(Rs/(Rs(Rs-(Rs/(Rs(Rs.(Rs(Rs,(Rs^(Rsb(Rsc(Rsd(Rs~(Rse(Rsf(Rsg(Rsh(RsD(Rsi(RsE(s \leftparenR(s ightparentR(s \leftbraceR(s ightbraceR(s \leftbracketR(s ightbracketR( RQRRRSRR<RtsplitRRRtaliasttargetR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsp    "                           t UnicodeFontscB sJeZdZeZdZedjZdZ dZ dZ RS(sa An abstract base class for handling Unicode fonts. While some reasonably complete Unicode fonts (such as DejaVu) may work in some situations, the only Unicode font I'm aware of with a complete set of math symbols is STIX. This class will "fallback" on the Bakoma fonts when a required symbol can not be found in the font. cO stdrt|||_n d|_tj|||i|_x;djD]-}td|}t|}||j|sp                   cC s)|jr|jj||S||fgS(N(R R(R;RR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs   ( RQRRRSRRR<RRRRRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR s    FRcB seZdZi dd6dd6dd6dd6d d 6d d 6dd 6dd6dd6dd6dd6dd6ZeZeZeZdZdZ iZ dZ RS(sa A font handling class for the STIX fonts. In addition to what UnicodeFonts provides, this class: - supports "virtual fonts" which are complete alpha numeric character sets with different font styles at special Unicode code points, such as "Blackboard". - handles sized alternative characters for the STIXSizeX fonts. t STIXGeneralRsSTIXGeneral:italicRsSTIXGeneral:weight=boldRtSTIXNonUnicodetnonunirmsSTIXNonUnicode:italictnonuniitsSTIXNonUnicode:weight=boldtnonunibfitSTIXSizeOneSymitSTIXSizeTwoSymitSTIXSizeThreeSymitSTIXSizeFourSymitSTIXSizeFiveSymicO sftj|||i|_xC|jjD]2\}}t|}||j|<||j|t|dkr|} t | } t }nt d|t|dk} |j|} |rZy| j| } WqZtk rVt d| j|ftt}qZXn|sd} }t | } | j| } nd}d |}g| j| D]}||^q\}}}}td | j| |d | j| |d | j| |d |d|d||d||d||d| }td| d|d| jd|d| d| d| d||j|<|j|S(s/load the cmfont, metrics and glyph with cachingRiRRs.No TeX to built-in Postscript mapping for '%s's2No glyph in standard Postscript font '%s' for '%s'RigMbP?RR=R>R[R]R^R\RiRRgRxRwRZRyRRjRvN(RRR9RRRtunicodeRRR%tchrRR,RRRt get_name_charR/Rwt get_bbox_charRtget_width_chartget_height_charRI(R;RRRRxRRttupRRRjRRgRyRvtscaleRR[R^R]R\RZ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR4sr                /     c C s||kru||kru|j||||| } |j||||| } | j} | j| j| jd|Stj|||||||||| S(NgMbP?(RRgt get_kern_distRjRR( R;RRRRRRRRRRRRg((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs cC s!|j|}|jd|S(NgMbP?(RR(R;RgRxRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRscC s!|j|}|jd|S(NgMbP?(RR(R;RgRxRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsN(RQRRRSRFRGRHR)RDR9RR<RRRRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR7s     N gffffff?g?ig?g333333?g?gg ףp= ?RcB seZRS((RQRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstNodecB sMeZdZdZdZdZdZdZdZdZ RS(s% A node in the TeX box model cC s d|_dS(Ni(tsize(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<scC s |jS(N(t__internal_repr__(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRscC s |jjS(N(t __class__RQ(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRUscC sdS(Ng((R;tnext((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRscC s|jd7_dS(s Shrinks one level smaller. There are only three levels of sizes, after which things will no longer get smaller. iN(RT(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytshrinkscC s|jd8_dS(sb Grows one level larger. There is no limit to how big something can get. iN(RT(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytgrowscC sdS(N((R;RRn((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytrenders( RQRRRSR<RRURRXRYRZ(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRSs      tBoxcB s2eZdZdZdZdZdZRS(s7 Represents any node with a physical location. cC s,tj|||_||_||_dS(N(RSR<R=R>R?(R;R=R>R?((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s   cC sPtj||jtkrL|jt9_|jt9_|jt9_ndS(N(RSRXRTtNUM_SIZE_LEVELSR=t SHRINK_FACTORR>R?(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXs  cC s>tj||jt9_|jt9_|jt9_dS(N(RSRYR=t GROW_FACTORR>R?(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYs cC sdS(N((R;RIRJRKRL((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRZs(RQRRRSR<RXRYRZ(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR[s    tVboxcB seZdZdZRS(s. A box with only height (zero width). cC stj|d||dS(Ng(R[R<(R;R>R?((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR_stHboxcB seZdZdZRS(s8 A box with only width (zero height and depth). cC stj||dddS(Ng(R[R<(R;R=((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR`stCharcB sVeZdZdZdZdZdZdZdZdZ dZ RS( s# Represents a single character. Unlike TeX, the font information and metrics are stored with each :class:`Char` to make it easier to lookup the font metrics when needed. Note that TeX boxes have a width, height, and depth, unlike Type1 and Truetype which use a full bounding box and an advance in the x-direction. The metrics must be converted to the TeX way, and the advance (if different from width) must be converted into a :class:`Kern` node when the :class:`Char` is added to its parent :class:`Hlist`. cC s`tj|||_|j|_|j|_|j|_|j|_|j|_|jdS(N( RSR<Rt font_outputRgRRxRt_update_metrics(R;Rtstate((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s       cC s d|jS(Ns`%s`(R(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRU#scC s|jj|j|j|j|j|j}|_|jdkrR|j|_ n |j |_ |j |_ |j |j  |_ dS(Nt ( RbRRgRRRxRt_metricsRR=RiR>R?(R;RZ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRc&s +  cC s |jjS(N(RfR(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt is_slanted0sc C sx|jj|j}d}t|trp|jj|j|j|j |j |j|j|j |j |j }n||S(s Return the amount of kerning between this and the given character. Called when characters are strung together into :class:`Hlist` to create :class:`Kern` nodes. g( RfRR=RRaRbRRgRRRxR(R;RWRtkern((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR3s cC s5|jj|||j|j|j|j|jdS(s4 Render the character to the canvas N(RbRHRgRRRxR(R;RRn((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRZBs cC s_tj||jtkr[|jt9_|jt9_|jt9_|jt9_ndS(N( RSRXRTR\RxR]R=R>R?(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXJs  cC sMtj||jt9_|jt9_|jt9_|jt9_dS(N(RSRYRxR^R=R>R?(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYRs  ( RQRRRSR<RURcRgRRZRXRY(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRa s      tAccentcB s2eZdZdZdZdZdZRS(s The font metrics need to be dealt with differently for accents, since they are already offset correctly from the baseline in TrueType fonts. cC sg|jj|j|j|j|j|j}|_|j|j |_ |j |j |_ d|_dS(Ni(RbRRgRRRxRRfR]R[R=R\R^R>R?(R;RZ((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRc_s  +cC stj||jdS(N(RaRXRc(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXfs cC stj||jdS(N(RaRYRc(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYjs cC sI|jj||jj||jj|j|j|j|j|j dS(s5 Render the character to the canvas. N( RbRHRfR[R^RgRRRxR(R;RRn((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRZns (RQRRRSRcRXRYRZ(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRiYs    tListcB sDeZdZdZdZdZdZdZdZRS(s: A list of nodes (either horizontal or vertical). cC sGtj|dddd|_||_d|_d|_d|_dS(Ngi(R[R<t shift_amounttchildrentglue_sett glue_signt glue_order(R;telements((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<zs     c C sQd|j|j|j|j|jdjg|jD]}t|^q4fS(Ns![%s <%.02f %.02f %.02f %.02f> %s]Re(RUR=R>R?RkRHRlR(R;R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs    cC sKd}x>tt|dddD] }||dkr#|}Pq#q#W|S(s A helper function to determine the highest order of glue used by the members of this list. Used by vpack and hpack. iiig(R3R(R;ttotalsRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt_determine_orders #cC s|j|}||_||_||dkrE||||_nd|_d|_|dkrt|jrtd||jj |ft qndS(Ngis %s %s: %r( RrRoRnRmt glue_ratioRRlRRVRQR(R;RtsignRqt error_typeR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt _set_glues     cC s_x|jD]}|jq Wtj||jtkr[|jt9_|jt9_ndS(N(RlRXR[RTR\RkR]Rm(R;tchild((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXs  cC sMx|jD]}|jq Wtj||jt9_|jt9_dS(N(RlRYR[RkR^Rm(R;Rw((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYs  ( RQRRRSR<RRrRvRXRY(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRjvs   tHlistcB s8eZdZddedZdZdddZRS(s% A horizontal list of boxes. gt additionalcC s1tj|||r#|jn|jdS(N(RjR<Rhthpack(R;RpR@Rtdo_kern((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s cC sg}t|j}|rxt|D]}|j|}||dkr_|j|d}nd}|j||j|}|dkr(t|}|j|q(q(W||_ndS(s) Insert :class:`Kern` nodes between :class:`Char` nodes to set kerning. The :class:`Char` nodes themselves determine the amount of kerning they need (in :meth:`~Char.get_kerning`), and this function just creates the linked list in the correct way. igN(RRlR3R9RRtKern(R;t new_childrent num_childrenRtelemRWtkerning_distanceRh((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRhs    c C sd}d}d}dgd}dgd}xG|jD]<}t|tr||j7}t||j}t||j}q6t|tr||j7}t|j rrt|j rrt |dd} t||j| }t||j| }qrq6t|t rS|j } || j7}|| j c| j 7<|| jc| j7R?R[RtgetattrtGluet glue_spect stretch_ordertstretcht shrink_orderRXR|RnRoRsRv( R;R@RRARBRt total_stretcht total_shrinkRRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRzsJ                  (RQRRRSRR<RhRz(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRxs &tVlistcB s5eZdZdddZddeedZRS(s# A vertical list of boxes. gRycC stj|||jdS(N(RjR<tvpack(R;RpRAR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<&sc C sd}d}d}dgd}dgd}x"|jD]} t| tr||| j7}| j}t| jsMt| dd} t|| j| }qMq6t| t r||7}d}| j } || j7}|| j c| j 7<|| j c| j7R?RR=RRXRRRRRRXR|RaRRnRoRsRv( R;RARRR@RBRRRRRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR*sR                    (RQRRRSR<tfloatRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR"stRulecB s eZdZdZdZRS(s A :class:`Rule` node stands for a solid black rectangle; it has *width*, *depth*, and *height* fields just as in an :class:`Hlist`. However, if any of these dimensions is inf, the actual value will be determined by running the rule up to the boundary of the innermost enclosing box. This is called a "running dimension." The width is never running in an :class:`Hlist`; the height and depth are never running in a :class:`Vlist`. cC s&tj|||||j|_dS(N(R[R<Rb(R;R=R>R?Rd((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<vscC s%|jj||||||dS(N(RbR_(R;RRnR@RA((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRZzs(RQRRRSR<RZ(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRls  tHrulecB seZdZddZRS(s8 Convenience class to create a horizontal rule. cC s[|dkr0|jj|j|j|j}n|d}}tj|t|||dS(Ng?( R9RbRRgRxRRR<R(R;Rdt thicknessR>R?((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s   N(RQRRRSR9R<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR}stVrulecB seZdZdZRS(s6 Convenience class to create a vertical rule. cC s>|jj|j|j|j}tj||tt|dS(N(RbRRgRxRRR<R(R;RdR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s (RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsRcB s,eZdZedZdZdZRS(s Most of the information in this object is stored in the underlying :class:`GlueSpec` class, which is shared between multiple glue objects. (This is a memory optimization which probably doesn't matter anymore, but it's easier to stick to what TeX does.) cC sztj|d|_t|r4tj|}n$t|trL|}n td|rm|j}n||_ dS(Ntnormals/glue_type must be a glue spec name or instance.( RSR<t glue_subtypeRtGlueSpectfactoryRt ArgumentErrortcopyR(R;t glue_typeRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s     cC s\tj||jtkrX|jjdkrX|jj|_|jjt9_qXndS(Ng(RSRXRTR\RR=RR](R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXs  cC sJtj||jjdkrF|jj|_|jjt9_ndS(Ng(RSRYRR=RR^(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYs (RQRRRSRR<RXRY(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs RcB sDeZdZddddddZdZdZeeZRS(s See :class:`Glue`. gicC s1||_||_||_||_||_dS(N(R=RRRXR(R;R=RRRXR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s     cC s%t|j|j|j|j|jS(N(RR=RRRXR(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs cC s |j|S(N(t_types(tclsR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs(RQRRRSR<RRt classmethod(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs   iitfilitfillitfillltneg_filtneg_fillt neg_fillltemptygtsstFilcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstFillcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstFilllcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstNegFilcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstNegFillcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstNegFilllcB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstSsGluecB seZdZRS(cC stj|ddS(NR(RR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRst HCenteredcB seZdZdZRS(ss A convenience class to create an :class:`Hlist` whose contents are centered within its enclosing box. cC s.tj|tg|tgdtdS(NR{(RxR<RR(R;Rp((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s#(RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRst VCenteredcB seZdZdZRS(sr A convenience class to create a :class:`Vlist` whose contents are centered within its enclosing box. cC s(tj|tg|tgdS(N(RR<R(R;Rp((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<s(RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsR|cB s2eZdZdZdZdZdZRS(s A :class:`Kern` node has a width field to specify a (normally negative) amount of spacing. This spacing correction appears in horizontal lists between letters like A and V when the font designer said that it looks better to move them closer together or further apart. A kern node can also appear in a vertical list, when its *width* denotes additional spacing in the vertical direction. cC stj|||_dS(N(RSR<R=(R;R=((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR< s cC s d|jS(Nsk%.02f(R=(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRscC s2tj||jtkr.|jt9_ndS(N(RSRXRTR\R=R](R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRXs cC s tj||jt9_dS(N(RSRYR=R^(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRYs (RQRRRSR<RRXRY(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR|s     tSubSuperClustercB seZdZdZRS(sR :class:`SubSuperCluster` is a sort of hack to get around that fact that this code do a two-pass parse like TeX. This lets us store enough information in the hlist itself, namely the nucleus, sub- and super-script, such that if another script follows that needs to be attached, it can be reconfigured on the fly. cC s/d|_d|_d|_tj|gdS(N(R9tnucleustsubtsuperRxR<(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<%s   (RQRRRSR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRstAutoHeightCharcB seZdZedZRS(sG :class:`AutoHeightChar` will create a character as close to the given height and depth as possible. When using a font with multiple height versions of some characters (such as the BaKoMa fonts), the correct glyph will be selected, otherwise this will always just return a scaled version of the glyph. c C s|jj|j|}|j}||}xF|D]>\}} ||_t| |} | j| j|kr5Pq5q5W|| j| j} |j| 9_t| |} || j} tj || g| |_ dS(N( RbRRgRRaR>R?RxRxR<Rk( R;RR>R?RdtalwaysR4t target_totalRRtchartfactortshift((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<3s     (RQRRRSRR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR+st AutoWidthCharcB seZdZeedZRS(s: :class:`AutoWidthChar` will create a character as close to the given width as possible. When using a font with multiple width versions of some characters (such as the BaKoMa fonts), the correct glyph will be selected, otherwise this will always just return a scaled version of the glyph. c C s|jj|j|}|j}x?|D]7\}}||_|||} | j|kr+Pq+q+W|| j} |j| 9_|||} tj|| g| j|_dS(N(RbRRgRR=RxRxR<( R;RR=RdRt char_classR4RRRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<Os    (RQRRRSRRaR<(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRGstShipcB s>eZdZdZdZeeZdZdZRS(s Once the boxes have been set up, this sends them to output. Since boxes can be inside of boxes inside of boxes, the main work of :class:`Ship` is done by two mutually recursive routines, :meth:`hlist_out` and :meth:`vlist_out`, which traverse the :class:`Hlist` nodes and :class:`Vlist` nodes inside of horizontal and vertical boxes. The global variables used in TeX to store state as it processes have become member variables here. cC sNd|_d|_d|_d|_||_||j|_|j|dS(Nig(tmax_pushtcur_stcur_vtcur_htoff_hR>toff_vt hlist_out(R;RERFRN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt__call__ks     cC s$|dkrdS|dkr dS|S(NgegeA((tvalue((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytclampts   cC s/d}d}|j}|j}|j}|j}|jd7_t|j|j|_|j}x|jD]} t | t r| j |j|j |j|j |j| j7_qjt | tr|j| j7_qjt | trvt| jdkr|j| j7_q|j} || j|_t | trM|j| n |j| | | j|_||_qjt | tr=| j} | j} | j} t| r|j} nt| r|j} n| dkr+| dkr+t| |_| j |j|j |j|j | | t|_n|j| 7_qjt | trj| j}|j|} |dkr|dkr|j|kr||j7}t|t |j!|}qq|j"|kr||j#7}t|t |j!|}qn| |7} |j| 7_qjqjW|jd8_dS(Nigi($RoRnRRRRXRRRlRRaRZRRR=R|RjRRkRxRt vlist_outR[R>R?RtbaselineRRRRtroundRRmRRX(R;RNtcur_gtcur_glueRoRnt base_linet left_edgeRRtedget rule_heightt rule_deptht rule_widthR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR|sl     $                   % % cC sd}d}|j}|j}|jd7_t|j|j|_|j}|j|j8_|j}|j}x|j D]} t | t r|j| j 7_q|t | t ret| j dkr|j| j| j7_q|j| j7_|| j|_|j} |j | _ t | tr<|j| n |j| | | j|_||_q|t | tr| j} | j} | j } t| r|j } n| | 7} | dkr| dkr|j| 7_| j|j|j|j|j| | qq|t | tr| j}|j |} |dkr|dkr|j|kr||j7}t|t|j|}qq|j |kr||j!7}t|t|j|}qn| |7} |j| 7_q|t | t"r|t#dq|q|W|jd8_dS(Nigis1Internal mathtext error: Char node found in vlist($RoRnRRXRRRR>RRlRR|R=RjRR?RkRxRRR[RRZRRRRRRRRRmRRXRaR(R;RNRRRoRnRttop_edgeRRtsave_vRRRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRsj                     % % (RQRRRSRRt staticmethodRR(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRas     ?c s)fd}t}|j||S(s. Helper class to raise parser errors. c std|dS(Ns (R(Rtlocttoks(tmsg(sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt raise_errors(RtsetParseAction(RRR((RsF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytErrors  tParsercB seZdZedjZedjZedjZeeBeBZedjZ edjZ edjZ edjZ edjZ ed jZed jZed jZed jZd ZdZdZdefdYZdZdZdZdZdZdZdZidd6dd6dd6dd 6d!d"6d#d$6dd%6Zd&Zd'Z d(Z!id`dbd.fd/6Z#d0Z$id1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6d;dC6d7dD6d9dE6d=dF6d?dG6d1dH6dIdJ6dKdL6Z%edMjZ&dNZ'dOZ(dPZ)dQZ*dRZ+dSZ,dTZ-dUZ.dVZ/dWZ0dXZ1dYZ2dZZ3d[Z4d\Z5d]Z6d^Z7d_Z8RS(cs This is the pyparsing-based parser for math expressions. It actually parses full strings *containing* math expressions, in that raw text may also appear outside of pairs of ``$``. The grammar is based directly on that in TeX, though it cuts a few corners. s + * \pm \sqcap \rhd \mp \sqcup \unlhd \times \vee \unrhd \div \wedge \oplus \ast \setminus \ominus \star \wr \otimes \circ \diamond \oslash \bullet \bigtriangleup \odot \cdot \bigtriangledown \bigcirc \cap \triangleleft \dagger \cup \triangleright \ddagger \uplus \lhd \amalgsc = < > : \leq \geq \equiv \models \prec \succ \sim \perp \preceq \succeq \simeq \mid \ll \gg \asymp \parallel \subset \supset \approx \bowtie \subseteq \supseteq \cong \Join \sqsubset \sqsupset \neq \smile \sqsubseteq \sqsupseteq \doteq \frown \in \ni \propto \vdash \dashv \dotss \leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow \Uparrow \rightarrow \longrightarrow \downarrow \Rightarrow \Longrightarrow \Downarrow \leftrightarrow \longleftrightarrow \updownarrow \Leftrightarrow \Longleftrightarrow \Updownarrow \mapsto \longmapsto \nearrow \hookleftarrow \hookrightarrow \searrow \leftharpoonup \rightharpoonup \swarrow \leftharpoondown \rightharpoondown \nwarrow \rightleftharpoons \leadstos, ; . ! \ldotp \cdotps} \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee \bigwedge \bigodot \bigotimes \bigoplus \biguplus slim liminf limsup sup max mins \int \oints6rm cal it tt sf bf default bb frak circled scr regulars arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan coth inf max tanhsb | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow .s( [ { < \lfloor \langle \lceils) ] } > \rfloor \rangle \rceilc% C sEtj|jjd}t}tj|jjd}tjd}tjd}tj|j}tj|jjd|_td}t dj }t dj } t ||} | j|j | j } | j|jt d } t|jjt|j} tt|j}tt|j}tg|jD]}d |^qp}t| td d d ddddgj|jjd}t d||| tdBj|jjd}d}td|t| ttjttdBj|jj}t| t|jjj|j }t!t| | |j|j"jd} t| |j|j#jd}t!| t$||A| j|j%jd}|t| |>|t| |>t!tt d||tdBj|j&jd}t!tt d||td Bj|j'jd!}t!tt d"||td#Bj|j(jd$}tt|j)}tt|j*}tt|j+}tt|j+t,dg}t!tt d%tt dtt|j)|j*Bt,d&gBtt dtt dtt|j)|j+t,dgBt,d&d'gBtt dtt dtd(tt d|||td)Bj|j-jd*}t!tt d+t tt d,td-tt d.d/d|td0Bj|j/jd1} ||||BA| A|A|A|A|A|A| A>|||B|B|B>td2d3g}!|t!t |t0|!||B>|tt d4||Btd5Bt!t0||Att d6||Btd5B>t0||Aj|j1jd }"| t d7}#td8j|j2jd9j}$|j|$t$t|#t |"t|#td:B|$t3>|j4dS(;NRgtsubsupert placeabletsimpletfinishs[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)RRs\tmaths\ s\/s\,s\;s\quads\qquads\!tspaces\hspacesExpected \hspace{n}t customspaceu€-🿿u8([a-zA-Z0-9 +\-*/<>=:,.;!'@()\[\]|%s])|(\\[%%${}\[\]_|])s [^a-zA-Z]taccenttfunctiontgroups\fracsExpected \frac{num}{den}tfracs \stackrelsExpected \stackrel{num}{den}tstackrels\binomsExpected \binom{num}{den}tbinoms\genfracts\}s[0-9]*(\.?[0-9]*)?s<Expected \genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}tgenfracs\sqrtRs[0-9]+RRsExpected \sqrt{value}tsqrtt_t^s\leftsExpected a delimiters\rightt$s(?:(?:\\[$])|[^$])*tnon_mathsExpected end of math '$'(5R RRgtsetNametsubsuperscripttauto_sized_delimiterRt _expressionRR tsuppressR t start_groupRt end_groupRt _accent_maptkeystlistt _wide_accentst_function_namest _fontnamesRRRRRR&R2tleaveWhitespaceRt_char_over_charstchar_over_charsRRRR RRRRt _ambiDelimt _leftDelimt _rightDelimRRR9RR RRRtclear(%R;Rgt latexfontRRRt autoDelimRtlbracetrbraceRRtbslashRRRRt latex2efontRRt unicode_rangeR2tc_over_cRRRRt ambiDelimt leftDelimt rightDelimtrightDelimSafeRRt subsuperopRt math_delimR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<Ts !   &          " Y)  Y  / cC sd|_d|_i|_dS(s1 Clear any state before parsing. N(R9t_exprt _state_stackt_em_width_cache(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR s  cC s|j|dd||g|_y|jj|WnLtk r}tdjd|jd|jddt |gnX|j S(s Parse expression *s* using the given *fonts_object* for output, at the given *fontsize* and *dpi*. Returns the parse tree of :class:`Node` instances. RRs RReiR( tStateRRt parseStringRR1RHtlinetcolumnRR(R;RR:RxRterr((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytparse s! RcB sAeZdZdZdZdZdZeeeZRS(s Stores the state of the parser. States are pushed and popped from a stack as necessary, and the "current" state is always at the top of the stack. cC s1||_||_||_||_||_dS(N(Rbt_fontRRxR(R;RbRgRRxR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<= s     cC s(tj|j|j|j|j|jS(N(RRRbRgRRxR(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRD s cC s|jS(N(R(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRL scC s%|dkr||_n||_dS(NRRR(srmsitsbf(RR(R;R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt _set_fontN s  ( RQRRRSR<RRRtpropertyRg(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR6 s     cC s |jdS(s? Get the current :class:`State` of the parser. i(R(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt get_stateT scC s|jjdS(s8 Pop a :class:`State` off of the stack. N(Rtpop(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt pop_stateZ scC s |jj|jjdS(sm Push a new :class:`State` onto the stack which is just a copy of the current state. N(RRRR(R;((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt push_state` scC st||_|jgS(N(RxR(R;RRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRg scC st|}|j|gS(N(RxR(R;RRRthlist((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRl s  cC sn|djdd}g|D]}t||j^q}t|}|jtd|j_|gS(Nis\$Rsmathtext.default(treplaceRaRRxRR*Rg(R;RRRRtsymbolsR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRr s (  cC s|j}|j|j|jf}|jj|}|dkr|jj|jt dd|j|j}|j }||j|RR?RkRxtSUBDROPRJtSUB1tabst SCRIPT_SPACEtSUP1RgtDELTA(R;RRRRRRtopRWtop1tnext1top2tnext2Rdtrule_thicknessRtvlistRR=RRtshift_upt shift_downRtclrRn((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR2 s                                         cC s|j}|jj|j|j|j}t|}|j|jt|g} t|g} t |j |j } | j | d| j | dt | t d|dt||t d|d| g} |jj|jtdd|j|j} | j| j| jd|d}|| _t| t|dgg}|s`|r|dkrud }n|dkrd }n|d krd }n|j|||S|S( NR)ig@smathtext.defaultt=ig@RR?s\}R(RRbRRgRxRRRXRRXR=RzRR_RRR*R>R\R^RkRxR`t_auto_sized_delimiter(R;tldelimtrdelimtruletstyleRtdenRdRtcnumtcdenR=RYRZRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyt_genfrac sB                  cC s|jt|dS(Ni(Rfttuple(R;RRR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR scC sY|j}|jj|j|j|j}|d\}}|jdd|d||S(NiR(RRbRRgRxRRf(R;RRRRdRRRc((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR s   cC s,|d\}}|jdddd||S(NiRg(Rf(R;RRRRRc((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR scC s,|d\}}|jdddd||S(NiRRgR(Rf(R;RRRRRc((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR scC s|d\}}|j}|jj|j|j|j}|j|j|d}|j|j} t d|| |dt } | j| j}| j| j} t t |d|t |dg} t t|t| g} | j||j|jd | d|dkr4t| jd d d }n<t g|D]} t| |^q>}|j|jt t |gg}| d |_t |t| j d | | g}|gS( Nig@s \__sqrt__Rg@gY@g(@R)g?gg333333?g@(RRbRRgRxRR>RkR?RRRxR`RRRRR9R[R=RaRXR|(R;RRRtroottbodyRdRR>R?tcheckt padded_bodyt rightsideRt root_vlistR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR s:      (   c C s|j}tg|D]}|j^q}tg|D]}|j^q8}g}|dkr|jt||||n|j||dkr|jt||||nt|} | S(NR?(RRXR>R?RRRLRx( R;tfronttmiddletbackRdRR>R?tpartsR((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR^ s ""    cC s(|\}}}|j||j|S(N(R^RK(R;RRRRnRoRp((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR/ s(srmR'g?N(Ns\circg?(9RQRRRSRRt_binary_operatorst_relation_symbolst_arrow_symbolsR%R&RERGRIRRRRRR<RRtobjectRRRRRRRR#R$RRR2R9RRRRRRRRRRgRHRJRgRRfRRRRRR^R(((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRs                %          y )    - tMathTextParsercB seZdZied6ed6ed6ed6ed6e d6e d6ed6Z ie d6e d 6ed 6ed 6Zd Zd ddZdddZddddZddddZdddZRS(tbitmaptaggR{tpdftsvgRGtcairotmacosxtcmtstixtstixsanstcustomcC s"|j|_td|_dS(sI Create a MathTextParser for the given backend *output*. i2N(Rt_outputRt_cache(R;toutput((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyR<O siHc C s|dkrt}n||t|f}|jj|}|dk rO|S|jdkrwtdrwt|}n_|j|j}td}|j j|j } | dk r| ||}n t d|j } |j dkrt|j_ n|j j||| |} |j| j| j| j|j| }||j|<|j j|jd|j_d|_|S(s Parse the given math expression *s* at the given *dpi*. If *prop* is provided, it is a :class:`~matplotlib.font_manager.FontProperties` object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to :meth:`parse` with the same expression should be fast. R{s ps.useafmsmathtext.fontsetsEmathtext.fontset must be either 'cm', 'stix', 'stixsans', or 'custom'N(R9R#thashRRRR*R7t_backend_mappingt_font_type_mappingRR1tget_size_in_pointst_parserRRVRRCR=R>R?RORRRdR:( R;RRR tcacheKeyRRbtbackendtfontsett fontset_classRxRN((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pyRV s6            ixicC sFtd|}|j|d|d|\}}|j}||fS(s *texstr* A valid mathtext string, eg r'IQ: $\sigma_i=15$' *dpi* The dots-per-inch to render the text *fontsize* The font size in points Returns a tuple (*array*, *depth*) - *array* is an NxM uint8 alpha ubyte mask array of rasterized tex. - depth is the offset of the baseline from the bottom of the image in pixels. RTRR (R#Rtas_array(R;ttexstrRRxR tftimageR?R((sF/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mathtext.pytto_mask s! tblackc C s|j|d|d|\}}tjj|\}}} tj|jd|jddfdtj} td|| dddddfs    p "((  41+  )vsnq !N=oJ  !   8