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

Skip to content

Commit 1fbd5e2

Browse files
committed
Bugfix: Add stream for AFM path
1 parent 63e0f3a commit 1fbd5e2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
645645
if mpl.rcParams['ps.useafm']:
646646
font = self._get_font_afm(prop)
647647
scale = 0.001 * prop.get_size_in_points()
648-
648+
stream = []
649649
thisx = 0
650650
last_name = None # kerns returns 0 for None.
651651
xs_names = []
@@ -661,6 +661,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
661661
thisx += kern * scale
662662
xs_names.append((thisx, name))
663663
thisx += width * scale
664+
ps_name = (font.postscript_name
665+
.encode("ascii", "replace").decode("ascii"))
666+
stream.append((ps_name, xs_names))
664667

665668
else:
666669
font = self._get_font_ttf(prop)
@@ -680,11 +683,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
680683
# append the last entry
681684
stream.append(curr_stream)
682685

683-
for ps_name, xs_names in stream:
684-
self.set_font(ps_name, prop.get_size_in_points(), False)
685-
thetext = "\n".join(f"{x:f} 0 m /{name:s} glyphshow"
686-
for x, name in xs_names)
687-
self._pswriter.write(f"""\
686+
for ps_name, xs_names in stream:
687+
self.set_font(ps_name, prop.get_size_in_points(), False)
688+
thetext = "\n".join(f"{x:f} 0 m /{name:s} glyphshow"
689+
for x, name in xs_names)
690+
self._pswriter.write(f"""\
688691
gsave
689692
{self._get_clip_cmd(gc)}
690693
{x:f} {y:f} translate

0 commit comments

Comments
 (0)