aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-06-06 20:51:10 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-06-06 20:51:10 -0700
commit186f9a0514f466c36677b515622ba1c4fa96e32d (patch)
tree164f59a875f8f093f2909c5452584261ea880d68 /doc
parente678020878c79830bf59db3ad0bddebab4537409 (diff)
downloadnasm-186f9a0514f466c36677b515622ba1c4fa96e32d.tar.gz
nasm-186f9a0514f466c36677b515622ba1c4fa96e32d.tar.xz
nasm-186f9a0514f466c36677b515622ba1c4fa96e32d.zip
doc: fix yet another set of Ghostscript font problems
Seems like Ghostscript has managed to break fontconfig support again, at least in Fedora 30. Help Ghostscript along by giving it an explicit font path. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/findfont.ph2
-rwxr-xr-xdoc/genps.pl24
-rwxr-xr-xdoc/pspdf.pl21
3 files changed, 43 insertions, 4 deletions
diff --git a/doc/findfont.ph b/doc/findfont.ph
index 60047b84..341fecf7 100644
--- a/doc/findfont.ph
+++ b/doc/findfont.ph
@@ -70,6 +70,8 @@ sub add_file_to_font_hash($) {
return unless (defined($fontdata));
+ $fontdata->{filename} = $filename;
+
my $oldinfo = $font_info_hash{$fontdata->{name}};
if (!defined($oldinfo) ||
diff --git a/doc/genps.pl b/doc/genps.pl
index 4758bb9d..8d7a76d9 100755
--- a/doc/genps.pl
+++ b/doc/genps.pl
@@ -99,7 +99,7 @@ $epsdir = File::Spec->curdir();
#
# Parse the command line
#
-undef $input;
+undef $input, $fontpath;
while ( $arg = shift(@ARGV) ) {
if ( $arg =~ /^\-(|no\-)(.*)$/ ) {
$parm = $2;
@@ -119,6 +119,8 @@ while ( $arg = shift(@ARGV) ) {
$epsdir = shift(@ARGV);
} elsif ( $true && $parm eq 'headps' ) {
$headps = shift(@ARGV);
+ } elsif ( $true && $parm eq 'fontpath' ) {
+ $fontpath = shift(@ARGV);
} else {
die "$0: Unknown option: $arg\n";
}
@@ -166,6 +168,26 @@ foreach my $fset ( @AllFonts ) {
}
}
+# Create a font path. At least some versions of Ghostscript
+# don't seem to get it right any other way.
+if (defined($fontpath)) {
+ my %fontdirs = ();
+ foreach my $fname (sort keys(%ps_all_fonts)) {
+ my $fdata = $ps_all_fonts{$fname};
+ if (defined($fdata->{filename})) {
+ my($vol,$dir,$basename) =
+ File::Spec->splitpath(File::Spec->rel2abs($fdata->{filename}));
+ $dir = File::Spec->catpath($vol, $dir, '');
+ $fontdirs{$dir}++;
+ }
+ }
+ open(my $fp, '>', $fontpath) or die "$0: $fontpath: $!\n";
+ foreach $d (sort(keys(%fontdirs))) {
+ print $fp $d, "\n";
+ }
+ close($fp);
+}
+
# Custom encoding vector. This is basically the same as
# ISOLatin1Encoding (a level 2 feature, so we dont want to use it),
# but with the "naked" accents at \200-\237 moved to the \000-\037
diff --git a/doc/pspdf.pl b/doc/pspdf.pl
index ef9f2900..2bfa74f7 100755
--- a/doc/pspdf.pl
+++ b/doc/pspdf.pl
@@ -26,10 +26,10 @@ while ($ARGV[0] =~ /^-(.*)$/) {
# Ghostscript executable name. "gs" on Unix-based systems.
my $gs = 'gs';
-my ($in, $out) = @ARGV;
+my ($in, $out, $fontpath) = @ARGV;
if (!defined($out)) {
- die "Usage: $0 [-nocompress] infile ou{ tfile\n";
+ die "Usage: $0 [-nocompress] infile outfile [fontpath]\n";
}
# If Win32, help GhostScript out with some defaults
@@ -96,14 +96,29 @@ exit 0 if ( !$r && -f $out );
# 2. ps2pdf (from Ghostscript)
#
# GhostScript uses # rather than = to separate options and values on Windows,
-# it seems. Call gs directly rather than ps2pdf, because -dSAFER
+# it seems. Similary it uses ; in path lists rather than :.
+# Call gs directly rather than ps2pdf, because -dSAFER
# breaks font discovery on some systems, apparently.
win32_gs_help();
my $o = $win32_ok ? '#' : '=';
+my $p = $win32_ok ? ';' : ':';
+my $fpopt;
+if (defined($fontpath)) {
+ my @fplist = ();
+ open(my $fp, '<', $fontpath) or die "$0: $fontpath: $!\n";
+ while (my $fpe = <$fp>) {
+ chomp $fpe;
+ push(@fplist, $fpe);
+ }
+ close($fp);
+ $fpopt = "-sFONTPATH${o}" . join($p, @fplist);
+}
+
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",
+ $fpopt,
"-dCompressPages${o}" . ($compress ? 'true' : 'false'),
"-dUseFlateCompression${o}true",
"-c", ".setpdfwrite", "-f", $in);