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

Skip to content

Commit d14874f

Browse files
authored
Merge pull request #18516 from QuLogic/delete-font-deprecations
Remove deprecated font-related things.
2 parents 214ba58 + 7b684a8 commit d14874f

File tree

4 files changed

+11
-169
lines changed

4 files changed

+11
-169
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Fonts
2+
~~~~~
3+
``font_manager.JSONEncoder`` has been removed. Use `.font_manager.json_dump` to
4+
dump a `.FontManager` instance.
5+
6+
``font_manager.createFontList`` has been removed. `.font_manager.FontManager.addfont`
7+
is now available to register a font at a given path.
8+
9+
The ``as_str``, ``as_rgba_str``, ``as_array``, ``get_width`` and ``get_height``
10+
methods of ``matplotlib.ft2font.FT2Image`` have been removed. Convert the
11+
``FT2Image`` to a NumPy array with ``np.asarray`` before processing it.

doc/sphinxext/math_symbol_table.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from docutils.parsers.rst import Directive
22

33
from matplotlib import mathtext
4-
from matplotlib import cbook
54

65

76
symbols = [
@@ -140,13 +139,6 @@ def get_n(n, l):
140139
return []
141140

142141

143-
@cbook.deprecated("3.2", alternative="MathSymbolTableDirective")
144-
def math_symbol_table_directive(
145-
name, arguments, options, content, lineno,
146-
content_offset, block_text, state, state_machine):
147-
return run(state_machine)
148-
149-
150142
class MathSymbolTableDirective(Directive):
151143
has_content = False
152144
required_arguments = 0

lib/matplotlib/font_manager.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -567,60 +567,6 @@ def afmFontProperty(fontpath, font):
567567
return FontEntry(fontpath, name, style, variant, weight, stretch, size)
568568

569569

570-
@cbook.deprecated("3.2", alternative="FontManager.addfont")
571-
def createFontList(fontfiles, fontext='ttf'):
572-
"""
573-
Create a font lookup list. The default is to create
574-
a list of TrueType fonts. An AFM font list can optionally be
575-
created.
576-
"""
577-
578-
fontlist = []
579-
# Add fonts from list of known font files.
580-
seen = set()
581-
for fpath in fontfiles:
582-
_log.debug('createFontDict: %s', fpath)
583-
fname = os.path.split(fpath)[1]
584-
if fname in seen:
585-
continue
586-
if fontext == 'afm':
587-
try:
588-
with open(fpath, 'rb') as fh:
589-
font = afm.AFM(fh)
590-
except EnvironmentError:
591-
_log.info("Could not open font file %s", fpath)
592-
continue
593-
except RuntimeError:
594-
_log.info("Could not parse font file %s", fpath)
595-
continue
596-
try:
597-
prop = afmFontProperty(fpath, font)
598-
except KeyError as exc:
599-
_log.info("Could not extract properties for %s: %s",
600-
fpath, exc)
601-
continue
602-
else:
603-
try:
604-
font = ft2font.FT2Font(fpath)
605-
except (OSError, RuntimeError) as exc:
606-
_log.info("Could not open font file %s: %s", fpath, exc)
607-
continue
608-
except UnicodeError:
609-
_log.info("Cannot handle unicode filenames")
610-
continue
611-
try:
612-
prop = ttfFontProperty(font)
613-
except (KeyError, RuntimeError, ValueError,
614-
NotImplementedError) as exc:
615-
_log.info("Could not extract properties for %s: %s",
616-
fpath, exc)
617-
continue
618-
619-
fontlist.append(prop)
620-
seen.add(fname)
621-
return fontlist
622-
623-
624570
class FontProperties:
625571
"""
626572
A class for storing and manipulating font properties.
@@ -1009,11 +955,6 @@ def default(self, o):
1009955
return super().default(o)
1010956

1011957

1012-
@cbook.deprecated("3.2", alternative="json_dump")
1013-
class JSONEncoder(_JSONEncoder):
1014-
pass
1015-
1016-
1017958
def _json_decode(o):
1018959
cls = o.pop('__class__', None)
1019960
if cls is None:

src/ft2font_wrapper.cpp

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -99,103 +99,6 @@ static PyObject *PyFT2Image_draw_rect_filled(PyFT2Image *self, PyObject *args, P
9999
Py_RETURN_NONE;
100100
}
101101

102-
const char *PyFT2Image_as_str__doc__ =
103-
"s = image.as_str()\n"
104-
"\n"
105-
"[*Deprecated*]\n"
106-
"Return the image buffer as a string\n"
107-
"\n";
108-
109-
static PyObject *PyFT2Image_as_str(PyFT2Image *self, PyObject *args, PyObject *kwds)
110-
{
111-
if (PyErr_WarnEx(PyExc_FutureWarning,
112-
"FT2Image.as_str is deprecated since Matplotlib 3.2 and "
113-
"will be removed in Matplotlib 3.4; convert the FT2Image "
114-
"to a NumPy array with np.asarray instead.",
115-
1)) {
116-
return NULL;
117-
}
118-
return PyBytes_FromStringAndSize((const char *)self->x->get_buffer(),
119-
self->x->get_width() * self->x->get_height());
120-
}
121-
122-
const char *PyFT2Image_as_rgba_str__doc__ =
123-
"s = image.as_rgba_str()\n"
124-
"\n"
125-
"[*Deprecated*]\n"
126-
"Return the image buffer as a RGBA string\n"
127-
"\n";
128-
129-
static PyObject *PyFT2Image_as_rgba_str(PyFT2Image *self, PyObject *args, PyObject *kwds)
130-
{
131-
if (PyErr_WarnEx(PyExc_FutureWarning,
132-
"FT2Image.as_rgba_str is deprecated since Matplotlib 3.2 and "
133-
"will be removed in Matplotlib 3.4; convert the FT2Image "
134-
"to a NumPy array with np.asarray instead.",
135-
1)) {
136-
return NULL;
137-
}
138-
npy_intp dims[] = {(npy_intp)self->x->get_height(), (npy_intp)self->x->get_width(), 4 };
139-
numpy::array_view<unsigned char, 3> result(dims);
140-
141-
unsigned char *src = self->x->get_buffer();
142-
unsigned char *end = src + (self->x->get_width() * self->x->get_height());
143-
unsigned char *dst = result.data();
144-
145-
while (src != end) {
146-
*dst++ = 0;
147-
*dst++ = 0;
148-
*dst++ = 0;
149-
*dst++ = *src++;
150-
}
151-
152-
return result.pyobj();
153-
}
154-
155-
const char *PyFT2Image_as_array__doc__ =
156-
"x = image.as_array()\n"
157-
"\n"
158-
"[*Deprecated*]\n"
159-
"Return the image buffer as a width x height numpy array of ubyte \n"
160-
"\n";
161-
162-
static PyObject *PyFT2Image_as_array(PyFT2Image *self, PyObject *args, PyObject *kwds)
163-
{
164-
if (PyErr_WarnEx(PyExc_FutureWarning,
165-
"FT2Image.as_array is deprecated since Matplotlib 3.2 and "
166-
"will be removed in Matplotlib 3.4; convert the FT2Image "
167-
"to a NumPy array with np.asarray instead.",
168-
1)) {
169-
return NULL;
170-
}
171-
npy_intp dims[] = {(npy_intp)self->x->get_height(), (npy_intp)self->x->get_width() };
172-
return PyArray_SimpleNewFromData(2, dims, NPY_UBYTE, self->x->get_buffer());
173-
}
174-
175-
static PyObject *PyFT2Image_get_width(PyFT2Image *self, PyObject *args, PyObject *kwds)
176-
{
177-
if (PyErr_WarnEx(PyExc_FutureWarning,
178-
"FT2Image.get_width is deprecated since Matplotlib 3.2 and "
179-
"will be removed in Matplotlib 3.4; convert the FT2Image "
180-
"to a NumPy array with np.asarray instead.",
181-
1)) {
182-
return NULL;
183-
}
184-
return PyLong_FromLong(self->x->get_width());
185-
}
186-
187-
static PyObject *PyFT2Image_get_height(PyFT2Image *self, PyObject *args, PyObject *kwds)
188-
{
189-
if (PyErr_WarnEx(PyExc_FutureWarning,
190-
"FT2Image.get_height is deprecated since Matplotlib 3.2 and "
191-
"will be removed in Matplotlib 3.4; convert the FT2Image "
192-
"to a NumPy array with np.asarray instead.",
193-
1)) {
194-
return NULL;
195-
}
196-
return PyLong_FromLong(self->x->get_height());
197-
}
198-
199102
static int PyFT2Image_get_buffer(PyFT2Image *self, Py_buffer *buf, int flags)
200103
{
201104
FT2Image *im = self->x;
@@ -227,11 +130,6 @@ static PyTypeObject *PyFT2Image_init_type(PyObject *m, PyTypeObject *type)
227130
static PyMethodDef methods[] = {
228131
{"draw_rect", (PyCFunction)PyFT2Image_draw_rect, METH_VARARGS, PyFT2Image_draw_rect__doc__},
229132
{"draw_rect_filled", (PyCFunction)PyFT2Image_draw_rect_filled, METH_VARARGS, PyFT2Image_draw_rect_filled__doc__},
230-
{"as_str", (PyCFunction)PyFT2Image_as_str, METH_NOARGS, PyFT2Image_as_str__doc__},
231-
{"as_rgba_str", (PyCFunction)PyFT2Image_as_rgba_str, METH_NOARGS, PyFT2Image_as_rgba_str__doc__},
232-
{"as_array", (PyCFunction)PyFT2Image_as_array, METH_NOARGS, PyFT2Image_as_array__doc__},
233-
{"get_width", (PyCFunction)PyFT2Image_get_width, METH_NOARGS, NULL},
234-
{"get_height", (PyCFunction)PyFT2Image_get_height, METH_NOARGS, NULL},
235133
{NULL}
236134
};
237135

0 commit comments

Comments
 (0)