#!/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...