@@ -69,7 +69,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
6969 d /= 64.0
7070 return w * scale , h * scale , d * scale
7171
72- def get_text_path (self , prop , s , ismath = False ):
72+ def get_text_path (self , prop , s , ismath = False , * , language = None ):
7373 """
7474 Convert text *s* to path (a tuple of vertices and codes for
7575 matplotlib.path.Path).
@@ -82,6 +82,9 @@ def get_text_path(self, prop, s, ismath=False):
8282 The text to be converted.
8383 ismath : {False, True, "TeX"}
8484 If True, use mathtext parser. If "TeX", use tex for rendering.
85+ language : str or list of tuples of (str, int, int), optional
86+ The language of the text in a format accepted by libraqm, namely `a BCP47
87+ language code <https://www.w3.org/International/articles/language-tags/>`_.
8588
8689 Returns
8790 -------
@@ -109,7 +112,8 @@ def get_text_path(self, prop, s, ismath=False):
109112 glyph_info , glyph_map , rects = self .get_glyphs_tex (prop , s )
110113 elif not ismath :
111114 font = self ._get_font (prop )
112- glyph_info , glyph_map , rects = self .get_glyphs_with_font (font , s )
115+ glyph_info , glyph_map , rects = self .get_glyphs_with_font (font , s ,
116+ language = language )
113117 else :
114118 glyph_info , glyph_map , rects = self .get_glyphs_mathtext (prop , s )
115119
@@ -130,7 +134,7 @@ def get_text_path(self, prop, s, ismath=False):
130134 return verts , codes
131135
132136 def get_glyphs_with_font (self , font , s , glyph_map = None ,
133- return_new_glyphs_only = False ):
137+ return_new_glyphs_only = False , * , language = None ):
134138 """
135139 Convert string *s* to vertices and codes using the provided ttf font.
136140 """
@@ -145,7 +149,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
145149
146150 xpositions = []
147151 glyph_ids = []
148- for item in _text_helpers .layout (s , font ):
152+ for item in _text_helpers .layout (s , font , language ):
149153 char_id = self ._get_char_id (item .ft_object , ord (item .char ))
150154 glyph_ids .append (char_id )
151155 xpositions .append (item .x )
0 commit comments