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

Skip to content

Commit 9059da7

Browse files
committed
Support font features/language in default RendererBase.draw_text
If a backend doesn't implement `draw_text`, then we fall back to this implementation that draws paths. It was previously missing support for font features and languages.
1 parent 41c4d8d commit 9059da7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/matplotlib/backend_bases.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,19 +540,25 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
540540
rendering backends, and indeed many builtin backends do not support
541541
this. Rather, TeX rendering is provided by `~.RendererBase.draw_tex`.
542542
"""
543-
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath)
543+
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath, mtext)
544544

545-
def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
545+
def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext):
546546
"""
547547
Draw the text by converting them to paths using `.TextToPath`.
548548
549549
This private helper supports the same parameters as
550550
`~.RendererBase.draw_text`; setting *ismath* to "TeX" triggers TeX
551551
rendering.
552552
"""
553+
if mtext is not None:
554+
features = mtext.get_fontfeatures()
555+
language = mtext.get_language()
556+
else:
557+
features = language = None
553558
text2path = self._text2path
554559
fontsize = self.points_to_pixels(prop.get_size_in_points())
555-
verts, codes = text2path.get_text_path(prop, s, ismath=ismath)
560+
verts, codes = text2path.get_text_path(prop, s, ismath=ismath,
561+
features=features, language=language)
556562
path = Path(verts, codes)
557563
if self.flipy():
558564
width, height = self.get_canvas_width_height()

0 commit comments

Comments
 (0)