OwlCyberSecurity - MANAGER
Edit File: texmanager.cpython-38.pyc
U ��]�@ � @ s� d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl Z ddl Z ddlZddl Zddl mZmZmZ e�e�ZG dd� de�ZdS )a� This module supports embedded TeX expressions in matplotlib via dvipng and dvips for the raster and postscript backends. The tex and dvipng/dvips information is cached in ~/.matplotlib/tex.cache for reuse between sessions Requirements: * latex * \*Agg backends: dvipng>=1.6 * PS backend: psfrag, dvips, and Ghostscript>=8.60 Backends: * \*Agg * PS * PDF For raster output, you can get RGBA numpy arrays from TeX expressions as follows:: texmanager = TexManager() s = ('\TeX\ is Number ' '$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!') Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1,0,0)) To enable tex rendering of all text in your matplotlib figure, set :rc:`text.usetex` to True. � N)�Path)�cbook�dviread�rcParamsc @ s8 e Zd ZdZe�� Zedk r>ej� ed�Z ee �jddd� ndZ i Z i ZdZdZdZd Zd ZdZdd ddd d ddddddddddd�ZdZdedd� eD �� Ze�� dd� �Zdd� Zd8dd�Zdd� Zd d!� Zd"d#� Z d$d%� Z!e"�#d&�Z$d'd(� Z%d)d*� Z&d+d,� Z'd-d.� Z(d/d0� Z)d9d1d2�Z*d:d4d5�Z+d;d6d7�Z,dS )<� TexManagerz� Convert strings to dvi files using TeX, caching the results to a directory. Repeated calls to this constructor always return the same instance. Nz tex.cacheT��parents�exist_ok)Zcmr� )Zcmssr )Zcmttr )Zpzcz\usepackage{chancery}�serif)r � sans-serif�cursive� monospace)Zpncz\renewcommand{\rmdefault}{pnc})Zpbkz\renewcommand{\rmdefault}{pbk})Zptmz\usepackage{mathptmx})Zpplz\usepackage{mathpazo})Zpchz\usepackage{charter})Zphvz\usepackage{helvet})Zpagz\usepackage{avant})Zpcrz\usepackage{courier})znew century schoolbookZbookman�timesZpalatinoz zapf chanceryr Zcharterr r Z helveticazavant gardeZcourierr zcomputer modern romanzcomputer modern sans serifzcomputer modern typewriter)�text.latex.preamble�text.latex.unicode�text.latex.preview�font.familyc c s | ]}d | V qdS )�font.N� )�.0�nr r �7/usr/lib/python3/dist-packages/matplotlib/texmanager.py� <genexpr>a s zTexManager.<genexpr>c C s t �| �}|�� |S )N)�object�__new__�_reinit)�cls�selfr r r r c s zTexManager.__new__c C s� | j d krtd��t| j �jddd� td }t|�dkr\|d �� | jkr\|d �� | _n>t |t �r�|�� | jkr�|�� | _nt�dd� | j�� d | _| jg}| jD ]�}|�d d�}td| D ]X}|�� | jk�rt| || j|�� � t�d ||| j|�� � �q<q�t�d|� q�t�d|� t| || j| � |�t| |�d � q�| �� �d�}|�t�|��� � d� |�| _| jd | jd | jd g}| jdk�r�|�| jd � d� dg| dg �| _d S )NzBCannot create TexManager, as there is no cache directory availableTr r � r zXfont.family must be one of (%s) when text.usetex is True. serif will be used by default.z, r �-�_r zfamily: %s, font: %s, info: %sz&%s font is not compatible with usetex.zQNo LaTeX-compatible font found for the %s font family in rcParams. Using default.�utf-8r r � z\usepackage{type1cm}z\usepackage{textcomp})�texcache�RuntimeErrorr �mkdirr �len�lower� font_families�font_family� isinstance�str�_log�info�join�replace� font_info�setattr�debug�append�getattr�get_custom_preamble�encode�hashlib�md5� hexdigest�_fontconfigr � sans_serifr r �_font_preamble)r ZffZ fontconfigr* Zfont_family_attrZfontZpreamble_bytes�cmdr r r r i sV � � ����zTexManager._reinitc C sH d� || �� d| | �� t|p d�g�}tj� | jt�|� d��� � �S )zU Return a filename based on a hash of the string, fontsize, and dpi. r z%fr"