.Key mode/a,mag/a,name/a,dpi/a,dest/a
;
; Script file for automatic TeX font generation with Metafont (Verbose version)
;
; Usage: callmf <mode> <magnification> <name> <dpi> <destination>
;
;    mode          - output device for which the new font will be used
;                    This must be the name of a Metafont mode definition
;    magnification - magnification factor
;    name          - font name
;    dpi           - dpi number
;    destination   - destination directory for the resulting pk file
;
; Example: callmf neclow magstep(1) cmr10 216 tex:pk/216
;
;  This generates a pk file to be used for the Nec P6 printer in low resolution
;  mode (180 dpi). The font is cmr10 with a magnification of 1.2. The resulting
;  pk file will be stored under tex:pk/216/cmr10.216pk
;
; Note 1: Most of the above parameters will be supplied by the calling program,
;         e.g. the previewer or the printer driver.
;
; Note 2: Some paths used in this script need to be changed to fit in your
;         local environment.

; If the destination directory doesn't already exists, create it.
IF NOT EXISTS <dest>
 MakeDir <dest>
 Echo "Directory <dest> created!"
EndIF

; Go to the working directory
cd ram:

; Start Metafont
mf:bin/virmf "\mode:=<mode>; mag:=<mag>; input <name> ."

; Convert the resulting gf file into a pk file
mf:bin/gftopk -v <name>.<dpi>gf <dest>/<name>.<dpi>pk

; If the tfm file for this font doesn't already exists, copy it to TeX:fonts
IF NOT EXISTS TeX:fonts/<name>.tfm
 Copy <name>.tfm TeX:fonts
 Echo "TFM file for <name> font installed!"
EndIF

; Delete temporary files
Delete <name>.tfm <name>.<dpi>gf <name>.log
