Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use fix-cm instead of type1cm. #30100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ will often automatically include these collections.
| | `lm <https://ctan.org/pkg/lm>`_, |
| | `txfonts <https://ctan.org/pkg/txfonts>`_ |
+-----------------------------+--------------------------------------------------+
| collection-latex | `geometry <https://ctan.org/pkg/geometry>`_, |
| collection-latex | `fix-cm <https://ctan.org/pkg/fix-cm>`_, |
| | `geometry <https://ctan.org/pkg/geometry>`_, |
| | `hyperref <https://ctan.org/pkg/hyperref>`_, |
| | `latex <https://ctan.org/pkg/latex>`_, |
| | latex-bin, |
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
# become quite long.
# The following packages are always loaded with usetex,
# so beware of package collisions:
# geometry, inputenc, type1cm.
# color, fix-cm, geometry, graphicx, textcomp.
# PostScript (PSNFSS) font packages may also be
# loaded, depending on your font settings.

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
# Note that it has to be put on a single line, which may
# become quite long.
# The following packages are always loaded with usetex, so
# beware of package collisions: color, geometry, graphicx,
# type1cm, textcomp.
# beware of package collisions:
# color, fix-cm, geometry, graphicx, textcomp.
# Adobe Postscript (PSSNFS) font packages may also be
# loaded, depending on your font settings.

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_unicode_won():

tree = xml.etree.ElementTree.fromstring(buf)
ns = 'http://www.w3.org/2000/svg'
won_id = 'SFSS3583-8e'
won_id = 'SFSS1728-8e'
assert len(tree.findall(f'.//{{{ns}}}path[@d][@id="{won_id}"]')) == 1
assert f'#{won_id}' in tree.find(f'.//{{{ns}}}use').attrib.values()

Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_usetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,10 @@ def test_rotation():
# 'My' checks full height letters plus descenders.
ax.text(x, y, f"$\\mathrm{{My {text[ha]}{text[va]} {angle}}}$",
rotation=angle, horizontalalignment=ha, verticalalignment=va)


def test_unicode_sizing():
tp = mpl.textpath.TextToPath()
scale1 = tp.get_glyphs_tex(mpl.font_manager.FontProperties(), "W")[0][0][3]
scale2 = tp.get_glyphs_tex(mpl.font_manager.FontProperties(), r"\textwon")[0][0][3]
assert scale1 == scale2
16 changes: 12 additions & 4 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class TexManager:
_grey_arrayd = {}

_font_families = ('serif', 'sans-serif', 'cursive', 'monospace')
# Check for the cm-super package (which registers unicode computer modern
# support just by being installed) without actually loading any package
# (because we already load the incompatible fix-cm).
_check_cmsuper_installed = (
r'\IfFileExists{type1ec.sty}{}{\PackageError{matplotlib-support}{'
r'Missing cm-super package, required by Matplotlib}{}}'
)
_font_preambles = {
'new century schoolbook': r'\renewcommand{\rmdefault}{pnc}',
'bookman': r'\renewcommand{\rmdefault}{pbk}',
Expand All @@ -83,10 +90,10 @@ class TexManager:
# Loading the type1ec package ensures that cm-super is installed, which
# is necessary for Unicode computer modern. (It also allows the use of
# computer modern at arbitrary sizes, but that's just a side effect.)
'monospace': r'\usepackage{type1ec}',
'computer modern roman': r'\usepackage{type1ec}',
'computer modern sans serif': r'\usepackage{type1ec}',
'computer modern typewriter': r'\usepackage{type1ec}',
'monospace': _check_cmsuper_installed,
'computer modern roman': _check_cmsuper_installed,
'computer modern sans serif': _check_cmsuper_installed,
'computer modern typewriter': _check_cmsuper_installed,
}
_font_types = {
'new century schoolbook': 'serif',
Expand Down Expand Up @@ -200,6 +207,7 @@ def _get_tex_source(cls, tex, fontsize):
font_preamble, fontcmd = cls._get_font_preamble_and_command()
baselineskip = 1.25 * fontsize
return "\n".join([
r"\RequirePackage{fix-cm}",
r"\documentclass{article}",
r"% Pass-through \mathdefault, which is used in non-usetex mode",
r"% to use the default text font but was historically suppressed",
Expand Down
Loading