Skip to content

Commit

Permalink
Merge pull request matplotlib#11130 from anntzer/postscript-unicode-t…
Browse files Browse the repository at this point in the history
…itle

FIX: Only use latin-1 encodable letters in ps title
  • Loading branch information
tacaswell authored Apr 28, 2018
2 parents cc4d9ce + 9e311d9 commit 3ba79fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ def _print_figure(
if isinstance(outfile,
(six.string_types, getattr(os, "PathLike", ()),)):
outfile = title = getattr(os, "fspath", lambda obj: obj)(outfile)
title = title.encode("latin-1", "replace").decode()
passed_in_file_object = False
elif is_writable_file_like(outfile):
title = None
Expand Down Expand Up @@ -1071,7 +1072,7 @@ def print_figure_impl(fh):
else:
print("%!PS-Adobe-3.0", file=fh)
if title:
print("%%Title: "+title, file=fh)
print("%%Title: " + title, file=fh)
print("%%Creator: " + creator_str, file=fh)
# get source date from SOURCE_DATE_EPOCH, if set
# See https://reproducible-builds.org/specs/source-date-epoch/
Expand All @@ -1081,7 +1082,7 @@ def print_figure_impl(fh):
int(source_date_epoch)).strftime("%a %b %d %H:%M:%S %Y")
else:
source_date = time.ctime()
print("%%CreationDate: "+source_date, file=fh)
print("%%CreationDate: " + source_date, file=fh)
print("%%Orientation: " + orientation, file=fh)
if not isEPSF:
print("%%DocumentPaperSizes: "+papertype, file=fh)
Expand Down

0 comments on commit 3ba79fb

Please sign in to comment.