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

Skip to content

Commit 650160a

Browse files
committed
Add super __init__ to TextPath and mark readonly.
The `vertices` and `codes` properties are overridden, so cannot be set directly, but the arrays that back them can be modified. This seems unintentional, so disable writing on those as well.
1 parent 197d04d commit 650160a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/textpath.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from matplotlib import _text_helpers, dviread, font_manager, rcParams
8+
from matplotlib import _text_helpers, dviread, font_manager
99
from matplotlib.font_manager import FontProperties, get_font
1010
from matplotlib.ft2font import LOAD_NO_HINTING, LOAD_TARGET_LIGHT
1111
from matplotlib.mathtext import MathTextParser
@@ -385,11 +385,11 @@ def __init__(self, xy, s, size=None, prop=None,
385385

386386
self._cached_vertices = None
387387
s, ismath = Text(usetex=usetex)._preprocess_math(s)
388-
self._vertices, self._codes = text_to_path.get_text_path(
389-
prop, s, ismath=ismath)
388+
super().__init__(
389+
*text_to_path.get_text_path(prop, s, ismath=ismath),
390+
_interpolation_steps=_interpolation_steps,
391+
readonly=True)
390392
self._should_simplify = False
391-
self._simplify_threshold = rcParams['path.simplify_threshold']
392-
self._interpolation_steps = _interpolation_steps
393393

394394
def set_size(self, size):
395395
"""Set the text size."""
@@ -427,4 +427,5 @@ def _revalidate_path(self):
427427
.scale(self._size / text_to_path.FONT_SCALE)
428428
.translate(*self._xy))
429429
self._cached_vertices = tr.transform(self._vertices)
430+
self._cached_vertices.flags.writeable = False
430431
self._invalid = False

0 commit comments

Comments
 (0)