#!/usr/bin/env tclsh # make a Truetype family into stuff for TeTEX # this is for preparing *type families*; individual decorative # and dingbat fonts are handled in a separate script # Released under the terms of the FSF's General Public License # (But it should be noted that another script on which this depends, # fontinst.sty, has a decidedly incompatible license.) # the TTF files should be named by the TeX convention, except thet # the encoding position is an `@'. 8a encoding will be imposed # upon extraction of the AFM. Note that small foundries are coded # `f', use the argument to spec a directory for them. # Also note that the fontinst script appears to ignore the c # width code; use n instead. # 2001 Jul 17 # directory in which the main texmf resides set texin /usr/pkg/share if {([llength $argv]-1)/2 != 0} { puts stderr "Usage: $argv0 []" puts stderr { generally being the first three letters of the filenames} puts stderr { is supplier/family directory} exit 1 } set fam [lindex $argv 0] #fixme: get from texmf/fontname/supplier.map array set sdir {b bitstrea j microsft o corel u urw 9 unknown} #fixme: get from texmf/fontname/typeface.map # bx, CB, gi, ld are my own array set fdir {bx barbedor CB casablanca ct cheltenh gi georgia gl galliard gm garamond ld lido} set dir [lindex $argv 1] #fixme: very rough test if {![string match */* $dir]} { set dir $sdir([string index $fam 0])/$fdir([string range $fam 1 end]) } # construct the Ghostscript mapping and the afm files set psm [open $fam.ps w] foreach i [glob $fam*.ttf] { set f [file root $i] set g [string map {@ 8a} $f] exec ttf2afm -a -e $texin/texmf/dvips/base/8a.enc $f.ttf >$g.afm set afm [open $g.afm r] regexp {FontName ([^\n]*)} [read $afm] {} name close $afm set psname($f) $name #puts $f:$name puts $psm "($name) ($texin/texmf/fonts/ttf/$dir/$f.ttf) ;" } close $psm # TeX as a script language may be even more horrific than perl! # I'd replace this if I had half a clue exactly what it did. # see texmf/doc/fontinst/base/fontinst.dvi exec tex -interaction=batchmode fontinst.sty \\latinfamily{$fam}{}\\end >@stderr 2>@stderr # `compile' the property files into tfm and vf foreach i [glob -nocomplain $fam*.pl] { exec pltotf $i } foreach i [glob -nocomplain $fam*.vpl] { exec vptovf $i } if {![catch {glob $fam*.pl $fam*.vpl *.mtx *$fam.fd $fam*8a*.tfm} x]} { eval {file delete --} $x } # construct dvips map file mkdir texmf/dvips/config set dvm [open texmf/dvips/config/$fam.map w] foreach i [lsort [glob $fam*8r*.tfm]] { # I need to get from the names concocted by fontinst.sty # back to the names of the TTFs; plus I need to catch # obliques and add the slope command. set i [file root $i] set ttf [string map {8r @} $i] set ps {} set x [string map {o@ @} $ttf] if {[string compare $x $ttf]} { #fixme: get the slope from somewhere set ps {.167 SlantFont} set ttf $x } puts $dvm "$i $psname($ttf) \"$ps TeXBase1Encoding ReEncodeFont\" <8r.enc" } close $dvm foreach x {afm tfm ttf vf} { # the tfm are required by TeX # the vf are required by dvips # the ttf are required by Ghostscript # the afm might be useful to something, this is a handy place to keep them if {![catch {glob $fam*.$x} lst]} { set z texmf/fonts/$x/$dir file mkdir $z eval {file rename -force --} $lst [list $z] } } puts "Now:" puts "* transfer the texmf tree into $texin/texmf," puts "* run texhash," puts "* add `$fam.map' to extra_modules in texmf/dvips/config/updmap," puts "* run texmf/dvips/config/updmap," puts "* append $fam.ps to ghostscript/6.01vflib/lib/Fontmap.GS." #eof