Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Recreated deprecated files and changed references
  • Loading branch information
oscargus authored and Oscar Gustafsson committed Jan 16, 2022
commit 1885e460ff39b73377f5a94197c9f8d301ac5288
6 changes: 3 additions & 3 deletions doc/api/next_api_changes/behavior/20715-JKS.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
``Type1Font`` objects include more properties
---------------------------------------------

The `.type1font.Type1Font.prop` dictionary now includes more keys, such
as ``CharStrings`` and ``Subrs``. The value of the ``Encoding`` key is
The ``matplotlib._type1font.Type1Font.prop`` dictionary now includes more keys,
such as ``CharStrings`` and ``Subrs``. The value of the ``Encoding`` key is
now a dictionary mapping codes to glyph names. The
`.type1font.Type1Font.transform` method now correctly removes
``matplotlib._type1font.Type1Font.transform`` method now correctly removes
``UniqueID`` properties from the font.
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/deprecations/22133-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
``AFM``, ``configfont_pattern`` and ``Type1Font`` deprecated
------------------------------------------------------------

The modules ``matplotlib.AFM``, ``matplotlib.configfont_pattern``, and
``matplotlib.Type1Font`` are considered internal and public access is
deprecated.
2 changes: 1 addition & 1 deletion doc/api/prev_api_changes/api_changes_0.91.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Changes for 0.91.0
pfa/pfb file, to get metrics and kerning information for a Type 1
font.

* The :class:`.AFM` class now supports querying CapHeight and stem
* The ``AFM`` class now supports querying CapHeight and stem
widths. The get_name_char method now has an isord kwarg like
get_width_char.

Expand Down
4 changes: 2 additions & 2 deletions doc/api/prev_api_changes/api_changes_0.98.x.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Changes for 0.98.x
:meth:`matplotlib.axes.Axes.set_ylim` now return a copy of the
``viewlim`` array to avoid modify-in-place surprises.

* :meth:`matplotlib.afm.AFM.get_fullname` and
:meth:`matplotlib.afm.AFM.get_familyname` no longer raise an
* ``matplotlib.afm.AFM.get_fullname`` and
``matplotlib.afm.AFM.get_familyname`` no longer raise an
exception if the AFM file does not specify these optional
attributes, but returns a guess based on the required FontName
attribute.
Expand Down
4 changes: 2 additions & 2 deletions doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ defaults to *False*.

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

3D contourf polygons placed between levels
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ._mathtext_data import (
latex_to_bakoma, latex_to_standard, stix_glyph_fixes, stix_virtual_fonts,
tex2uni)
from .afm import AFM
from ._afm import AFM
from .font_manager import FontProperties, findfont, get_font
from .ft2font import KERNING_DEFAULT

Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/afm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from matplotlib._afm import * # noqa: F401, F403
from matplotlib import _api
_api.warn_deprecated(
"3.6", message="The module %(name)s is deprecated since %(since)s.",
name=f"{__name__}")
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/_backend_pdf_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import matplotlib as mpl
from .. import font_manager, ft2font
from ..afm import AFM
from .._afm import AFM
from ..backend_bases import RendererBase


Expand Down
8 changes: 3 additions & 5 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
from PIL import Image

import matplotlib as mpl
from matplotlib import _api, _text_helpers, cbook
from matplotlib import _api, _text_helpers, _type1font, cbook, dviread
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import (
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
RendererBase)
from matplotlib.backends.backend_mixed import MixedModeRenderer
from matplotlib.figure import Figure
from matplotlib.font_manager import findfont, get_font
from matplotlib.afm import AFM
import matplotlib.type1font as type1font
import matplotlib.dviread as dviread
from matplotlib._afm import AFM
from matplotlib.ft2font import (FIXED_WIDTH, ITALIC, LOAD_NO_SCALE,
LOAD_NO_HINTING, KERNING_UNFITTED, FT2Font)
from matplotlib.mathtext import MathTextParser
Expand Down Expand Up @@ -982,7 +980,7 @@ def _embedTeXFont(self, fontinfo):
return fontdictObject

# We have a font file to embed - read it in and apply any effects
t1font = type1font.Type1Font(fontinfo.fontfile)
t1font = _type1font.Type1Font(fontinfo.fontfile)
if fontinfo.effects:
t1font = t1font.transform(fontinfo.effects)
fontdict['BaseFont'] = Name(t1font.prop['FontName'])
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import matplotlib as mpl
from matplotlib import _api, cbook, _path, _text_helpers
from matplotlib.afm import AFM
from matplotlib._afm import AFM
from matplotlib.backend_bases import (
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
RendererBase)
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
from dummy_threading import Timer

import matplotlib as mpl
from matplotlib import _api, afm, cbook, ft2font, rcParams
from matplotlib.fontconfig_pattern import (
from matplotlib import _api, _afm, cbook, ft2font, rcParams
from matplotlib._fontconfig_pattern import (
parse_fontconfig_pattern, generate_fontconfig_pattern)
from matplotlib.rcsetup import _validators

Expand Down Expand Up @@ -553,7 +553,7 @@ def afmFontProperty(fontpath, font):

Parameters
----------
font : `.AFM`
font : AFM
The AFM font file from which information will be extracted.

Returns
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def addfont(self, path):
"""
if Path(path).suffix.lower() == ".afm":
with open(path, "rb") as fh:
font = afm.AFM(fh)
font = _afm.AFM(fh)
prop = afmFontProperty(path, font)
self.afmlist.append(prop)
else:
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/fontconfig_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from matplotlib._fontconfig_pattern import * # noqa: F401, F403
from matplotlib import _api
_api.warn_deprecated(
"3.6", message="The module %(name)s is deprecated since %(since)s.",
name=f"{__name__}")
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from matplotlib import _api, cbook
from matplotlib.cbook import ls_mapper
from matplotlib.colors import Colormap, is_color_like
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
from matplotlib._enums import JoinStyle, CapStyle

# Don't let the original cycler collide with our validating cycler
Expand Down
18 changes: 9 additions & 9 deletions lib/matplotlib/tests/test_afm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import logging

from matplotlib import afm
from matplotlib import _afm
from matplotlib import font_manager as fm


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

ret = afm._to_str(byte_str)
ret = _afm._to_str(byte_str)
assert ret == inp_str


def test_parse_header():
fh = BytesIO(AFM_TEST_DATA)
header = afm._parse_header(fh)
header = _afm._parse_header(fh)
assert header == {
b'StartFontMetrics': 2.0,
b'FontName': 'MyFont-Bold',
Expand All @@ -66,8 +66,8 @@ def test_parse_header():

def test_parse_char_metrics():
fh = BytesIO(AFM_TEST_DATA)
afm._parse_header(fh) # position
metrics = afm._parse_char_metrics(fh)
_afm._parse_header(fh) # position
metrics = _afm._parse_char_metrics(fh)
assert metrics == (
{0: (250.0, 'space', [0, 0, 0, 0]),
42: (1141.0, 'foo', [40, 60, 800, 360]),
Expand All @@ -81,13 +81,13 @@ def test_parse_char_metrics():

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


def test_font_manager_weight_normalization():
font = afm.AFM(BytesIO(
font = _afm.AFM(BytesIO(
AFM_TEST_DATA.replace(b"Weight Bold\n", b"Weight Custom\n")))
assert fm.afmFontProperty("", font).weight == "normal"

Expand All @@ -107,7 +107,7 @@ def test_font_manager_weight_normalization():
def test_bad_afm(afm_data):
fh = BytesIO(afm_data)
with pytest.raises(RuntimeError):
afm._parse_header(fh)
_afm._parse_header(fh)


@pytest.mark.parametrize(
Expand All @@ -132,6 +132,6 @@ def test_bad_afm(afm_data):
def test_malformed_header(afm_data, caplog):
fh = BytesIO(afm_data)
with caplog.at_level(logging.ERROR):
afm._parse_header(fh)
_afm._parse_header(fh)

assert len(caplog.records) == 1
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_antialiasing():
def test_afm_kerning():
fn = mpl.font_manager.findfont("Helvetica", fontext="afm")
with open(fn, 'rb') as fh:
afm = mpl.afm.AFM(fh)
afm = mpl._afm.AFM(fh)
assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_type1font.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import matplotlib.type1font as t1f
import matplotlib._type1font as t1f
import os.path
import difflib
import pytest
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/type1font.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from matplotlib._type1font import * # noqa: F401, F403
from matplotlib import _api
_api.warn_deprecated(
"3.6", message="The module %(name)s is deprecated since %(since)s.",
name=f"{__name__}")