New Font Tools For
Total Page:16
File Type:pdf, Size:1020Kb
New font to ols for T X E Werner Lemb erg Kleine Beurhausstr. 1 D-44137 Dortmund Germany [email protected] Abstract The following font to ols will b e describ ed in this pap er: VFlib, the Vector Font Library, which has b een written by Kakugawa Hi- rotsugu Ì ¯ < ê. This library together with an included suite of demo applications is aimed to provide a uniform interface for accessing fonts in many di erent formats. With the help of con guration les it is p ossible to access fonts with other enco dings, to de ne new virtual fonts, and others. Using VFlib as a basis for dvi drivers, it will b e no longer necessary to have pk les for any font format except for Metafont. FreeTyp e, develop ed byDavid Turner, Rob ert Wilhelm, and the author of this pap er. This is a platform-indep endent library to render bitmaps from TrueTyp e fonts. What makes it di erent from other freely available TrueTyp e to ols is a TrueTyp e interpreter to pro cess hints. ttf2pk and hbf2gf, maintained resp. written by the author. Both programs are part of the CJK package and are used to convert CJK TrueTyp e and HBF fonts into T X fonts. E Intro duction Today,wehave many font les and many dif- ferent font le formats. When we need soft- None of the to ols are really new, but until now they ware to display or printcharacters whichdoes either have not b een presented to the English T X E not dep end on a windowing system and/or communityorhave b een hidden in other packages. an op erating system, wemust write interface Most of them are work in progress, and there is a routines for accessing font les in each appli- good chance that this pap er is already out of date cation software again and again. To do this, when it is printed. programmers must have knowledge of font le 1 All of them have a CJK background more or formats; it will b e a hard task for program- less; Kakugawa originally wanted easy Japanese mers if the number of font formats that an font supp ort for dvi drivers, mytwo programs are application software supp orts b ecomes large. still only useful for CJK fonts, and FreeTyp e was also so on extended to manage CJK TrueTyp e fonts. VFlib is a font library written in C pro- Nevertheless, work is going on to internationalize the viding several functions to obtain bitmaps of to ols, making them useful for a broader audience. characters. VFlib hides the font format of font In the bibliographyyou can nd the lo cations les and provides a uni ed API for all sup- from whichtodownload the packages. p orted font formats. Thus, programmers for application software need not have knowledge VFlib on font le formats. Instead, any software us- Until recently do cumentation was only available in ing VFlib can supp ort various font le formats Japanese see [2] | the main reason why this great immediately. to ol is virtually unknown outside of Japan. Nowa translation into English has b een made; this quote [...] 2 from basic.txt tells what VFlib is: Currently, VFlib supp orts the following font 1 Chinese/Japanese/Korean 2 le formats: PCF, BDF, HBF, TrueTyp e, In general, I'm following the do cumentation les very closely, omitting not so imp ortantortootechnical details. GF, PK, TFM, ShotaiKurabu b K û Õ , 206 TUGb oat,Volume 18 1997, No. 3 | Pro ceedings of the 1997 Annual Meeting New font to ols for T X E 3 a vector font format for Japanese Kanji, device. In addition to these font metrics are de ned and JG another vector font format for Japa- for each glyph. nese Kanji. Esp ecially, VFlib can b e used as Some font le formats do not have such con- a font mo dule for drivers/previewers of dvi cepts; in this case, missing information either is A les T X/L T X; part of this package is a given in a vf libcap le or the sp eci c font driver pro- E E sample dvi previewer for X Windows writ- vides default values. For instance, a TrueTyp e font ten with only 400 lines of C co de. is a vector font and is not restricted to a certain p oint size and resolution of the target device since VFlib stands for Vector Font library | earlier vector fonts can b e scaled to any size. Another ex- versions of the library have supp orted Japanese vec- ample is the ShotaiKurabu font format whichdoes tor fonts only, hence the name. not have font metric information at all: a font driver Basic concepts. The VFlib mo dule consists of two for this font format generates virtual font metrics parts: the library itself whichmust b e linked to the using the data given in a vf libcap le. application program, and a font database le called Here a small excerpt of a vf libcap le suitable `vf libcap' since the le format resembles the format for Japanese T X JT X; omissions are indicated E E of a termcap database; see b elow for an example. with three dots. Font classes and font drivers. VFlib can handle VFlib-Defaults:\ multiple font le formats. Reading a font le is done :implicit-font-classes=ascii- jtex- kanj i,\ byaninternal mo dule in VFlib corresp onding to the gf/pk:\ font le format. This internal mo dule is called a :extension-hints=pk=ascii-jte x-kan ji,\ `font driver'. Service units provided by font drivers gf=ascii-jtex-kanji,\ are called `font classes'. From an end-user's p ointof pk=gf/pk,\ view, font formats are distinguished by the names gf=gf/pk,\ of font classes. Font drivers themself are not visible .ttf=ttf:\ for end-users. :variables-default-values=\ $TeX_KPATHSEA_PROGRAM=\ Some font drivers may not read font les on /usr/local/teTeX/bin/xldvi: disk; they may generate glyphs and outlines by in- ternal computation only. In addition, some font TeX-Defaults:\ drivers may return glyphs which are obtained as :kpathsea-mode=ljfour:\ glyphs by another font class. :dpi=600:\ Font names and searching. In VFlib, a font is :kpathsea-program-name=\ sp eci ed by a `font name' on op ening. First, VFlib $TeX_KPATHSEA_PROGRAM: checks if the font name is given in vf libcap or not. If the font name is found, VFlib reads the description TrueType-Defaults:\ for the font in vf libcap, invokes a font driver corre- :extension=.ttf:\ sp onding to the font class name and op ens the font :aspect=1:\ :dpi=600:\ le. :font-directories=\ If the font name is not given in a vf libcap le, a /dos/texmf/fonts/truetype/j apane se:\ font searching mechanism is invoked. Since there are :platform=microsoft: so many font les for X Window and T X, this fea- E ture has b een intro duced to avoid writing an entry for each font le. Various font drivers will b e called mincho-jtex:\ to see whether the font can b e op ened; a list of font :font-class=ttf:\ drivers for font searching is given in the vf libcap le. :font-file=uwjmg3.ttf:\ Fonts describ ed in a vf libcap le are called `ex- :magnification=0.92:\ plicit fonts' and fonts that are searched by the font :writing-direction=h:\ search feature are called `implicit fonts'. :character-set=jisx0208_1983: \ :encoding-force=sjis: For T X fonts, the kpathsea library will b e used E for searching. mincho-5pt:\ The vf libcap database. Each virtual font as :point-size=5:\ provided by VFlib has its inherent information on :inheritance=mincho-jtex: p oint size, pixel size, and resolution of the target 3 ... Other transcription forms are SyotaiKurabu or Syotai- Club. TUGb oat,Volume 18 1997, No. 3 | Pro ceedings of the 1997 Annual Meeting 207 Werner Lemb erg All other entries are used to de ne a Japa- mincho-10pt:\ :point-size=10:\ nese TrueTyp e font as a font for JT X. The nal E :inheritance=mincho-jtex: JT X font is built from various layers, starting with E the entry `mincho-jtex' which de nes the TrueTyp e font name, the writing direction, the character set, min:\ etc. `mincho-5pt' is an example of how to inherit :font-class=ascii-jtex-kanj i:\ font capabilities: only a p oint size declaration has :kanji-adjustment-file=\ b een added. Then the `min' base font class is sp eci- /usr/local/VFlib/ascii-jtex/t tf.ad j: ed, calling the `ascii-jtex-kanji' font driver and us- ing an adjustment le ttf.adj for all fonts of this min5:\ 4 class. Note that in `min' no fonts are de ned | :kanji-font=mincho-5pt:\ :inheritance=min: the concept is similar to ob ject oriented languages where some base classes are de ned on which vir- ... tual classes are built. With `min5' or `min10' the top level is reached, using all previously constructed min10:\ font classes. :kanji-font=mincho-10pt:\ NFSS would not require size quantization of the :inheritance=min: font; it's easy to add a prop er entry like this: min-nfss:\ The format of a capability le is somewhat :kanji-font=mincho-jtex:\ strange: each entry must be formally on one line :inheritance=min: which can b e split with a trailing backslash. The A font de ned in this way can then b e used at any name of a capabilityentry is the rst name starting size; VFlib would scale the font appropriately.