| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/matplotlib/tests/ |
Upload File : |
from pathlib import Path
import re
import matplotlib.pyplot as plt
from matplotlib.texmanager import TexManager
import pytest
def test_fontconfig_preamble():
"""Test that the preamble is included in _fontconfig."""
plt.rcParams['text.usetex'] = True
tm1 = TexManager()
font_config1 = tm1.get_font_config()
plt.rcParams['text.latex.preamble'] = '\\usepackage{txfonts}'
tm2 = TexManager()
font_config2 = tm2.get_font_config()
assert font_config1 != font_config2
@pytest.mark.parametrize(
"rc, preamble, family", [
({"font.family": "sans-serif", "font.sans-serif": "helvetica"},
r"\usepackage{helvet}", r"\sffamily"),
({"font.family": "serif", "font.serif": "palatino"},
r"\usepackage{mathpazo}", r"\rmfamily"),
({"font.family": "cursive", "font.cursive": "zapf chancery"},
r"\usepackage{chancery}", r"\rmfamily"),
({"font.family": "monospace", "font.monospace": "courier"},
r"\usepackage{courier}", r"\ttfamily"),
({"font.family": "helvetica"}, r"\usepackage{helvet}", r"\sffamily"),
({"font.family": "palatino"}, r"\usepackage{mathpazo}", r"\rmfamily"),
({"font.family": "zapf chancery"},
r"\usepackage{chancery}", r"\rmfamily"),
({"font.family": "courier"}, r"\usepackage{courier}", r"\ttfamily")
])
def test_font_selection(rc, preamble, family):
plt.rcParams.update(rc)
tm = TexManager()
src = Path(tm.make_tex("hello, world", fontsize=12)).read_text()
assert preamble in src
assert [*re.findall(r"\\\w+family", src)] == [family]