Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/texmanager.cpython-312.pyc
T

129 lines
17 KiB
Plaintext
Raw Normal View History

Ë
†Rjê;ãó¬dZddlZddlZddlZddlZddlmZddlZddlm Z ddl
Z ddl Z
ddl mZmZej e«ZddœdZGdd «Zy)

Support for embedded TeX expressions in Matplotlib.
Requirements:
* LaTeX.
* \*Agg backends: dvipng>=1.6.
* PS backend: PSfrag, dvips, and Ghostscript>=9.0.
* PDF and SVG backends: if LuaTeX is present, it will be used to speed up some
post-processing steps, but note that it is not used to parse the TeX string
itself (only LaTeX is supported).
To enable TeX rendering of all text in your Matplotlib figure, set
:rc:`text.usetex` to True.
TeX and dvipng/dvips processing results are cached
in ~/.matplotlib/tex.cache for reuse between sessions.
`TexManager.get_rgba` can also be used to directly obtain raster output as RGBA
NumPy arrays.
éN)ÚPath)ÚTemporaryDirectory)ÚcbookÚdviread©Úoptioncó&|d|dnd}d||dœzS)a$
Output LaTeX code that loads a package (possibly with an option) if it
hasn't been loaded yet.
LaTeX cannot load twice a package with different options, so this helper
can be used to protect against users loading arbitrary packages/options in
their custom preamble.
úz]\makeatletter\@ifpackageloaded{%(package)s}{}{\usepackage%(option)s{%(package)s}}\makeatother©Úpackager©r
s úX/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/texmanager.pyÚ_usepackage_if_not_loadedr's1ð0ˆq˜‰]°b€Fð ð vÑ c
óòeZdZdZej
j
ej«d«Z iZ
dZ idddddd “d
d d d
dd
ddddddddddddddddddddZ dddddddddddddœ Z
ejd „«Zed!„«Zed"„«Zed0d$„«Zed%„«Zed&„«Zed'„«Zed(„«Zed#d)œd*„«Zed+„«Zed,„«Zed1d-„«Zed2d.„«Zed0d/„«Zy#)3Ú
TexManagera
Convert strings to dvi files using TeX, caching the results to a directory.
The cache directory is called ``tex.cache`` and is located in the directory
returned by `.get_cachedir`.
Repeated calls to this constructor always return the same instance.
z tex.cache)Úserifú
sans-serifÚcursiveÚ monospaceúnew century schoolbookz\renewcommand{\rmdefault}{pnc}Úbookmanz\renewcommand{\rmdefault}{pbk}Útimesz\usepackage{mathptmx}Úpalatinoz\usepackage{mathpazo}ú
zapf chanceryz\usepackage{chancery}rÚcharterz\usepackage{charter}rr rÚ helveticaz\usepackage{helvet}ú avant gardez\usepackage{avant}Úcourierz\usepackage{courier}rz\usepackage{type1ec}úcomputer modern romanúcomputer modern sans serifúcomputer modern typewriter) rrrrrrrr r!r"r#r$cóxt|j«jdd¬«tj |«S)NT©ÚparentsÚexist_ok)rÚ _texcacheÚmkdirÚobjectÚ__new__©Úclss rr,zTexManager.__new__js-ä ˆS]‰]Ó×!¨$¸Ð~‰~˜"rcóhtjd}t|«dk(r|dj«nd}t|«dk(r||jvr|dfSt|«dk(r||j
vr|j |dfStjddj|j««y )
z<Return the font family name and whether the font is reduced.ú font.familyérNFTzXfont.family must be one of (%s) when text.usetex is True. serif will be used by default.ú, )rF)
ÚmplÚrcParamsÚlenÚlowerÚ_font_familiesÚ_font_preamblesÚ _font_typesÚ_logÚinfoÚjoin)r.ÚffÚff_vals rÚ_get_font_family_and_reducedz'TexManager._get_font_family_and_reducedoô\‰\˜-Ñ
(ˆÜ"% b£'¨Q¢,A°DˆÜ ˆr7aŠ<˜F c×&8Ñ&8ј5 Ü
‹W˜Š\˜f¨×(;Ñ(;Ñ—?? *¨DÐ I‰Ið—i‘i × 2Ñ 2Ó
"rc
ó4|j«\}}i}|jD]}|r:||k(r5|jtjddj «||<Œ@tjd|}t
ttj
|««D]b\}}||jvsŒ|j|||<tjd||j|||dj|d|««ŒÝtjd|«|j|||<ŒdDchc]}||Œ } }|dk(r| j|d«| jd «d
jt| ««}
|d k(rd n|d
k(rdnd} |
| fScc}w)Nr0rzfont.z.family: %s, package: %s, font: %s, skipped: %sr2zPNo LaTeX-compatible font found for the %s fontfamily in rcParams. Using default.)rrrrz\usepackage{type1cm}ú
rz \sffamilyrz \ttfamilyz \rmfamily)r?r7r8r3r4r6Ú enumerateÚmapÚstrr:Údebugr<r;ÚaddÚsorted) r.Úrequested_familyÚis_reduced_fontÚ preamblesÚ font_familyÚrcfontsÚfontÚfamilyÚcmdÚpreambleÚfontcmds rÚ_get_font_preamble_and_commandz)TexManager._get_font_preamble_and_command~à,/×,LÑ,LÓ,Nј/àˆ Ø× Nˆ ;Ð2BÒ#BØ),×)<Ñ)<Ü—LL ÑÑ2×*< ˜Ÿ,™,¨¨{¨mÐ'<Ñ=ܬS¯Y©Y¸Ó)@Ó
NGA˜s×2Ø14×1DÑ1DÀTÑ1J˜  Ÿ
Ø×)<Ñ)<¸TÑ)BÀGÈAÁJØ ŸI™I g¨b¨q ñ
ð
Nô—I‘IðCà.1×-@Ñ-@ÀÑ-MI˜*ð' Nð0BöCØð˜Ó ðCˆðCà ˜yÒ G‰GI˜  З99œV C)ˆØ#3°|Ò#C<Ø#3°{Ò#Bð ð˜Ð Ð ùòCsÄ/ FNcó’|j||«t|«z}tj|j d«d¬«j «}t
|j«}d\}}td||z|«D]} |t
|| | dz«z }Œ|jdd¬«tjj||«S) zU
Return a filename based on a hash of the string, fontsize, and dpi.
úutf-8F)Úusedforsecurity)érWrrWTr&)
Ú_get_tex_sourcerDÚhashlibÚsha256ÚencodeÚ hexdigestrr)Úranger*ÚosÚpathr<)
r.ÚtexÚfontsizeÚdpiÚsrcÚfilehashÚfilepathÚ num_lettersÚ
num_levelsrMs
rÚ get_basefilezTexManager.get_basefile¥s¿ð
×! # xÓ0´3°s³8Ñ;ˆÜ—> J‰J Ø
÷ ‰)‹+ð ô˜Ÿ
Ó&ˆà"&ш q˜+ 0°+Ó 8ˆ¤$ °!°A±# Ó"7Ñ7‰Hð ˜t¨dˆÔw‰w|‰|˜H /rcó,|j«\}}|S)zU
Return a string containing font configuration for the tex preamble.
)rS)r.Ú
font_preambleÚcommands rÚget_font_preamblezTexManager.get_font_preamble¸sð
"%×!CÑ!CÓ!Eш
Ðrcó(tjdS)z>Return a string containing user additions to the tex preamble.ztext.latex.preamble)r3r4r-s rÚget_custom_preamblezTexManager.get_custom_preambleÀsô|‰|Ð2rc"óî|j«\}}d|z}djddddd|dd d
d d d
|j«ddtdd¬«ddtd«ddddddd|d|ddd |d!|dd"g«S)#z;Return the complete TeX source for processing a TeX string.gô?rAz\documentclass{article}z=% Pass-through \mathdefault, which is used in non-usetex modez>% to use the default text font but was historically suppressedz% in usetex mode.z \newcommand{\mathdefault}[1]{#1}z\usepackage[utf8]{inputenc}z.\DeclareUnicodeCharacter{2212}{\ensuremath{-}}z3% geometry is loaded before the custom preamble as z<% convert_psfrags relies on a custom preamble to change the z % geometry.z1\usepackage[papersize=72in, margin=1in]{geometry}z?% Use `underscore` package to take care of underscores in text.z?% The [strings] option allows to use underscores in file names.Ú
underscoreÚstringsrz;% Custom packages (e.g. newtxtext) may already have loaded z"% textcomp with different options.Útextcompz\pagestyle{empty}z\begin{document}z>% The empty hbox ensures that a page is printed even for emptyz=% inputs, except when using psfrag which gets confused by it.z;% matplotlibbaselinemarker is used by dviread to detect thez% last line's baseline.z
\fontsize{z}{z}%z!\ifdefined\psfrag\else\hbox{}\fi%ú z\end{document})rSr<rnr)r.r`rarjrRÚ baselineskips rrXzTexManager._get_tex_sourceÅð"%×!CÑ!CÓ!Eш
˜hˆ Øy‰yØ Ø Ø Ø × % l¸ %  Ø Ø ˜8˜* ¨°cÐ '˜!˜C˜5 Ð ð;
ó ð rcóˆ|j||«dz}t|«j|j||«d¬«|S)zv
Generate a tex file to render the tex string at a specific font size.
Return the file name.
ú.texrU©Úencoding)rhrÚ
write_textrX)r.r`raÚtexfiles rÚmake_texzTexManager.make_texêsIð×" Ó1°FÑ:ˆÜ ˆW‹
× Ñ  ×!4Ñ!4°S¸(Ó!CØ*1ðˆr©Úcwdc ótjtj|«« t j
|||n |j tj¬«}tj|«|S#t$r}td|dd«|d}~wtj$rc}tdj|dtj|«|jd«|jjdd«¬ ««dd}~wwxYw)
N)r~Ústderrz*Failed to process string with tex because rz could not be foundzŒ{prog} was not able to process the following string:
{tex!r}
Here is the full command invocation and its output:
{format_command}
{exc}
Úunicode_escaperUÚbackslashreplace)ÚprogÚformat_commandr`Úexc)r:rErÚ_pformat_subprocessÚ
subprocessÚ check_outputr)ÚSTDOUTÚFileNotFoundErrorÚ RuntimeErrorÚCalledProcessErrorÚformatr[ÚoutputÚdecode)r.rkr`r~Úreportr…s rÚ_run_checked_subprocessz"TexManager._run_checked_subprocessösä
”5×,¨WÓ Ü× C O™S¸¿¹Ü!×*ˆFô&
؈
øô#Ø<¸WÀQ¹Z¸I&à+.ð
/ûô× Üð÷#™FØ  Ü#(×#<Ñ#<¸WÓ#EØŸ
Ð#3ÓŸ
×)¨'Ð3EÓHó
ðð
ûð ús$ª4A5Á5 D
Á>BÂD
Â'ADÄD
cót|j||««jd«}|j«s²t |j
¬«5}t|d«j