From 2c8b2c756d570e6403b6a621cf3966b92f500dde Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 6 Jan 2019 14:19:16 +0100 Subject: [PATCH] Deprecate TextToPath.glyph_to_path. The currx argument is unused, and realistic uses of glyph_to_path that may need currx (to generate the path for layouting multiple glyphs) would likely cache the path for performance anyways (as TextToPath does). If we deprecate currx, then we may as well deprecate glyph_to_path which becomes synonym to `font.get_path()`. --- doc/api/next_api_changes/2018-01-07-AL.rst | 5 +++++ lib/matplotlib/textpath.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 doc/api/next_api_changes/2018-01-07-AL.rst diff --git a/doc/api/next_api_changes/2018-01-07-AL.rst b/doc/api/next_api_changes/2018-01-07-AL.rst new file mode 100644 index 000000000000..5de677905af0 --- /dev/null +++ b/doc/api/next_api_changes/2018-01-07-AL.rst @@ -0,0 +1,5 @@ +Deprecations +```````````` + +``TextToPath.glyph_to_path`` is deprecated (call ``font.get_path()`` and +manually transform the path instead). diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 91b5079f06a1..df4b520e7846 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -67,6 +67,9 @@ def _get_char_id_ps(self, font, ccode): char_id = urllib.parse.quote('%s-%d' % (ps_name, ccode)) return char_id + @cbook.deprecated( + "3.1", + alternative="font.get_path() and manual translation of the vertices") def glyph_to_path(self, font, currx=0.): """ convert the ft2font glyph to vertices and codes. @@ -215,7 +218,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None, char_id = self._get_char_id(font, ccode) if char_id not in glyph_map: - glyph_map_new[char_id] = self.glyph_to_path(font) + glyph_map_new[char_id] = font.get_path() currx += kern / 64 @@ -266,7 +269,7 @@ def get_glyphs_mathtext(self, prop, s, glyph_map=None, font.clear() font.set_size(self.FONT_SCALE, self.DPI) glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) - glyph_map_new[char_id] = self.glyph_to_path(font) + glyph_map_new[char_id] = font.get_path() xpositions.append(ox) ypositions.append(oy) @@ -343,7 +346,7 @@ def get_glyphs_tex(self, prop, s, glyph_map=None, glyph0 = font.load_char(glyph, flags=ft2font_flag) - glyph_map_new[char_id] = self.glyph_to_path(font) + glyph_map_new[char_id] = font.get_path() glyph_ids.append(char_id) xpositions.append(x1)