Skip to content

Commit 585635c

Browse files
committed
fixes #80 pstopdf removal on Mac and use of ghostscript in MacOS Sonoma
1 parent 509a07d commit 585635c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

easy_abc.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,10 @@ def AbcToPDF(settings, abc_code, header, cache_dir, extra_params='', abcm2ps_pat
934934
# convert ps to pdf
935935
# p09 we already checked for gs_path in restore_settings() 2014-10-14
936936
cmd2 = [gs_path, '-sDEVICE=pdfwrite', '-sOutputFile=%s' % pdf_file, '-dBATCH', '-dNOPAUSE', ps_file]
937-
# [SS] 2015-04-08
938-
if wx.Platform == "__WXMAC__":
937+
#FAU:PDF:Manage the case where one put ps2pdf from ghostscript instead of gs directly
938+
if 'ps2pdf' in gs_path:
939+
cmd2 = [gs_path, ps_file, pdf_file]
940+
elif wx.Platform == "__WXMAC__" and int(platform.mac_ver()[0].split('.')[0]) <= 13 and gs_path == '/usr/bin/pstopdf':
939941
cmd2 = [gs_path, ps_file, '-o', pdf_file]
940942
if os.path.exists(pdf_file):
941943
os.remove(pdf_file)
@@ -8367,16 +8369,22 @@ def restore_settings(self):
83678369
if wx.Platform == "__WXMSW__":
83688370
gs_path = get_ghostscript_path()
83698371
settings['gs_path'] = gs_path
8370-
elif wx.Platform == '__WXGTK__':
8372+
#FAU:PDF:pstopdf is not provided by Apple starting from MacOS Sonoma. So in any case look for ghostscript and use /usr/bin/pstopdf only if Mac OS version earlier than Sonoma.
8373+
#elif wx.Platform == '__WXGTK__':
8374+
else:
83718375
try:
83728376
gs_path = subprocess.check_output(["which", "gs"])
83738377
settings['gs_path'] = gs_path[0:-1].decode()
83748378
except:
8375-
settings['gs_path'] = ''
8379+
if wx.Platform == "__WXMAC__" and int(platform.mac_ver()[0].split('.')[0]) <= 13:
8380+
settings['gs_path'] = '/usr/bin/pstopdf'
8381+
else:
8382+
settings['gs_path'] = ''
83768383
#1.3.6.1 [SS] 2014-01-13
8377-
elif wx.Platform == "__WXMAC__":
8378-
gs_path = '/usr/bin/pstopdf'
8379-
settings['gs_path'] = gs_path
8384+
#FAU:PDF:pstopdf is not provided by Apple starting from MacOS Sonoma. So merge with Ghostscript in case ghostscript is installed
8385+
#elif wx.Platform == "__WXMAC__":
8386+
# gs_path = '/usr/bin/pstopdf'
8387+
# settings['gs_path'] = gs_path
83808388

83818389
# 1.3.6.1 [SS] 2015-01-12 2015-01-22
83828390
gs_path = settings['gs_path'] #eliminate trailing \n

0 commit comments

Comments
 (0)