@@ -769,7 +769,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
769769 if ismath :
770770 return self .draw_mathtext (gc , x , y , s , prop , angle )
771771
772- stream = [] # list of (ps_name, x, char_name)
772+ stream = [] # list of (ps_name, x, y, char_name)
773773
774774 if mpl .rcParams ['ps.useafm' ]:
775775 font = self ._get_font_afm (prop )
@@ -787,7 +787,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
787787 kern = font .get_kern_dist_from_name (last_name , name )
788788 last_name = name
789789 thisx += kern * scale
790- stream .append ((ps_name , thisx , name ))
790+ stream .append ((ps_name , thisx , 0 , name ))
791791 thisx += width * scale
792792
793793 else :
@@ -797,20 +797,19 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
797797 else :
798798 features = language = None
799799 font = self ._get_font_ttf (prop )
800- self ._character_tracker .track (font , s )
801800 for item in _text_helpers .layout (s , font , features = features ,
802801 language = language ):
802+ self ._character_tracker .track_glyph (item .ft_object , item .glyph_index )
803803 ps_name = (item .ft_object .postscript_name
804804 .encode ("ascii" , "replace" ).decode ("ascii" ))
805805 glyph_name = item .ft_object .get_glyph_name (item .glyph_index )
806- stream .append ((ps_name , item .x , glyph_name ))
806+ stream .append ((ps_name , item .x , item . y , glyph_name ))
807807 self .set_color (* gc .get_rgb ())
808808
809- for ps_name , group in itertools . \
810- groupby (stream , lambda entry : entry [0 ]):
809+ for ps_name , group in itertools .groupby (stream , lambda entry : entry [0 ]):
811810 self .set_font (ps_name , prop .get_size_in_points (), False )
812- thetext = "\n " .join (f"{ x :g} 0 m /{ name :s} glyphshow"
813- for _ , x , name in group )
811+ thetext = "\n " .join (f"{ x :g} { y :g } m /{ name :s} glyphshow"
812+ for _ , x , y , name in group )
814813 self ._pswriter .write (f"""\
815814 gsave
816815{ self ._get_clip_cmd (gc )}
0 commit comments