home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
useful
/
dist
/
text
/
tex
/
pastex
/
mf
/
rexx
/
maketexfont.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-09-07
|
8KB
|
280 lines
/*RX
MakeTeXFont 0.91 */
/* Send new features and bug reports to
Martin Bokaemper
Reuthstr. 12
W-8521 Poxdorf
Germany
Email: mnbokaem@cip.e-technik.uni-erlangen.de (Internet)
mab@ame.zer (Zerberus)
History:
0.80: My 'works-fine-for-me' version modified by Georg Hessmann 13.4.91
+ Variables for all directories and filenames
+ ^C and ^D detection
+ support for a 'modefile' containing site-specific information
+ searches for standard magsteps
+ support for different format-files
0.81: + take new Parameters 'drivertype' and 'pkfilename'
Georg Hessmann 17.4.91
0.82: + History
+ a lot of small improvements and bugfixes
+ looking for PK-directory for each device
+ checking if the font already exists
Martin Bokaemper 21.4.91
0.84: + add new parameter 'pkdir' (new since driver version V1.10)
Georg Hessmann 9.6.91
0.85: + fixed a pkdir/pkfilename mixing bug
+ slight modifications, now works with old driver versions
+ changed exit codes
+ always calls uses plain.base (absolutely no gain in using cmbase)
J\"org H\"ohle 24.6.91, 1-Aug-91
0.86: + fixed makedir(pkname) bug
J\"org H\"ohle 6-Aug-91
0.90: + add makedir(pkdir)
+ delete localfont entry in 'modes' file
Georg Hessmann 28-Aug-91
0.91: + change scrollmode arg
+ delete cmbase format
+ comment out ERROR/FAILURE
Georg Hessmann 4-Sep-93
*/
/* TRACE RESULTS */
/* files / directories */
logdir = "MF:log" /* directory of the logfiles */
/* without trailing slash! */
logname = logdir"/MakeTeXFont.log" /* logfile */
modefilename = "MF:config/modes" /* description of the modes */
textfm = "TeX:fonts/" /* TeX tfm-files directory */
/*pkdir "TeX:pk/" * Where pk fonts are copied to */
/* programs: */
virmf = "MF:bin/virmf"
gftopk = "MF:bin/gftopk"
format = "plain" /* base file for all fonts */
/* SIGNAL ON ERROR */
/* SIGNAL ON FAILURE */
SIGNAL ON BREAK_C
SIGNAL ON BREAK_D
/* TRACE RESULTS */
if ~show('Libraries', 'rexxsupport.library') then do
if ~addlib('rexxsupport.library', 0, -30) then do
say "no RexxSupport ... no Metafont"
exit 20
end
end
dummy = time("Reset");
IF ~exists(logdir) THEN DO
CALL makedir(logdir)
say "logfile-directory ("logdir"/) did not exist. It was created."
END
IF ~exists(logname) THEN DO
ADDRESS COMMAND 'echo >'||logname
say "logfile did not exist. It was created."
END
/**** arguments *****/
parse arg fntname dpi hbasedpi vbasedpi drivertype pkfilename pkdir .
IF pkdir == "" THEN pkdir = "TeX:pk/" /* default for driver types < V1.10 */
say "Making font with name = "fntname" dpi = "dpi" and base x = "hbasedpi" y = "vbasedpi
mag = dpi/hbasedpi /* what magstep should the font have? */
magmult.0 = 13 /* number of saved magsteps */
magmult.num.1 = 1.000000 /* magstep(0) */
magmult.str.1 = "0"
magmult.num.2 = 1.095445 /* magstep(0.5) */
magmult.str.2 = "0.5"
magmult.num.3 = 1.200000 /* magstep(1) */
magmult.str.3 = "1"
magmult.num.4 = 1.314534 /* magstep(1.5) */
magmult.str.4 = "1.5"
magmult.num.5 = 1.440000 /* magstep(2) */
magmult.str.5 = "2"
magmult.num.6 = 1.577441 /* magstep(2.5) */
magmult.str.6 = "2.5"
magmult.num.7 = 1.728000 /* magstep(3) */
magmult.str.7 = "3"
magmult.num.8 = 2.073600 /* magstep(4) */
magmult.str.8 = "4"
magmult.num.9 = 2.488320 /* magstep(5) */
magmult.str.9 = "5"
magmult.num.10 = 2.985984 /* magstep(6) */
magmult.str.10 = "6"
magmult.num.11 = 3.583180 /* magstep(7) */
magmult.str.11 = "7"
magmult.num.12 = 4.299817 /* magstep(8) */
magmult.str.12 = "8"
magmult.num.13 = 5.159780 /* magstep(9) */
magmult.str.13 = "9"
magmult.str.default = "???"
magstr = magmult.str.default
eps = 0.005 /* erlaubte Abweichung */
DO i=1 to magmult.0
IF abs(magmult.num.i - mag) < eps THEN DO
mag = magmult.num.i
magstr = magmult.str.i
LEAVE i
END
END
/* modes ... search the correct mode in the file MF:config/modes */
IF ~open('modefile', modefilename, 'read') THEN DO
call log("Can't find file "modefilename"!");
exit 10
END
DO UNTIL (xres == hbasedpi & yres == vbasedpi) | eof('modefile')
PARSE VALUE translate(readln('modefile'), '', '2009'X) WITH mode xres yres .
/**
line = readln('modefile')
line = strip(translate(line, '', '2009'X)) / * a space and a tab * /
mode = word(line,1)
xres = word(line,2)
yres = word(line,3)
/* pkdir = word(line,4) */
**/
END
IF ~close('modefile') THEN call log("Can't close mode-file!")
IF xres ~= hbasedpi | yres ~= vbasedpi THEN DO
call log("Can't find matching mode! Make an update in your "modefilename" file.")
EXIT 5
END;
/* Produce the complete name of the file */
IF pkfilename="" THEN DO
pkname = pkdir||dpi'/'fntname'.'dpi'pk'
END; ELSE DO
pkname = pkdir||pkfilename
END
/* Looks if the font already is there */
IF exists(pkname) THEN DO
say "The font "pkname" already exists!"
say "check your driver's configuration!"
call log(pkname" already exists")
EXIT 0
END;
/* Metafont options */
IF magstr ~= magmult.str.default THEN
options = "\scrollmode; \mode:="mode"; mag:=magstep("magstr"); input "fntname""
ELSE
options = "\scrollmode; \mode:="mode"; \mag:="mag"; \input "fntname""
say "MF commands: '"options"'"
dummy = pragma("directory","MF:");
ADDRESS COMMAND
/* first: create all needet directories.... */
/* Don't include last '/' in pkdir, makedir doesn't like it */
pkdir2 = LEFT(pkdir, LASTPOS("/",pkdir)-1)
IF ~exists(pkdir2) THEN DO
IF ~makedir(pkdir2) THEN DO
call log("MakeDir "pkdir2" failed");
EXIT 10
END
END
/* a '/' is required to exist in pkname. */
/* Don't include last '/' in fulldir, makedir doesn't like it */
fulldir = LEFT(pkname, LASTPOS("/",pkname)-1)
IF ~exists(fulldir) THEN DO
IF ~makedir(fulldir) THEN DO
call log("MakeDir "fulldir" failed");
EXIT 10
END
END
/* second: create gf-file */
virmf '&'format' "'options'"'
/* copy/delete instead rename to overwrite existing logfile (eg. from a
failed call of MakeTeXfont). Replace by 'move' if you have ARP:
i.e. add a line here ``copy = "move" or "mv"'' */
CALL delete(logdir'/'fntname'.'dpi'log')
CALL rename(fntname'.log', logdir'/'fntname'.'dpi'log')
/* tfm-file ?? */
IF exists(textfm) & ~exists(textfm||fntname'.tfm') THEN DO
copy fntname'.tfm' textfm
protect textfm||fntname'.tfm' SUB ew
END
CALL delete(fntname'.tfm')
/* third: create pk-file */
gftopk fntname'.'dpi'gf' pkname
IF 0 = RC THEN DO /* never called because of 'signal on failure' ? */
/* don't delete .gf file on failure */
protect pkname SUB ew
filenote pkname '"mode='mode',magstep='magstr'"'
CALL delete(fntname'.'dpi'gf')
END
elapsed = time("Elapsed");
call log("in "elapsed%3600":"Right(elapsed%60//60,2,'0')":"Right(elapsed%1//60,2,'0'))
EXIT 0
/**** log - function ****/
log: PROCEDURE EXPOSE logname fntname mode hbasedpi vbasedpi dpi magstr
PARSE ARG msg
message = date()" "time()": "fntname" for "mode"("hbasedpi","vbasedpi") with "dpi" dpi (mag="magstr") "msg
say message
IF ~open(logfile, logname, 'Append') THEN DO
say "Can't open logfile!"
RETURN
END
dummy = writeln(logfile,message);
IF ~close(logfile) THEN say "Can't close logfile!"
RETURN
/**** signal - functions ****/
error:
failure: call log "errorlevel "rc" in line "sigl": "sourceline(sigl)
EXIT 10
BREAK_C:
BREAK_D:
call log "execution aborted!"
IF exists(fntname'.'dpi'gf') THEN dummy = delete(fntname'.'dpi'gf')
IF exists(fntname'.log') THEN dummy = delete(fntname'.log')
EXIT 5