summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-09-24 18:02:22 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-09-24 18:02:22 -0700
commitab2c4dfff9b51b3a1a3768c5ed75f4ed870d9743 (patch)
tree5638b74cafe872e444a34595004377b292d81d5e
parent10c0f665709f99cb901786154ce39474aff32e38 (diff)
downloadnasm-ab2c4dfff9b51b3a1a3768c5ed75f4ed870d9743.tar.gz
pspdf.pl: GhostScript font integration seems broken with -dSAFER
-dSAFER seems to break font integration on some systems. Furthermore, once given -dSAFER seems to not be possible to override, so instead of calling via the ps2pdf script, call GhostScript explicitly with the equivalent options, sans -dSAFER. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rwxr-xr-xdoc/pspdf.pl30
1 files changed, 25 insertions, 5 deletions
diff --git a/doc/pspdf.pl b/doc/pspdf.pl
index 23880668..ef9f2900 100755
--- a/doc/pspdf.pl
+++ b/doc/pspdf.pl
@@ -23,6 +23,9 @@ while ($ARGV[0] =~ /^-(.*)$/) {
}
}
+# Ghostscript executable name. "gs" on Unix-based systems.
+my $gs = 'gs';
+
my ($in, $out) = @ARGV;
if (!defined($out)) {
@@ -70,6 +73,17 @@ sub win32_gs_help() {
$ENV{'PATH'} .= ';' . $gs[0]->{'/GS_LIB'};
$ENV{'GS_FONTPATH'} .= (defined($ENV{'GS_FONTPATH'}) ? ';' : '')
. $ENV{'windir'}.'\\fonts';
+
+ my $gsp = undef;
+ foreach my $p (split(/\;/, $gs[0]->{'/GS_LIB'})) {
+ foreach my $exe ('gswin64c.exe', 'gswin32c.exe', 'gs.exe') {
+ last if (defined($gsp));
+ my $e = File::Spec->catpath($p, $exe);
+ $gsp = $e if (-f $e && -x _);
+ }
+ }
+
+ $gs = $gsp if (defined($gsp));
}
# Remove output file
@@ -80,13 +94,19 @@ my $r = system('acrodist', '-n', '-q', '--nosecurity', '-o', $out, $in);
exit 0 if ( !$r && -f $out );
# 2. ps2pdf (from Ghostscript)
-# The -I clause helps Ghostscript pick up the Fontdir file written by findfont.ph
-# GhostScript uses # rather than - to separate options and values on Windows, it seems...
+#
+# GhostScript uses # rather than = to separate options and values on Windows,
+# it seems. Call gs directly rather than ps2pdf, because -dSAFER
+# breaks font discovery on some systems, apparently.
win32_gs_help();
-my $o = $win32_ok ? '#' : '-';
-my $r = system('ps2pdf', "-dOptimize${o}true", "-dEmbedAllFonts${o}true",
+my $o = $win32_ok ? '#' : '=';
+my $r = system($gs, "-dCompatibilityLevel${o}1.4", "-q",
+ "-P-", "-dNOPAUSE", "-dBATCH", "-sDEVICE${o}pdfwrite",
+ "-sstdout${o}%stderr", "-sOutputFile${o}${out}",
+ "-dOptimize${o}true", "-dEmbedAllFonts${o}true",
"-dCompressPages${o}" . ($compress ? 'true' : 'false'),
- "-dUseFlateCompression${o}true", $in, $out);
+ "-dUseFlateCompression${o}true",
+ "-c", ".setpdfwrite", "-f", $in);
exit 0 if ( !$r && -f $out );
# 3. pstopdf (BSD/MacOS X utility)