rL idZddlZddlZddlZddlmZmZddlmZddl m Z ddlm Z m Z m Z ejeZee _Gdd Zd dd d Zy) a  A module for parsing a subset of the TeX math syntax and rendering it to a Matplotlib backend. For a tutorial of its usage, see :ref:`mathtext`. This document is primarily concerned with implementation details. The module uses pyparsing_ to parse the TeX expression. .. _pyparsing: https://pypi.org/project/pyparsing/ 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. N)_api _mathtext) LoadFlags)FontProperties) RasterParse VectorParseget_unicode_indexceZdZdZej ej ejejejejdZ dZ ddddZ ejddZy) MathTextParserN)cm dejavuserif dejavusansstixstixsanscustomc`tjdddd|j|_y)a  Create a MathTextParser for the given backend *output*. Parameters ---------- output : {"path", "agg"} Whether to return a `VectorParse` ("path") or a `RasterParse` ("agg", or its synonym "macosx"). vectorraster)pathaggmacosx)outputN)r check_getitemlower _output_type)selfrs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/mathtext.py__init__zMathTextParser.__init__0s*!..h( C<<># antialiasedc||jnd}tj|d}ddlm}t j |jd|j}|j|||||S)a Parse the given math expression *s* at the given *dpi*. If *prop* is provided, it is a `.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 `parse` with the same expression should be fast. Depending on the *output* type, this returns either a `VectorParse` or a `RasterParse`. Nztext.antialiasedr) backend_agg)rr) copympl _val_or_rcmatplotlib.backendsr$r NO_HINTINGget_hinting_flagr _parse_cached)rsdpipropr"r$load_glyph_flagss rparsezMathTextParser.parse>ss"#.tyy{Dnn[2DE 3**!224    !!!S$ =MNNr 2c| t}tj|j|j }|||}|j }|j #tj|j_|j j||||} tj| } |jdk(r| jS|jdk(r| j|Sy)N)fontsetrrr!)rrr_font_type_mappingget_math_fontfamilyget_size_in_points_parserrParser __class__r0shipr to_vector to_raster) rr,r-r.r"r/ fontset_classr3fontsizeboxrs rr+zMathTextParser._parse_cachedXs <!#D**  # #T-E-E-GI &67**, << %.%5%5%7DNN "ll  GXs;$    (##% %   ( *## #< <+r )HN)__name__ __module__ __qualname__r7r BakomaFontsDejaVuSerifFontsDejaVuSansFonts StixFonts StixSansFonts UnicodeFontsr4rr0 functools lru_cacher+r rr r %syG ,, 11 00 ** .. --  #OO4Y==r r )colorcddlm}td}|j|d|\}} } } } |j |dz | dz f} | j d| | z |||| j ||| | S) a Given a math expression, renders it in a closely-clipped bounding box to an image file. Parameters ---------- s : str A math expression. The math portion must be enclosed in dollar signs. filename_or_obj : str or path-like or file-like Where to write the image data. prop : `.FontProperties`, optional The size and style of the text. dpi : float, optional The output dpi. If not set, the dpi is determined as for `.Figure.savefig`. format : str, optional The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the format is determined as for `.Figure.savefig`. color : str, optional Foreground color, defaults to :rc:`text.color`. r)figurerr@)r-r.gR@)figsize)fontpropertiesrM)r-format) matplotlibrOr r0Figuretextsavefig) r,filename_or_objr.r-rRrMrOparserwidthheightdepth_figs r math_to_imager^ls~." F #F!'aRd!CE65!Q --v} =- >CHHQf aEHBKKSK8 Lr )NNN)__doc__rJloggingrSr&rrmatplotlib.ft2fontrmatplotlib.font_managerrrr r getLoggerrA_logrBr r^rLr rresa"&(211w" ( D=D=N  r