Skip to content

Commit 2cfa74d

Browse files
authored
Merge pull request #98 from aupfred/pstopdf
fixes #80 pstopdf removal on Mac, use of ghostscript in Sonoma
2 parents 58601ca + 585635c commit 2cfa74d

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)
@@ -8428,16 +8430,22 @@ def restore_settings(self):
84288430
if wx.Platform == "__WXMSW__":
84298431
gs_path = get_ghostscript_path()
84308432
settings['gs_path'] = gs_path
8431-
elif wx.Platform == '__WXGTK__':
8433+
#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.
8434+
#elif wx.Platform == '__WXGTK__':
8435+
else:
84328436
try:
84338437
gs_path = subprocess.check_output(["which", "gs"])
84348438
settings['gs_path'] = gs_path[0:-1].decode()
84358439
except:
8436-
settings['gs_path'] = ''
8440+
if wx.Platform == "__WXMAC__" and int(platform.mac_ver()[0].split('.')[0]) <= 13:
8441+
settings['gs_path'] = '/usr/bin/pstopdf'
8442+
else:
8443+
settings['gs_path'] = ''
84378444
#1.3.6.1 [SS] 2014-01-13
8438-
elif wx.Platform == "__WXMAC__":
8439-
gs_path = '/usr/bin/pstopdf'
8440-
settings['gs_path'] = gs_path
8445+
#FAU:PDF:pstopdf is not provided by Apple starting from MacOS Sonoma. So merge with Ghostscript in case ghostscript is installed
8446+
#elif wx.Platform == "__WXMAC__":
8447+
# gs_path = '/usr/bin/pstopdf'
8448+
# settings['gs_path'] = gs_path
84418449

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

0 commit comments

Comments
 (0)