summaryrefslogtreecommitdiff
path: root/fonts/utilities/mathinst/mathinst
blob: b152615ccf5373303c9666218cb9fda9f27d0679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/usr/local/bin/perl
## The main module for MathInst.

### ====================================================================
###  @Perl-file{
###     author          = "Alan Hoenig",
###     version         = "0.800", 
###     date            = "7 January 1998", 
###     filename        = "mathinst",
###     address         = "Department of Mathematics,
###                        John Jay College,
###                        445 West 59 Street,
###                        New York, NY 10019, USA",
###     email           = "ajhjj@cunyvm.cuny.edu",
###     codetable       = "ISO/ASCII",
###     keywords        = "AFM, virtual fonts, fonts, PostScript, TeX",
###     supported       = "yes",
###     abstract        = "This is the Perl script for the mathinst 
###                        virtual math font installation utility.
###			   It installs raw math fonts (MathTime, Lucida,
###			   Euler, Mathematica) with text fonts for a
###			   complete math typesetting style.
###                        See accompanying file mathinst.tex for 
###                        additional details.",
###     package         = "mathinst",
###     dependencies    = "",
###  }
### ====================================================================

############################################################
##
## The main routine.
##
############################################################

  $prelim_info =<<"Endprelim_info";

This is MathInst, a utility for creating math fonts for use by TeX and LaTeX.
To run it you need to supply 2 arguments at the command line:
  1. the name of the collection of raw math fonts you're using; and
  2. the name of the family of text fonts you'll be using with the math fonts.
Currently, the math font names can be either `mt' (MathTime), `eu' (Euler),
or `lu' (Lucida New Math).  The text family name should be the Berry 
fontname---something like `pad' for Adobe Garamond, `pac' for Adobe Caslon,
and so on.  Thus, I would type something like
  perl ../mathinst mt pad
to create math fonts combining MathTime plus Adobe Garamond.

MathInst itself is written in Perl5, so you'll need to place the
Perl executable somewhere on your system's search path.  MathInst depends
on `fontinst' and `pdcfsel'; both packages are freely available from the 
CTAN archive of TeX software.  

The current versions of the MathInst scripts are available from the 
  fonts/utilities/mathinst
area of the CTAN archive.  Read the file `mathinst.tex' for additional 
information.  (The info on this screen is stored in the file `mathinst.how'.)

Endprelim_info

sub die_from_ignorance{
    open(TODO, ">mathinst.how");
    print $prelim_info;
    print TODO $prelim_info;
    close TODO;
    die;
}

## Let's verify that we were passed the proper number of args. 
die_from_ignorance unless $#ARGV == 1;

$mathfam_ = $ARGV[0];		# $mathfam_="mt", "eu", etc.
$fontfam_ = $ARGV[1];		# mbv, pac, pad, etc.

require("../${mathfam_}.par"); # system dependent; get module params
require("..${sep}mathinst.lib");

sub DoIt{
    ## Here are some constants we'll be using throughout.
    ## $fontfam_ is something like "mbv" (eg, Monotype
    ## Baskerville).  $mathpkg_ is something like "zmtmbv", a
    ## math package combining MathTime fonts + Monotype
    ## Baskerville.  $mathid will be "m", "l", or "e" for
    ## mathTime, Lucida, or Euler.  $shortmathpkg_ will be
    ## something like "mtmbv", and should be used in file
    ## naming contexts whenever the appearance of $mathpkg_
    ## will make the file name exceed 8 characters.
    local($s, $typefam) = split(//, $fontfam_, 2);
    # Here, $s = m or p, etc and $typefam = 'bv', 'ac', and so on
    $mathpkg_ = "z$mathfam_$fontfam_";
    $shortmathpkg_ = "$mathfam_$fontfam_";
    $mathid   = $mathid_{$mathfam_};
    &openlog;
    ## Now begins an important verification process.  We need to 
    ## verify that everything the user says is there really is there.  
    if (&isTDS) { # check TDS directories first
        &dwlog("This is a TDS installation.");
        $sup_ = &getTDSsupplier;
	&dwlog("I am using <<$sup_>> as the supplier for $fontfam_.");
        $typ_ = &getTDStypeface;
	&dwlog("I am using <<$typ_>> as type directory for $fontfam_.");
    ## Need to redefine $afm_, $tfm_, $vf_ to correspond to these
    ## text fonts ONLY.  They will not apply to special fonts (math, 
    ## fraktur, etc.).
	$temp = "${mathfam_}_fonts";
        ($mathsup_, $mathtyp_) = ($$temp[0], $$temp[1]);
	$psfonts_ = "$texmf_${sep}fonts${sep}type1${sep}$sup_${sep}$typ_";
	$afm_ = "$texmf_${sep}fonts${sep}afm${sep}$sup_${sep}$typ_";
	$tfm_ = "$texmf_${sep}fonts${sep}tfm${sep}$sup_${sep}$typ_";
	$vf_ = "$texmf_${sep}fonts${sep}vf${sep}$sup_${sep}$typ_";
	$mathpsfonts_ = 
	    "$texmf_${sep}fonts${sep}type1${sep}$mathsup_${sep}$mathtyp_";
	$mathafm_ = 
	    "$texmf_${sep}fonts${sep}afm${sep}$mathsup_${sep}$mathtyp_";
	$mathtfm_ = 
	    "$texmf_${sep}fonts${sep}tfm${sep}$mathsup_${sep}$mathtyp_";
	$mathvf_ = "$texmf_${sep}fonts${sep}vf${sep}$mathsup_${sep}$mathtyp_";
	$inputs_ = "$texmf_${sep}tex${sep}latex${sep}$installer_";
	$map_ = "$texmf_${sep}dvips${sep}base";
    } else { # non-TDS systems...
	$mathpsfonts_ = $psfonts_;
	$mathafm_  =$afm_;
	$mathtfm_ = $tfm_;
	$mathvf_ = $vf_;       
	&dwlog("This is a traditional installation.");
    }
    &verifydirs(
        $psfonts_,      
        $afm_,          
        $vf_,           
        $tfm_, 
	$mathpsfonts_,    
        $mathafm_,          
        $mathvf_,           
        $mathtfm_,      
        $map_,          
        $inputs_, 
		); 
    &verifydirs( 
	"$texmf_${sep}fonts${sep}vf${sep}$installer_${sep}$mathpkg_", 
	"$texmf_${sep}fonts${sep}tfm${sep}$installer_${sep}$mathpkg_",
        "$texmf_${sep}tex${sep}plain${sep}mathinst",
        "$texmf_${sep}tex${sep}latex${sep}mathinst",  
		) if &isTDS;
  ## Now to verify encoding.
    $lc_encoding_ =lc $encoding_;
    if (($lc_encoding_ ne "ot1") and ($lc_encoding_ ne "t1")) {
    	  &dwlog("Warning: I don't recognize the encoding $encoding_.");
    	  &dwlog("(You may want to fix and re-run mathinst.)");
    } else {
    	  &dwlog("I will be using the encoding `$encoding_' in this run.");
    }
    ## We need a math encoding for use by the math roman font.  It can only
    ## be `OT1' or `ot1'.
    $mathencoding_ = "ot1";
    $mathencoding_ = "OT1" if $encoding_ =~ /T/;
    $manname = "${mathfam_}_manifest";
    *thismanifest = *$manname; # for later use...
    &checkinstallation(@mathinstmanifest); # check everybody's files
    &checkinstallation(@thismanifest); # check math stuff...
    ## Regardless of how the text fonts have been installed, we will
    ## use the OT1, OMX, OMS, and OML encodings for the math fonts.
    ## We'll begin by getting characteristics of installed font.
    undef $enc; undef $rreg; # initialize
    TEST_ENC: foreach $testenc ("9t", "9o", "9d", "9e", "7t", "8t") {
	$enc=$testenc;
	foreach $testroman ("r", "k", "m", "l") {
	    $rreg=$testroman;
	    last TEST_ENC if -e "$vf_$sep${fontfam_}$rreg$enc.vf";
	}
    }
    $enc = "99" unless $enc;
    &Out("I HAVEN'T FOUND THE MATCHING ROMAN FONTS! Please help me.")
	if $enc eq "99";
    $osf = $true if $enc =~ /d|o/;# Old Style Figures exist
    $osf = $true if $enc =~ /9/; # expert fonts exist
    $latexfontfam_ = "nul"; $latex = $true; undef $foundfile;
    $fdfile =  "$inputs_$sep$encoding_${fontfam_}.fd";
    $fdxfile = "$inputs_$sep$encoding_${fontfam_}x.fd";
    $fd9file = "$inputs_$sep$encoding_${fontfam_}9.fd";
    if (&isfile($fdxfile)) {	# check for expert fonts first
	$latex = $true;		
	$latexfontfam_ = "${fontfam_}x";
        $foundfile = $fdxfile;
	$textenc = "9"; $famvariant = "x";
    } elsif (&isfile($fdfile)) {# then for non-expert fonts
	$latex = $true;		
	$latexfontfam_ = "${fontfam_}"; 
        $foundfile = $fdfile;
	$famvariant = "";
    } elsif (&isfile($fd9file)) {	# finally for oldstyle fonts
	$latex = $true;
	$latexfontfam_ = "${fontfam_}9";
        $foundfile = $fd9file;
	$textenc = "9"; $famvariant = "9";
    }
    if ($latexfontfam_ eq "nul") {
      &dwlog("I failed to find font descriptors like\n  >>$fdfile.");
      &dwlog("I assume you're not using NFSS & LaTeX so I won't either.");
      $latex = $false;
  } else {
      &dwlog("I found font descriptor file\n  >>$foundfile;");
      &dwlog("the LaTeX font family for this run is $latexfontfam_.");
  }
  &verifytextfonts; # are text fonts present for $fontfam_?
  &verifymathfonts; # are math fonts present?
  ## Now to verify various specialty fonts. 
  &dwlog("\nNow we verify various specialty fonts.");
  &verifyspecialfonts;
  ## Whew, we've finished all the verification/calculation, and now it's
  ## time to start creating the file makemath.tex.
  $namedroutine = "make_${mathfam_}_math";
  open(MAKEMATH, ">makemath.tex");
  &$namedroutine;
  close(MAKEMATH);
  ## The file `makemath.tex' is certainly the most important, but not 
  ## the only file we need to create.  First off among these others:
  ## we need the file makevf.bat to transform .vpl files to .vf files.
  ## Of course, Unix can do this within the foreach statement, but other
  ## operating systems (such as MS-DOS), are less clever.
  open(GETVF, ">makevf.bat");
  &makevf;
  close(GETVF);
  ## We need a pair of files copies.  From the template files
  ##   rhax.mtx and ihax.mtx
  ## we create files $fontfam_rhax.mtx and $fontfam_ihax.mtx 
  ## unless they already exist, for it would be a deadly shame to 
  ## over-write files for which users had already done work.
  ## (Eg: if $fontfam_ is `mbv', then we generate mbvrhax.mtx, etc.)
  $target = "${fontfam_}rhax.mtx";
  &safecopy("../rhax.mtx", "$target");
  $target = "${fontfam_}ihax.mtx";
  &safecopy("../${mathfam_}_ihax.mtx", "$target");
  $target = "${fontfam_}iskew.mtx";
  &safecopy("../${mathfam_}_iskew.mtx", "$target");
  ## At this point everything is ready to create the math virtual fonts.
  ## We still need to create the style files and the test files.
  ## The 2 style files we create will essentially create a complete font
  ## environment for typesetting.  In addition to making the Roman and
  ## accompanying math fonts the defaults, it will also enable the setup of
  ## sans serif (for both math and text), and blackboard bold and fraktur
  ## fonts (for math), provided these fonts have been specified.
  local($myans) = "y"; # ensures font tables are printed in test files
  ## The Latex style is only for LaTeX users ...
  $mathSF_ = "${mathfam_}SF_";
  &makelatexstyle($mathfam_, $$mathSF_) if $latex;
  ## ... but everybody gets the plain style.  Since the plain style is 
  ## much more concise than the LaTeX equivalent, it seemed to make sense
  ## to use a template file plainsty.tpl to facilitate the creation.
  &makeplainstyle($mathfam_, $$mathSF_);
  ## Finally, we prepare the test files, which show off our fancy font
  ## work, and show how to use the style files.
  &makeLaTeXtestfile($mathfam_) if $latex;
  &makeplaintestfile($mathfam_);
  &makecleanupfile;
  open (TODO, ">finish.mth");
  print $todo_next; print TODO $todo_next;
  close TODO;
}

  $todo_next =<<"End_todo_next";


MathInst: finishing up
======================

The hard work is done.  Please review the messages that appeared onscreen which
were also stored in the file `z$mathfam_$fontfam_.mlg'.  Unless some cries for help were
uttered, here's what to do now:

  1. Execute `mkdirs.bat' to create any missing directories;
  2. Execute `makepl.bat' to create some needed property list files;
  3. Run the plain TeX file `makemath.tex' through TeX (this step may take
     a short while...);
  4. Execute `makevf.bat' to create the actual virtual fonts TeX will use;
  5. Test the files, by typesetting either of `testmath.tex' (LaTeX + NFSS) 
     or `testmatp.tex' (plain TeX).  Make any adjustments as outlined in 
     `mathinst.tex';
  6. When you are satisfied with your fonts, execute `putfonts.bat' to place
     all fonts files, style files, and so on where they belong.  (Any files 
     remaining in your work directory thereafter may safely be deleted.)
  7. TDS Only: Update the TDS data base by issuing a `texhash' or `configure'
     command, or whatever is appropriate for your system.

(This information can be found in the file `finish.mth'.)

End_todo_next
&DoIt;				# just do it...