4
# --- Generate vflibcap for TeX DVI drivers
5
# (Especially, DVIware of the TeX-Guy Project)
7
# by Hirotsugu Kakugawa
10
# 12 Oct 2001 Fixed bugs. Thanks to James Hirschorn.
11
# Changed to read modex.mf to obtain device resolution.
13
# Copyright (C) 2001 Hirotsugu Kakugawa.
14
# All rights reserved.
16
# This program is free software; you can redistribute it and/or modify
17
# it under the terms of the GNU General Public License as published by
18
# the Free Software Foundation; either version 2, or (at your option)
21
# This program is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU General Public License for more details.
26
# You should have received a copy of the GNU General Public License
27
# along with this program; if not, write to the Free Software
28
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32
vflibversion="@vflib_version@"
34
datadir=${prefix}/share
41
fclass_pk_def="pk vf type1 tfm"
42
fclass_t1_def="type1 vf pk tfm"
51
use_jtex_jisx0212="no"
53
pcf_kanji_dir_extra=""
54
ekanji_kanji_dir_extra=""
55
ttf_kanji_dir_extra=""
68
echo "vflmkcaptex - make a vflibcap file of VFlib 3 for TeX DVI drivers."
69
echo "Usage: vflmkcaptex [Options] [Class-list]"
70
echo " or vflmkcaptex [Shortcut] [Options]"
71
echo "Class-list: pk, gf, vf, type1, tfm"
72
echo " A list of font class names."
73
echo " Default class list: pk vf type1 tfm (with -pk option)"
74
echo " type1 vf pk tfm (with -t1 option)"
76
echo " -p PROG Program name for kpathsea (default: ${k_prg_d})"
77
echo " -n MODE Device mode name for kpathsea (default: ${k_mode_d})"
78
echo " -r DPI Device resolution in DPI (default: ${k_dpi_d})"
79
echo " -g Enable to generate PK on-the-fly"
80
echo " -pk Search PK font before Type 1 (default)"
81
echo " -t1 Search Type1 font before PK"
82
echo " -i Generate more portable font directory list"
83
echo " --version Print version number and exit"
84
echo " --help Print help message"
85
echo "Options for Japanese Kanji characters:"
86
echo " -jtex Enable Japanese Kanji (JISX0208) font support"
87
echo " -jisx0212 Enable Japanese Hojo Kanji (JISX0212) font support"
88
echo " -jpcf Use X11 PCF fonts (default)"
89
echo " -jttf Use TrueType fonts"
90
echo " -jekanji Use eKanji fonts"
91
echo " -jpfd DIR Add PCF font directory"
92
echo " -jtfd DIR Add TrueType font directory"
93
echo " -jefd DIR Add eKanji font directory"
94
echo " -jtdb FILE File for TeX font definition with TrueType font"
95
echo " The format of a file for -jtdb option is a sequence of"
96
echo " lines, each of which contains TeX font name and TrueType"
97
echo " font file name."
99
echo " minimum same as 'pk' (PK only)"
100
echo " simple same as '-g pk tfm' (PK and TFM only)"
101
echo " standard same as '-t1 -g' (use default class list)"
102
echo " simple-ja same as '-g pk tfm -jtex -jisx0212 -jpcf'"
103
echo " standard-ja same as '-t1 -g -jtex -jisx0212 -jpcf'"
123
shortcut="-g pk tfm -jtex -jisx0212 -jpcf"
131
shortcut="-t1 -g -jtex -jisx0212 -jpcf"
133
kakugawa) # developer's preference B-)
138
-jtfd /usr/local/share/fonts/DynaFont-TypeMuseum// \
139
-jtfd /usr/local/share/fonts/DynaFont-SpecialPack1// \
140
-jtfd /usr/local/share/fonts/DynaFont-Premium30// \
141
-jtfd /usr/local/share/fonts/FontCity2// \
142
-jtfd /usr/local/share/fonts/TrueTypeWorld-ValueFont141// \
143
-jtfd /usr/local/share/fonts/TrueTypeWorld-ValueFontDX// \
144
-jtdb ../ascii-jtex/fonts.lst"
150
set -- $shortcut $args_rest
155
# Command line argument
160
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
167
datadir=${prefix}/share
173
fclass="${fclass} $1"
204
use_jtex_jisx0212="yes"
219
ttf_kanji_dir_extra="${ttf_kanji_dir_extra} $2"
223
pcf_kanji_dir_extra="${pcf_kanji_dir_extra} $2"
227
ekanji_kanji_dir_extra="${ekanji_kanji_dir_extra} $2"
231
ajt_ttf_fontdb="${ajt_ttf_fontdb} -tf $2"
234
--help|-help|-hel|-he|-h)
238
echo "${version}, VFlib ${vflibversion}"
243
echo "vflmkcaptex: Unknown option ${1}" >&2
244
echo "Use --help option for help" >&2
252
if [ "x-${fclass}" = "x-" ] ; then
253
if [ "x-${prefer_t1}" = "x-no" ]; then
254
fclass=${fclass_pk_def}
256
fclass=${fclass_t1_def}
268
if [ "${use_jtex}" = "yes" ] ; then
269
ccv="${ccv} -c jisx0201_unicode.ccv "
270
ccv="${ccv} -c jisx0208_unicode.ccv "
271
ccv="${ccv} -c jisx0208sjis_unicode.ccv "
272
ccv="${ccv} -c jisx0212_unicode.ccv "
278
kpsewhich texmf.cnf >/dev/null 2>/dev/null
279
if [ $? = "0" ] ; then
282
if [ "x-${have_kpathsea}" = "x-no" ] ; then
284
echo "No kpathsea." >&2
294
t1dir=" /usr/local/Acrobat3/Fonts \
295
/usr/Acrobat3/Fonts \
296
/opt/Acrobat3/Fonts \
297
/usr/lpp/Acrobat3/Fonts \
298
/usr/local/Acrobat4/Resource/Font \
299
/opt/Acrobat4/Resource/Font \
300
/usr/Acrobat4/Resource/Font \
301
/usr/lpp/Acrobat4/Resource/Font "
302
for f in ${t1dir}; do
303
if [ "x-${emit_portable}" = "x-yes" ] ; then
304
type1_opt="${type1_opt} -d ${f}"
306
ff=`echo ${f} | sed 's|//$||'`
307
if [ -d ${ff} ] ; then
308
type1_opt="${type1_opt} -d ${f}"
317
tmp=/tmp/vflmkcaptex$$
319
echo '0 1 LIBPATH length 1 sub {
320
LIBPATH exch get print (\n) print } for' > ${tmp}
321
d=`gs -q -DNODISPLAY ${tmp} quit.ps`
322
if [ $? -eq 0 ] ; then
324
if [ -f ${f}/Fontmap ] ; then
325
gs_fm="-gm ${f}/Fontmap"
327
if [ "x-${f}" != "x-." ] ; then
328
type1_gs_opt="${type1_gs_opt} -gf ${f}"
329
type1_opt="${type1_opt} -a ${f}"
334
type1_gs_opt="${type1_gs_opt} ${gs_fm}"
337
type1_check_fontmap()
339
dc=`kpsewhich '-format=dvips config' config.ps`
340
if [ $? -ne 0 ] ; then
342
echo "dvips config file 'config.ps' not found" >&2
346
sed 's/[[:blank:]]//' > /dev/null < /dev/null 2> /dev/null;
347
if [ $? -eq 0 ]; then
348
sedfiltregex='s/^p[[:blank:]]*[+]*\([^[:blank:]]*\)[:blank:]*/\1/'
350
sedfiltregex='s/^p[ ]*[+]*\(.*map\).*/\1/'
352
maps=`cat $dc| sed 's/%.*//' | grep '^p' | sed "$sedfiltregex"`
356
f=`kpsewhich '-format=dvips config' $m`
357
if [ $? -eq 0 ] ; then
358
type1_fontmap="${type1_fontmap} $m"
361
echo "dvips fontmap file $m is not found" >&2
370
pcfdirs=" /usr/X11R6/lib/X11/fonts// \
371
/usr/local/X11R6/lib/X11/fonts// \
372
/usr/openwin/lib/X11/fonts// \
373
/usr/X386/lib/X11/fonts// \
374
/usr/XFree86/lib/X11/fonts// \
375
/usr/X11/lib/X11/fonts// \
376
/usr/local/lib/X11/fonts// \
377
/usr/X11R5/lib/X11/fonts// \
378
/usr/local/X11R5/lib/X11/fonts// \
379
/usr/local/share/emacs/fonts// \
380
/usr/local/share/fonts/X11// "
382
for f in ${pcfdirs} ${pcf_kanji_dir_extra}; do
383
if [ "x-${emit_portable}" = "x-yes" ] ; then
384
pcf_dir_opt="${pcf_dir_opt} -d ${f}"
386
ff=`echo ${f} | sed 's|//$||'`
387
if [ -d ${ff} ] ; then
388
pcf_dir_opt="${pcf_dir_opt} -d ${f}"
396
ekanjidirs=" /usr/local/share/fonts/ekanji// \
397
/usr/local/share/fonts/eKanji// "
399
for f in ${ekanjidirs} ${ekanji_kanji_dir_extra}; do
400
if [ "x-${emit_portable}" = "x-yes" ] ; then
401
ekanji_dir_opt="${ekanji_dir_opt} -d ${f}"
403
ff=`echo ${f} | sed 's|//$||'`
404
if [ -d ${ff} ] ; then
405
ekanji_dir_opt="${ekanji_dir_opt} -d ${f}"
415
for f in ${ttfdirs} ${ttf_kanji_dir_extra}; do
416
if [ "x-${emit_portable}" = "x-yes" ] ; then
417
ttf_dir_opt="${ttf_dir_opt} -d ${f}"
419
ff=`echo ${f} | sed 's|//$||'`
420
if [ -d ${ff} ] ; then
421
ttf_dir_opt="${ttf_dir_opt} -d ${f}"
427
get_device_resolution()
429
modes_mf=`kpsewhich modes.mf`
430
if [ x-${modes_mf} = x- ] ; then
431
echo "Not found: modes.mf" >&2
434
if [ ! -f ${modes_mf} ] ; then
435
echo "Not found: modes.mf" >&2
438
devdpi=`cat ${modes_mf} | awk -v devname=${k_mode} '
444
printf("-1\n"); # not found
446
printf("%s\n", devdpi);
448
# Line: e.g., mode_def ljfour = % 600dpi HP LaserJet 4
456
desc=substr($0, i + match(x, "[a-zA-Z0-9]") - 1);
458
# Line: e.g., mode_param (pixels_per_inch, 600);
459
/^[ \t]*mode_param[ \t]*\([ \t]*pixels_per_inch, [ \t]*[0-9.]+\);/ {
460
match($3, "[0-9.]*");
461
ppi=substr($3, 1, RLENGTH);
464
# Line: e.g., mode_param (aspect_ratio, 4/3);
465
# Currently, aspect ratio must be 1
466
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio[ \t]*,[ \t]*[0-9./]+[ \t]*);/ {
467
i=match($0, ",[ \t]*");
471
asp=substr($0, s0, len-1);
473
ppi=-1; ### ignore this entry.
475
# Line: e.g., mode_param (aspect_ratio, 180 / pixels_per_inch);
476
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio, [ \t]*.*\/[ \t]*pixels_per_inch)/ {
477
i=match($0, ",[ \t]*[0-9.]");
478
x=substr($0, i+RLENGTH-1);
481
ppiv=substr($0, s0, RSTART-1);
483
ppi=-1; ### ignore this entry.
485
# Line: e.g., enddef;
487
if ((mode != "") && (ppi > 0)){
488
if ((ppiv < 0) && (mode == devname)){
497
if [ ${devdpi} -eq -1 ] ; then
513
xu=`who am i | awk '{ print $1 }'`
514
echo ";; a vflibcap file generated by 'vflmkcaptex' automatically"
516
echo ";; on ${xh} by ${xu}"
518
echo ";; command line arguments given to generate this vflibcap:"
519
echo ";; vflmkcaptex ${cmdline}"
523
if [ ${k_dpi} -eq -1 ] ; then
524
get_device_resolution;
526
# echo ${k_mode} ${k_dpi}; exit;
529
opt="-n ${k_mode} -r ${k_dpi} -p ${k_prg}"
530
if [ "x-${have_kpathsea}" = "x-yes" ] ; then
533
if [ "x-${use_tex_mapper}" = "x-yes" ] ; then
536
for c in ${fclass}; do
544
vflmkvfl ${opt} ${ccv}
547
# Emit TeX font mapper
550
if [ "x-${use_tex_mapper}" = "x-yes" ] ; then
552
for c in ${fclass}; do
555
opt_map="${opt_map} -m ${c} %f.%dpk"
558
opt_map="${opt_map} -m ${c} %f.%dgk"
561
opt_map="${opt_map} -m ${c} %f.vf"
564
opt_map="${opt_map} -m ${c} %f.%dtfm"
567
opt_map="${opt_map} -m ${c} %f.pfb"
570
opt_map="${opt_map} -m ${c} %f.jtex"
575
opt="${opt} -d TEXMF"
576
vflmktex ${opt} ${opt_map}
581
comopt1="-n \$TeX_KPATHSEA_MODE -d TEXMF"
582
comopt2="-r \$TeX_DPI"
583
for c in ${fclass}; do
587
if [ "x-${gen_pk_otf}" = "x-yes" ] ; then
590
vflmkpk ${comopt1} ${comopt2} ${opt}
593
vflmkgf ${comopt1} ${comopt2}
596
vflmkvf ${comopt1} ${comopt2} -m any %f.pk
599
opt="${comopt1} ${comopt2}"
601
opt="${opt} -a TEXMF"
602
opt="${opt} -e ${datadir}/VFlib/${vflibversion}/t1lib"
603
opt="${opt} -e ${datadir}/VFlib/site"
604
opt="${opt} -e ${datadir}/VFlib/site/t1lib"
612
opt="${opt} ${type1_opt} ${type1_gs_opt} ${type1_fontmap}"
616
vflmktfm ${comopt1} ${comopt2}
622
if [ "${use_jtex}" = "yes" ] ; then
623
jtex_opt="-c ${jtex_class}"
624
if [ "x-${use_jtex_jisx0212}" = "x-yes" ] ; then
625
jtex_opt="${jtex_opt} -jisx0212"
627
case ${jtex_class} in
630
vflmkpcf ${opt} ${pcf_dir_opt}
634
vflmkekan ${ekanji_dir_opt}
638
vflmkttf ${opt} -d TEXMF ${ttf_opt} ${ttf_dir_opt}
639
jtex_opt="${jtex_opt} ${ajt_ttf_fontdb}"
642
vflmkajt -d TEXMF -x .pk ${jtex_opt}