8000 Use fix-cm instead of type1cm. · matplotlib/matplotlib@581ab44 · GitHub
[go: up one dir, main page]

Skip to content

Commit 581ab44

Browse files
committed
Use fix-cm instead of type1cm.
... to fix unicode glyph sizing issues for svg & patheffects.
1 parent 903d537 commit 581ab44

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

doc/install/dependencies.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ will often automatically include these collections.
443443
| | `lm <https://ctan.org/pkg/lm>`_, |
444444
| | `txfonts <https://ctan.org/pkg/txfonts>`_ |
445445
+-----------------------------+--------------------------------------------------+
446-
| collection-latex | `geometry <https://ctan.org/pkg/geometry>`_, |
446+
| collection-latex | `fix-cm <https://ctan.org/pkg/fix-cm>`_, |
447+
| | `geometry <https://ctan.org/pkg/geometry>`_, |
447448
| | `hyperref <https://ctan.org/pkg/hyperref>`_, |
448449
| | `latex <https://ctan.org/pkg/latex>`_, |
449450
| | latex-bin, |

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
# become quite long.
340340
# The following packages are always loaded with usetex,
341341
# so beware of package collisions:
342-
# geometry, inputenc, type1cm.
342+
# color, fix-cm, geometry, graphicx, textcomp.
343343
# PostScript (PSNFSS) font packages may also be
344344
# loaded, depending on your font settings.
345345

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
122122
# Note that it has to be put on a single line, which may
123123
# become quite long.
124124
# The following packages are always loaded with usetex, so
125-
# beware of package collisions: color, geometry, graphicx,
126-
# type1cm, textcomp.
125+
# beware of package collisions:
126+
# color, fix-cm, geometry, graphicx, textcomp.
127127
# Adobe Postscript (PSSNFS) font packages may also be
128128
# loaded, depending on your font settings.
129129

lib/matplotlib/tests/test_usetex.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,10 @@ def test_rotation():
185185
# 'My' checks full height letters plus descenders.
186186
ax.text(x, y, f"$\\mathrm{{My {text[ha]}{text[va]} {angle}}}$",
187187
rotation=angle, horizontalalignment=ha, verticalalignment=va)
188+
189+
190+
def test_unicode_sizing():
191+
tp = mpl.textpath.TextToPath()
192+
scale1 = tp.get_glyphs_tex(mpl.font_manager.FontProperties(), "W")[0][0][3]
193+
scale2 = tp.get_glyphs_tex(mpl.font_manager.FontProperties(), r"\textwon")[0][0][3]
194+
assert scale1 == scale2

lib/matplotlib/texmanager.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class TexManager:
6767
_grey_arrayd = {}
6868

6969
_font_families = ('serif', 'sans-serif', 'cursive', 'monospace')
70+
# Check for the cm-super package (which registers unicode computer modern
71+
# support just by being installed) without actually loading any package
72+
# (because we already load the incompatible fix-cm).
73+
_check_cmsuper_installed = (
74+
r'\IfFileExists{type1ec.sty}{}{\PackageError{matplotlib-support}{'
75+
r'Missing cm-super package, required by Matplotlib}{}}'
76+
)
7077
_font_preambles = {
7178
'new century schoolbook': r'\renewcommand{\rmdefault}{pnc}',
7279
'bookman': r'\renewcommand{\rmdefault}{pbk}',
@@ -83,10 +90,10 @@ class TexManager:
8390
# Loading the type1ec package ensures that cm-super is installed, which
8491
# is necessary for Unicode computer modern. (It also allows the use of
8592
# computer modern at arbitrary sizes, but that's just a side effect.)
86-
'monospace': r'\usepackage{type1ec}',
87-
'computer modern roman': r'\usepackage{type1ec}',
88-
'computer modern sans serif': r'\usepackage{type1ec}',
89-
'computer modern typewriter': r'\usepackage{type1ec}',
93+
'monospace': _check_cmsuper_installed,
94+
'computer modern roman': _check_cmsuper_installed,
95+
'computer modern sans serif': _check_cmsuper_installed,
96+
'computer modern typewriter': _check_cmsuper_installed,
9097
}
9198
_font_types = {
9299
'new century schoolbook': 'serif',
@@ -200,6 +207,7 @@ def _get_tex_source(cls, tex, fontsize):
200207
font_preamble, fontcmd = cls._get_font_preamble_and_command()
201208
baselineskip = 1.25 * fontsize
202209
return "\n".join([
210+
r"\RequirePackage{fix-cm}",
203211
r"\documentclass{article}",
204212
r"% Pass-through \mathdefault, which is used in non-usetex mode",
205213
r"% to use the default text font but was historically suppressed",

0 commit comments

Comments
 (0)
0