Skip to content

Commit 9d61a67

Browse files
committed
Merge branch 'v1.5.x' into v2.0.x
2 parents 454c330 + d6d64df commit 9d61a67

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import threading
2828
import numpy as np
29-
29+
from math import radians, cos, sin
3030
from matplotlib import verbose, rcParams
3131
from matplotlib.backend_bases import (RendererBase, FigureManagerBase,
3232
FigureCanvasBase)
@@ -173,10 +173,10 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
173173
ox, oy, width, height, descent, font_image, used_characters = \
174174
self.mathtext_parser.parse(s, self.dpi, prop)
175175

176-
xd = descent * np.sin(np.deg2rad(angle))
177-
yd = descent * np.cos(np.deg2rad(angle))
178-
x = np.round(x + ox + xd)
179-
y = np.round(y - oy + yd)
176+
xd = descent * sin(radians(angle))
177+
yd = descent * cos(radians(angle))
178+
x = round(x + ox + xd)
179+
y = round(y - oy + yd)
180180
self._renderer.draw_text_image(font_image, x, y + 1, angle, gc)
181181

182182
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
@@ -204,12 +204,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
204204
xo, yo = font.get_bitmap_offset()
205205
xo /= 64.0
206206
yo /= 64.0
207-
xd = -d * np.sin(np.deg2rad(angle))
208-
yd = d * np.cos(np.deg2rad(angle))
207+
xd = -d * sin(radians(angle))
208+
yd = d * cos(radians(angle))
209209

210210
#print x, y, int(x), int(y), s
211211
self._renderer.draw_text_image(
212-
font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc)
212+
font, round(x - xd + xo), round(y + yd + yo) + 1, angle, gc)
213213

214214
def get_text_width_height_descent(self, s, prop, ismath):
215215
"""
@@ -254,10 +254,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
254254
Z = np.array(Z * 255.0, np.uint8)
255255

256256
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
257-
xd = d * np.sin(np.deg2rad(angle))
258-
yd = d * np.cos(np.deg2rad(angle))
259-
x = np.round(x + xd)
260-
y = np.round(y + yd)
257+
xd = d * sin(radians(angle))
258+
yd = d * cos(radians(angle))
259+
x = round(x + xd)
260+
y = round(y + yd)
261261

262262
self._renderer.draw_text_image(Z, x, y, angle, gc)
263263

src/_image_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ static PyObject *PyImage_color_conv(PyImage *self, PyObject *args, PyObject *kwd
177177
free(buff));
178178

179179
PyObject *result = PyByteArray_FromStringAndSize((const char *)buff, size);
180+
free(buff);
180181
if (result == NULL) {
181-
free(buff);
182182
return NULL;
183183
}
184184

src/_path.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,6 @@ int convert_to_string(PathIterator &path,
11361136

11371137
*buffersize = path.total_vertices() * (precision + 5) * 4;
11381138
if (*buffersize == 0) {
1139-
*buffer = NULL;
11401139
return 0;
11411140
}
11421141

src/_path_wrapper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,9 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
638638
PyObject *codesobj;
639639
char *codes[5];
640640
int postfix;
641-
char *buffer;
641+
char *buffer = NULL;
642642
size_t buffersize;
643+
PyObject *result;
643644
int status;
644645

645646
if (!PyArg_ParseTuple(args,
@@ -702,10 +703,14 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
702703
}
703704

704705
if (buffersize == 0) {
705-
return PyBytes_FromString("");
706+
result = PyBytes_FromString("");
706707
} else {
707-
return PyBytes_FromStringAndSize(buffer, buffersize);
708+
result = PyBytes_FromStringAndSize(buffer, buffersize);
708709
}
710+
711+
free(buffer);
712+
713+
return result;
709714
}
710715

711716
extern "C" {

src/ft2font_wrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ static PyObject *PyFT2Font_get_name_index(PyFT2Font *self, PyObject *args, PyObj
10531053

10541054
CALL_CPP("get_name_index", name_index = self->x->get_name_index(glyphname));
10551055

1056+
PyMem_Free(glyphname);
1057+
10561058
return PyLong_FromLong(name_index);
10571059
}
10581060

@@ -1106,6 +1108,8 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11061108
}
11071109
}
11081110

1111+
PyMem_Free(tagname);
1112+
11091113
void *table = FT_Get_Sfnt_Table(self->x->get_face(), (FT_Sfnt_Tag)tag);
11101114
if (!table) {
11111115
Py_RETURN_NONE;

0 commit comments

Comments
 (0)