2
:: This is dvidrv.btm, a batch file for 4DOS/4OS2 written by
3
:: Werner Lemberg <wl@gnu.org> partially based on the
4
:: dvidrv.btm file of the 4allTeX package written by Phons Bloemen.
6
:: It is a replacement for dvidrv.exe of the emTeX package.
8
:: Additional features: support of ps2pk
10
:: support of hbf2gf for HBFs (Hanzi bitmap fonts)
12
:: Only quadratic printer modes are supported for ttf2pk!
14
:: All needed binaries will be searched in the path.
18
echo Usage: %0 dvi-driver dvi-file [parameters]
23
:: we set a default value only if the corresponding environment variable
24
:: is empty. The `=' must follow the variable name immediately.
25
alias set_def `iff "%[%@word["=",0,%1]]" eq "" then %+ set %& %+ endiff`
27
:: =========================================
28
:: ======== User defined variables. ========
29
:: =========================================
31
:: Can be overridden in the environment (except %ps2pk, %ttf2pk, %hbf2gf,
32
:: %pre_dpi, and %post_dpi).
34
:: Set these values to `no' for the programs you don't want to use.
39
:: where the PK files will be installed created by ps2pk, ttf2pk, and
41
:: dvidrv.btm adds `\modeless\XXXdpi' to this string (see below for the
43
set_def pkdir=%emtexdir\pixel\tmp\pk
45
:: where the TrueType fonts reside. Supports trailing `!' and `!!'.
46
set_def ttfonts=%emtexdir\fonts\truetype
47
:: where auxiliary files of ttf2pk are located. Supports trailing `!'
49
set_def ttfcfg=%emtexdir\ttf2pk
51
:: where the HBF files reside. Supports trailing `!' and `!!'.
52
set_def hbfonts=%emtexdir\fonts\hbf
53
:: where the hbf2gf config files are. Supports trailing `!' and `!!'.
54
set_def hbfcfg=%emtexdir\hbf2gf
56
:: the dpi-subdirectory has various forms; the most common are XXXdpi and
57
:: dpiXXX, e.g. 300dpi and dpi300. Here we define two variables which
58
:: control this behaviour.
59
:: [dpiXXX is used for TDS compatible TeX trees.]
63
:: ================================================
64
:: ======== End of user defined variables. ========
65
:: ================================================
67
:: the base name for log files etc.
68
set basename=%@name[%1]
71
iff "%basename" ne "dvips" then
75
:: we delete dvips.mfj if it exists.
78
:: now we run dvips with all supplied parameters.
81
:: do we have to generate fonts?
82
iff exist dvips.mfj then
91
:: here we call the dvi driver with all supplied parameters.
94
:: do we have to generate fonts?
107
iff "%basename" ne "dvips" then
111
:: we now call dvips a second time
114
:: since no fonts will be generated in the second run we remove dvips.mfj
121
:: we call the dvi driver a second time (without font generation).
124
del %basename.mfj >& nul
129
:: this is the main subroutine which calls mfjob and then parses the mfjob
130
:: file for fonts which can be handled by ps2pk, ttf2pk, or hbf2gf.
132
:: this alias prints a message on the screen and writes it into the logfile.
133
alias echolog=`echo %& | tee /a %basename.mlg`
135
echo ======== DVIDRV.BTM logfile ======== > %basename.mlg
136
echo Commandline: dvidrv.btm %& >> %basename.mlg
137
echo `` >> %basename.mlg
138
echo basename=%basename >> %basename.mlg
139
echo emtexdir=%emtexdir >> %basename.mlg
140
echo dvidrvfonts=%dvidrvfonts >> %basename.mlg
141
echo mfinput=%mfinput >> %basename.mlg
142
echo mfjobopt=%mfjobopt >> %basename.mlg
143
echo textfm=%textfm >> %basename.mlg
144
echo psfonts=%psfonts >> %basename.mlg
145
echo ttfonts=%ttfonts >> %basename.mlg
146
echo ttfcfg=%ttfcfg >> %basename.mlg
147
echo hbfonts=%hbfonts >> %basename.mlg
148
echo hbfcfg=%hbfcfg >> %basename.mlg
149
echo `` >> %basename.mlg
151
iff "%@search[mfjob]" eq "" then
152
echolog MFJOB not found in the path.
153
echolog Can't generate PK fonts from METAFONT automatically.
158
:: now we call mfjob.
159
echolog mfjob %mfjobopt -g%basename.mfl %basename.mfj
160
mfjob %mfjobopt -g%basename.mfl %basename.mfj
163
echolog Something went wrong while running METAFONT.
164
echolog Look into the log files...
168
:: after running mfjob we scan the mfjob input file for fonts which can
169
:: be handled by ps2pk, ttf2pk, or hbf2gf.
171
set totlines=%@lines[%basename.mfj]
173
do while %lnnr le %totlines
175
set scratch=%@line[%basename.mfj,%lnnr]
176
set lnnr=%@inc[%lnnr]
178
:: get resolutions (METAFONT mode will be ignored).
180
:: mode=lqlores[180 180];
181
iff %@index[%scratch,mode] ge 0 then
182
set temp=%@word["[]",1,%scratch]
183
set xdpi=%@word[0,%temp]
184
set ydpi=%@word[1,%temp]
187
:: get fontname and magnification; we then compute the font resolutions
188
:: (rounded to the nearest integer---there is no necessity to adjust
189
:: these values further because of possible rounding errors since both
190
:: emTeX's dvi drivers and dvips check neighbored values too).
192
:: {font=cmr10; mag=0.5;}
193
iff %@index[%scratch,{font] ge 0 then
194
set testfont=%@word["=;",1,%scratch]
195
set temp=%@word["=;",3,%scratch]
196
:: we use highest arithmetic precision for these calculations.
197
:: Additionally we write 1/2 instead of 0.5 to avoid problems with
198
:: countries which use a comma instead of a colon as the decimal
200
set fontresx=%@int[%@eval[%xdpi*%temp+1/2=8]]
201
set fontresy=%@int[%@eval[%ydpi*%temp+1/2=8]]
202
set pksubdir=modeless\%[pre_dpi]%[fontresx]%post_dpi
206
:: check whether %testfont leads to a PS font (we call ps2pkmfj).
207
iff %success == 0 .and. "%ps2pk" eq "yes" then
211
:: check whether %testfont leads to a TrueType font.
212
iff %success == 0 .and. "%ttf2pk" eq "yes" then
216
:: check whether %testfont leads to a HBF file.
217
iff %success == 0 .and. "%hbf2gf" eq "yes" then
223
iff exist %basename.mfp then
224
echo `` >> %basename.mlg
225
echo `` >> %basename.mlg
226
echo ======== PS2PK logfile ======== >> %basename.mlg
227
echo `` >> %basename.mlg
228
type %basename.mfp >> %basename.mlg
229
echo `` >> %basename.mlg
230
del %basename.mfp >& nul
233
iff exist %basename.mfl then
234
echo `` >> %basename.mlg
235
type %basename.mfl >> %basename.mlg
236
echo `` >> %basename.mlg
237
del %basename.mfl >& nul
244
iff "%@search[ttf2pk]" eq "" then
245
echolog TTF2PK not found in the path.
246
echolog Can't generate PK fonts from TrueType fonts automatically.
251
echolog ttf2pk -q -n %testfont %fontresx
252
ttf2pk -q -n %testfont %fontresx
255
echolog Font %pkdir\%pksubdir\%testfont.pk generated.
256
mkdir /s %pkdir\%pksubdir >& nul
257
move %testfont.pk %pkdir\%pksubdir >& nul
260
echolog (%lnnr/%totlines): Font %testfont is no TrueType font.
263
echolog Error running TTF2PK for font %testfont!
270
iff "%@search[hbf2gf]" eq "" then
271
echolog HBF2GF not found in the path.
272
echolog Can't generate PK fonts from HBF files automatically.
277
echolog hbf2gf -q -p -n %testfont %fontresx %fontresy
278
hbf2gf -q -p -n %testfont %fontresx %fontresy
281
echolog Font %pkdir\%pksubdir\%testfont.pk generated.
282
mkdir /s %pkdir\%pksubdir >& nul
283
gftopk %testfont.gf %testfont.pk
284
move %testfont.pk %pkdir\%pksubdir >& nul
285
del %testfont.gf >& nul
288
echolog (%lnnr/%totlines): Font %testfont is no HBF.
291
echolog Error running HBF2GF for font %testfont!
298
iff not exist %pkdir\%pksubdir\%testfont.pk then
299
iff "%@search[ps2pkmfj]" eq "" .or. "%@search[ps2pk]" eq "" then
300
echolog PS2PKMFJ and/or PS2PK not found in the path.
301
echolog Can't generate PK fonts from PostScript fonts automatically.
306
echolog ps2pkmfj -X%fontresx -Y%fontresy %testfont %testfont.pk
307
ps2pkmfj -X%fontresx -Y%fontresy %testfont %testfont.pk | input %%pspkline
309
iff errorlevel != 1 then
310
%pspkline >> %basename.mfp
312
echolog Font %pkdir\%pksubdir\%testfont.pk generated.
313
mkdir /s %pkdir\%pksubdir >& nul
314
move %testfont.pk %pkdir\%pksubdir >& nul
317
echolog Error running PS2PK for font %testfont!
320
echolog (%lnnr/%totlines): Font %testfont is no PS font.
324
echolog Font %pkdir\%pksubdir\%testfont.pk already exists.
334
:: ==== end of dvidrv.btm ====