Skip to content

Commit 1885e46

Browse files
oscargusOscar Gustafsson
authored and
Oscar Gustafsson
committed
Recreated deprecated files and changed references
1 parent cd8abb0 commit 1885e46

17 files changed

+51
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
``Type1Font`` objects include more properties
22
---------------------------------------------
33

4-
The `.type1font.Type1Font.prop` dictionary now includes more keys, such
5-
as ``CharStrings`` and ``Subrs``. The value of the ``Encoding`` key is
4+
The ``matplotlib._type1font.Type1Font.prop`` dictionary now includes more keys,
5+
such as ``CharStrings`` and ``Subrs``. The value of the ``Encoding`` key is
66
now a dictionary mapping codes to glyph names. The
7-
`.type1font.Type1Font.transform` method now correctly removes
7+
``matplotlib._type1font.Type1Font.transform`` method now correctly removes
88
``UniqueID`` properties from the font.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
``AFM``, ``configfont_pattern`` and ``Type1Font`` deprecated
2+
------------------------------------------------------------
3+
4+
The modules ``matplotlib.AFM``, ``matplotlib.configfont_pattern``, and
5+
``matplotlib.Type1Font`` are considered internal and public access is
6+
deprecated.

doc/api/prev_api_changes/api_changes_0.91.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Changes for 0.91.0
3636
pfa/pfb file, to get metrics and kerning information for a Type 1
3737
font.
3838

39-
* The :class:`.AFM` class now supports querying CapHeight and stem
39+
* The ``AFM`` class now supports querying CapHeight and stem
4040
widths. The get_name_char method now has an isord kwarg like
4141
get_width_char.
4242

doc/api/prev_api_changes/api_changes_0.98.x.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Changes for 0.98.x
6363
:meth:`matplotlib.axes.Axes.set_ylim` now return a copy of the
6464
``viewlim`` array to avoid modify-in-place surprises.
6565

66-
* :meth:`matplotlib.afm.AFM.get_fullname` and
67-
:meth:`matplotlib.afm.AFM.get_familyname` no longer raise an
66+
* ``matplotlib.afm.AFM.get_fullname`` and
67+
``matplotlib.afm.AFM.get_familyname`` no longer raise an
6868
exception if the AFM file does not specify these optional
6969
attributes, but returns a guess based on the required FontName
7070
attribute.

doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ defaults to *False*.
229229

230230
Type 1 fonts have a large part of their code encrypted as an obsolete
231231
copy-protection measure. This part is now available decrypted as the
232-
``decrypted`` attribute of `~.type1font.Type1Font`. This decrypted data is not
233-
yet parsed, but this is a prerequisite for implementing subsetting.
232+
``decrypted`` attribute of ``matplotlib.type1font.Type1Font``. This decrypted
233+
data is not yet parsed, but this is a prerequisite for implementing subsetting.
234234

235235
3D contourf polygons placed between levels
236236
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/_mathtext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ._mathtext_data import (
2323
latex_to_bakoma, latex_to_standard, stix_glyph_fixes, stix_virtual_fonts,
2424
tex2uni)
25-
from .afm import AFM
25+
from ._afm import AFM
2626
from .font_manager import FontProperties, findfont, get_font
2727
from .ft2font import KERNING_DEFAULT
2828

lib/matplotlib/afm.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from matplotlib._afm import * # noqa: F401, F403
2+
from matplotlib import _api
3+
_api.warn_deprecated(
4+
"3.6", message="The module %(name)s is deprecated since %(since)s.",
5+
name=f"{__name__}")

lib/matplotlib/backends/_backend_pdf_ps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import matplotlib as mpl
1111
from .. import font_manager, ft2font
12-
from ..afm import AFM
12+
from .._afm import AFM
1313
from ..backend_bases import RendererBase
1414

1515

lib/matplotlib/backends/backend_pdf.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@
2626
from PIL import Image
2727

2828
import matplotlib as mpl
29-
from matplotlib import _api, _text_helpers, cbook
29+
from matplotlib import _api, _text_helpers, _type1font, cbook, dviread
3030
from matplotlib._pylab_helpers import Gcf
3131
from matplotlib.backend_bases import (
3232
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
3333
RendererBase)
3434
from matplotlib.backends.backend_mixed import MixedModeRenderer
3535
from matplotlib.figure import Figure
3636
from matplotlib.font_manager import findfont, get_font
37-
from matplotlib.afm import AFM
38-
import matplotlib.type1font as type1font
39-
import matplotlib.dviread as dviread
37+
from matplotlib._afm import AFM
4038
from matplotlib.ft2font import (FIXED_WIDTH, ITALIC, LOAD_NO_SCALE,
4139
LOAD_NO_HINTING, KERNING_UNFITTED, FT2Font)
4240
from matplotlib.mathtext import MathTextParser
@@ -982,7 +980,7 @@ def _embedTeXFont(self, fontinfo):
982980
return fontdictObject
983981

984982
# We have a font file to embed - read it in and apply any effects
985-
t1font = type1font.Type1Font(fontinfo.fontfile)
983+
t1font = _type1font.Type1Font(fontinfo.fontfile)
986984
if fontinfo.effects:
987985
t1font = t1font.transform(fontinfo.effects)
988986
fontdict['BaseFont'] = Name(t1font.prop['FontName'])

lib/matplotlib/backends/backend_ps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import matplotlib as mpl
2424
from matplotlib import _api, cbook, _path, _text_helpers
25-
from matplotlib.afm import AFM
25+
from matplotlib._afm import AFM
2626
from matplotlib.backend_bases import (
2727
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
2828
RendererBase)

lib/matplotlib/font_manager.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
from dummy_threading import Timer
4444

4545
import matplotlib as mpl
46-
from matplotlib import _api, afm, cbook, ft2font, rcParams
47-
from matplotlib.fontconfig_pattern import (
46+
from matplotlib import _api, _afm, cbook, ft2font, rcParams
47+
from matplotlib._fontconfig_pattern import (
4848
parse_fontconfig_pattern, generate_fontconfig_pattern)
4949
from matplotlib.rcsetup import _validators
5050

@@ -553,7 +553,7 @@ def afmFontProperty(fontpath, font):
553553
554554
Parameters
555555
----------
556-
font : `.AFM`
556+
font : AFM
557557
The AFM font file from which information will be extracted.
558558
559559
Returns
@@ -1107,7 +1107,7 @@ def addfont(self, path):
11071107
"""
11081108
if Path(path).suffix.lower() == ".afm":
11091109
with open(path, "rb") as fh:
1110-
font = afm.AFM(fh)
1110+
font = _afm.AFM(fh)
11111111
prop = afmFontProperty(path, font)
11121112
self.afmlist.append(prop)
11131113
else:

lib/matplotlib/fontconfig_pattern.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from matplotlib._fontconfig_pattern import * # noqa: F401, F403
2+
from matplotlib import _api
3+
_api.warn_deprecated(
4+
"3.6", message="The module %(name)s is deprecated since %(since)s.",
5+
name=f"{__name__}")

lib/matplotlib/rcsetup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from matplotlib import _api, cbook
2626
from matplotlib.cbook import ls_mapper
2727
from matplotlib.colors import Colormap, is_color_like
28-
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
28+
from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
2929
from matplotlib._enums import JoinStyle, CapStyle
3030

3131
# Don't let the original cycler collide with our validating cycler

lib/matplotlib/tests/test_afm.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
import logging
44

5-
from matplotlib import afm
5+
from matplotlib import _afm
66
from matplotlib import font_manager as fm
77

88

@@ -39,13 +39,13 @@ def test_nonascii_str():
3939
inp_str = "привет"
4040
byte_str = inp_str.encode("utf8")
4141

42-
ret = afm._to_str(byte_str)
42+
ret = _afm._to_str(byte_str)
4343
assert ret == inp_str
4444

4545

4646
def test_parse_header():
4747
fh = BytesIO(AFM_TEST_DATA)
48-
header = afm._parse_header(fh)
48+
header = _afm._parse_header(fh)
4949
assert header == {
5050
b'StartFontMetrics': 2.0,
5151
b'FontName': 'MyFont-Bold',
@@ -66,8 +66,8 @@ def test_parse_header():
6666

6767
def test_parse_char_metrics():
6868
fh = BytesIO(AFM_TEST_DATA)
69-
afm._parse_header(fh) # position
70-
metrics = afm._parse_char_metrics(fh)
69+
_afm._parse_header(fh) # position
70+
metrics = _afm._parse_char_metrics(fh)
7171
assert metrics == (
7272
{0: (250.0, 'space', [0, 0, 0, 0]),
7373
42: (1141.0, 'foo', [40, 60, 800, 360]),
@@ -81,13 +81,13 @@ def test_parse_char_metrics():
8181

8282
def test_get_familyname_guessed():
8383
fh = BytesIO(AFM_TEST_DATA)
84-
font = afm.AFM(fh)
84+
font = _afm.AFM(fh)
8585
del font._header[b'FamilyName'] # remove FamilyName, so we have to guess
8686
assert font.get_familyname() == 'My Font'
8787

8888

8989
def test_font_manager_weight_normalization():
90-
font = afm.AFM(BytesIO(
90+
font = _afm.AFM(BytesIO(
9191
AFM_TEST_DATA.replace(b"Weight Bold\n", b"Weight Custom\n")))
9292
assert fm.afmFontProperty("", font).weight == "normal"
9393

@@ -107,7 +107,7 @@ def test_font_manager_weight_normalization():
107107
def test_bad_afm(afm_data):
108108
fh = BytesIO(afm_data)
109109
with pytest.raises(RuntimeError):
110-
afm._parse_header(fh)
110+
_afm._parse_header(fh)
111111

112112

113113
@pytest.mark.parametrize(
@@ -132,6 +132,6 @@ def test_bad_afm(afm_data):
132132
def test_malformed_header(afm_data, caplog):
133133
fh = BytesIO(afm_data)
134134
with caplog.at_level(logging.ERROR):
135-
afm._parse_header(fh)
135+
_afm._parse_header(fh)
136136

137137
assert len(caplog.records) == 1

lib/matplotlib/tests/test_text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def test_antialiasing():
199199
def test_afm_kerning():
200200
fn = mpl.font_manager.findfont("Helvetica", fontext="afm")
201201
with open(fn, 'rb') as fh:
202-
afm = mpl.afm.AFM(fh)
202+
afm = mpl._afm.AFM(fh)
203203
assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)
204204

205205

lib/matplotlib/tests/test_type1font.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import matplotlib.type1font as t1f
1+
import matplotlib._type1font as t1f
22
import os.path
33
import difflib
44
import pytest

lib/matplotlib/type1font.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from matplotlib._type1font import * # noqa: F401, F403
2+
from matplotlib import _api
3+
_api.warn_deprecated(
4+
"3.6", message="The module %(name)s is deprecated since %(since)s.",
5+
name=f"{__name__}")

0 commit comments

Comments
 (0)