@@ -69,7 +69,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
69
69
d /= 64.0
70
70
return w * scale , h * scale , d * scale
71
71
72
- def get_text_path (self , prop , s , ismath = False ):
72
+ def get_text_path (self , prop , s , ismath = False , * , language = None ):
73
73
"""
74
74
Convert text *s* to path (a tuple of vertices and codes for
75
75
matplotlib.path.Path).
@@ -82,6 +82,9 @@ def get_text_path(self, prop, s, ismath=False):
82
82
The text to be converted.
83
83
ismath : {False, True, "TeX"}
84
84
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/>`_.
85
88
86
89
Returns
87
90
-------
@@ -109,7 +112,8 @@ def get_text_path(self, prop, s, ismath=False):
109
112
glyph_info , glyph_map , rects = self .get_glyphs_tex (prop , s )
110
113
elif not ismath :
111
114
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 )
113
117
else :
114
118
glyph_info , glyph_map , rects = self .get_glyphs_mathtext (prop , s )
115
119
@@ -130,7 +134,7 @@ def get_text_path(self, prop, s, ismath=False):
130
134
return verts , codes
131
135
132
136
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 ):
134
138
"""
135
139
Convert string *s* to vertices and codes using the provided ttf font.
136
140
"""
@@ -145,7 +149,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
145
149
146
150
xpositions = []
147
151
glyph_ids = []
148
- for item in _text_helpers .layout (s , font ):
152
+ for item in _text_helpers .layout (s , font , language ):
149
153
char_id = self ._get_char_id (item .ft_object , ord (item .char ))
150
154
glyph_ids .append (char_id )
151
155
xpositions .append (item .x )
0 commit comments