aboutsummaryrefslogtreecommitdiffstats
path: root/doc/genps.pl
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-10-04 13:09:30 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-10-04 13:09:30 -0700
commit18e87ce7bd64de013e55813a837b38d46252f30d (patch)
treed38e5767f8fd0bccf6116c5177d63a18df4e7322 /doc/genps.pl
parentbef71a86b949009f8fd2d194b1d9f1ce1595ffb4 (diff)
downloadnasm-18e87ce7bd64de013e55813a837b38d46252f30d.tar.gz
nasm-18e87ce7bd64de013e55813a837b38d46252f30d.tar.xz
nasm-18e87ce7bd64de013e55813a837b38d46252f30d.zip
doc: we really need a Fontmap file
It turns out that we need a Fontmap file after all, *and* -I. to make gs find it. Inconsistent results came from stray Fontmap files from previous debug attempts. Now generate both fontpath and Fontmap, and hopefully at least one of them should work. We might, in fact, need both, one for gs to know where the files are and one for gs to know it is allowed to read them. The core problem seems to be that gs will find OTF fonts by its normal discovery mechanisms, but for some reason don't seem to use them unless it can find them in a Fontmap, Font directory, of CIDFont directory. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'doc/genps.pl')
-rwxr-xr-xdoc/genps.pl55
1 files changed, 35 insertions, 20 deletions
diff --git a/doc/genps.pl b/doc/genps.pl
index 8d7a76d9..7cbe23c0 100755
--- a/doc/genps.pl
+++ b/doc/genps.pl
@@ -99,7 +99,7 @@ $epsdir = File::Spec->curdir();
#
# Parse the command line
#
-undef $input, $fontpath;
+undef $input, $fontpath, $fontmap;
while ( $arg = shift(@ARGV) ) {
if ( $arg =~ /^\-(|no\-)(.*)$/ ) {
$parm = $2;
@@ -121,6 +121,8 @@ while ( $arg = shift(@ARGV) ) {
$headps = shift(@ARGV);
} elsif ( $true && $parm eq 'fontpath' ) {
$fontpath = shift(@ARGV);
+ } elsif ( $true && $parm eq 'fontmap' ) {
+ $fontmap = shift(@ARGV);
} else {
die "$0: Unknown option: $arg\n";
}
@@ -129,6 +131,25 @@ while ( $arg = shift(@ARGV) ) {
}
}
+# Generate a PostScript string
+sub ps_string($) {
+ my ($s) = @_;
+ my ($i,$c);
+ my ($o) = '(';
+ my ($l) = length($s);
+ for ( $i = 0 ; $i < $l ; $i++ ) {
+ $c = substr($s,$i,1);
+ if ( ord($c) < 32 || ord($c) > 126 ) {
+ $o .= sprintf("\\%03o", ord($c));
+ } elsif ( $c eq '(' || $c eq ')' || $c eq "\\" ) {
+ $o .= "\\".$c;
+ } else {
+ $o .= $c;
+ }
+ }
+ return $o.')';
+}
+
# Configure post-paragraph skips for each kind of paragraph
# (subject to modification above)
%skiparray = ('chap' => $psconf{chapskip},
@@ -188,6 +209,19 @@ if (defined($fontpath)) {
close($fp);
}
+# Create a Fontmap. At least some versions of Ghostscript
+# don't seem to get it right any other way.
+if (defined($fontmap)) {
+ open(my $fm, '>', $fontmap) or die "$0: $fontmap: $!\n";
+ foreach my $fname (sort keys(%ps_all_fonts)) {
+ my $fdata = $ps_all_fonts{$fname};
+ if (defined($fdata->{filename})) {
+ print $fm '/', $fname, ' ', ps_string($fdata->{filename}), " ;\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
@@ -1113,25 +1147,6 @@ while ( defined($line = <PSHEAD>) ) {
close(PSHEAD);
print "%%EndProlog\n";
-# Generate a PostScript string
-sub ps_string($) {
- my ($s) = @_;
- my ($i,$c);
- my ($o) = '(';
- my ($l) = length($s);
- for ( $i = 0 ; $i < $l ; $i++ ) {
- $c = substr($s,$i,1);
- if ( ord($c) < 32 || ord($c) > 126 ) {
- $o .= sprintf("\\%03o", ord($c));
- } elsif ( $c eq '(' || $c eq ')' || $c eq "\\" ) {
- $o .= "\\".$c;
- } else {
- $o .= $c;
- }
- }
- return $o.')';
-}
-
# Generate PDF bookmarks
print "%%BeginSetup\n";
foreach $b ( @bookmarks ) {