~ubuntu-branches/ubuntu/precise/vflib3/precise

« back to all changes in this revision

Viewing changes to doc/Paper1/vflib35.tex

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta
  • Date: 2002-04-15 12:10:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020415121024-cann32wucyfbq22f
Tags: upstream-3.6.12
ImportĀ upstreamĀ versionĀ 3.6.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%%
 
2
%%%  VFlib 3.5.0 document 
 
3
%%%  Revised: 1 September 1998 
 
4
%%%
 
5
%%%  VFlib 3.5.0 --- a general font library that supports multiple font formats
 
6
%%% 
 
7
%%%  by Hirotsugu Kakugawa
 
8
%%%
 
9
%%%  Email: h.kakugawa@computer.org
 
10
%%%  FAX:   +81-824-24-0757
 
11
%%%
 
12
%%%  Research Institute for Information Science and Education
 
13
%%%  Hiroshima University
 
14
%%%  1-7-1 Kagamiyama, Higashi Hiroshima, Hiroshima,
 
15
%%%  739-8521 JAPAN
 
16
%%%
 
17
 
 
18
\documentclass{cah-gut}
 
19
\usepackage{graphicx}
 
20
\usepackage{shortvrb}
 
21
\usepackage{english}
 
22
\usepackage{germanb}
 
23
 
 
24
\newcommand{\pkg}[1]{\textsf{#1}}
 
25
\newcommand{\prog}[1]{\texttt{#1}}
 
26
\newcommand{\file}[1]{\texttt{#1}}
 
27
\newcommand{\var}[1]{\textit{#1}}
 
28
\newcommand{\VFlib}{\pkg{VFlib}}
 
29
\newcommand{\freetype}{\pkg{FreeType}}
 
30
\newcommand{\tlib}{\pkg{T1Lib}}
 
31
\newcommand{\vflibcap}{\pkg{vflibcap}}
 
32
\newcommand{\hbfgf}{\prog{hbf2gf}}
 
33
\newcommand{\ttfpk}{\prog{ttf2pk}}
 
34
\MakeShortVerb{\|}
 
35
 
 
36
%%%---
 
37
 
 
38
\setcounter{page}{1}
 
39
\NoC{0}
 
40
\DateC{}
 
41
 
 
42
%%%----
 
43
 
 
44
\begin{document}
 
45
\selectlanguage{american}
 
46
 
 
47
%%%-----------------------------------------------------------------------
 
48
 
 
49
\title{VFlib 3.5.0 --- a general font library that
 
50
       supports multiple font formats\footnote{
 
51
          This paper is based on 
 
52
          ``VFlib --- a general font library that
 
53
             supports multiple font formats,'' by Hirotsugu Kakugawa,
 
54
           Euro\TeX 98, Saint-Malo, France, 1998.}
 
55
       }
 
56
\author{Hirotsugu Kakugawa}
 
57
\affiliation{%
 
58
   Research Institute for Information Science and Education\\
 
59
   Hiroshima University\\
 
60
   1-7-1 Kagamiyama, Higashi Hiroshima, Hiroshima,\\
 
61
   739-8521 JAPAN}
 
62
\authorhead{Hirotsugu Kakugawa}
 
63
\titlehead{A font library VFlib 3.5.0}
 
64
\maketitle
 
65
 
 
66
 
 
67
%%%-----------------------------------------------------------------------
 
68
 
 
69
\begin{Abstract}
 
70
  \VFlib\ is a font library written in C providing several functions
 
71
  to obtain bitmaps of characters (i.e., a rasterizer).
 
72
  \VFlib\ hides the font format of font files and provides a unified API 
 
73
  for all supported font formats.  
 
74
  Thus, programmers of application software need not worry
 
75
  about font file formats and  any software using \VFlib\ 
 
76
  can support various font file formats immediately.  In addition to
 
77
  this, when a new font format is supported by \VFlib, application
 
78
  software need not be modified to use such new fonts.
 
79
  
 
80
  \VFlib\ has been developed for not only Latin fonts but also Asian
 
81
  scripts such as Chinese, Japanese, and Korean.  Since it is designed
 
82
  as a general font module, it can be used in DVI drivers for \TeX\ 
 
83
  and \LaTeX.   In this paper, we explain the API of \VFlib, a font 
 
84
  database file called \vflibcap, and the internal structure of \VFlib.
 
85
\end{Abstract}
 
86
 
 
87
 
 
88
%%%-----------------------------------------------------------------------
 
89
 
 
90
\begin{Keywords}
 
91
  digital fonts, computer typography, multilingual typography, 
 
92
  multilingual information processing, \TeX
 
93
\end{Keywords}
 
94
 
 
95
 
 
96
%%%-----------------------------------------------------------------------
 
97
 
 
98
\section{Introduction}
 
99
\label{SEC:Introduction}
 
100
 
 
101
Commercially and freely available fonts exist in many
 
102
different font file formats.  When we develop software to display or
 
103
print characters which do not depend on a particular window system 
 
104
and/or an operating system, we must write interface routines for 
 
105
accessing font files for each application program again and again.  
 
106
To do this, programmers must have knowledge of font file formats; 
 
107
it will be a difficult task for programmers if the number of font 
 
108
formats that an application program supports becomes large.
 
109
 
 
110
\VFlib\ is a font library written in C providing several functions to
 
111
obtain glyphs (bitmaps).  \VFlib\ hides the font format of font
 
112
files and provides a unified API for all supported font formats so
 
113
that programmers for application software need not worry about
 
114
font file formats.  Thus, any software using \VFlib\ can support
 
115
various font file formats immediately without modification even when
 
116
\VFlib\ is updated to support new font file formats.  
 
117
Furthermore, \VFlib\ is not window- or operating-system dependent. 
 
118
 
 
119
As far as the author knows, there is no general font library other than
 
120
\VFlib\ that supports multiple font formats in a platform-independent
 
121
way and that provides a unified API for font access.
 
122
For example, X~Window servers support multiple font formats.
 
123
But to use a font service, an X server process is required.  
 
124
Some font libraries have been proposed for general use: 
 
125
\freetype\ 1.1 by David Turner, Robert Wilhelm, and Werner Lemberg is a 
 
126
library for accessing TrueType fonts \cite{FreeType}. 
 
127
The \tlib\ by Rainer Menzner is a library to handle
 
128
Type~1 PostScript fonts \cite{TypeOneLib}.  
 
129
Although both are very useful libraries not dependent on 
 
130
window or operating systems, each of them supports only one 
 
131
font format and has a different API.
 
132
 
 
133
Conversion of font formats so that application software can use 
 
134
multiple font formats is one possible approach.  For example,
 
135
\ttfpk\ \cite{TTFTOPK} (TrueType fonts to PK fonts) 
 
136
and \hbfgf\ \cite{HBFTOGF} (HBF\footnote{
 
137
    The Hanzi Bitmap Font (HBF) format \cite{HBFspecs} 
 
138
    is a binary format for bitmap fonts for 
 
139
    Japanese, Chinese, and Korean characters.
 
140
}
 
141
fonts to GF fonts), 
 
142
both written by Werner Lemberg, makes these font formats 
 
143
available to \TeX. This method is useful but one drawback 
 
144
is that we must convert many font files in advance.
 
145
 
 
146
Currently, \VFlib\ supports the following font file formats: 
 
147
PCF, BDF, HBF, TrueType, Type~1, GF, PK, TFM, VF, Syotai Kurabu 
 
148
and JG \footnote{
 
149
    PCF (Portable Compiled Font) format is a binary format 
 
150
    for bitmap fonts used on X-Window.
 
151
    BDF (Bitmap Distribution Format) \cite{BDFSpec} 
 
152
    is an ASCII format for distributing binary fonts.
 
153
    Syotai Kurabu, which means \textit{font club} in English,
 
154
    is a vector font format for Japanese Kanji characters.
 
155
    JG format is another vector font format for
 
156
    Japanese Kanji characters.
 
157
}.  
 
158
To search \TeX\ font files (e.g., PK, GF, TFM, VF files)
 
159
and TrueType font files, 
 
160
\VFlib\ uses the \pkg{kpathsea} library 3.2 by Karl Berry \cite{Kpathsea}.  
 
161
\VFlib\ can be used as a font module for
 
162
drivers and previewers of DVI files generated by \TeX\ and \LaTeX.
 
163
 
 
164
This paper describes \VFlib\ version 3.5.0\footnote{
 
165
    \VFlib\ version 3.2 is introduced in \cite{Werner97} and
 
166
    version 3.3 is reported in \cite{Kakugawa98a}.
 
167
}.  
 
168
\VFlib\ versions 1 and 2 were designed and implemented 
 
169
for Japanese fonts only; they are widely used
 
170
in many localized software packages in Japan, 
 
171
e.g. by \pkg{Ghostscript}, \pkg{dvi2ps}, and \pkg{xdvi} 
 
172
for printing Japanese Kanji characters.  
 
173
\VFlib\ version 3 is designed for multilingual
 
174
document processing in English, French, Chinese, Japanese,
 
175
Korean, and other languages.
 
176
 
 
177
This paper is organized as follows.  In section \ref{SEC:ConceptsOfVFlib}, 
 
178
the basic concepts of \VFlib\ are explained.
 
179
The API of \VFlib\ is shown in section \ref{SEC:VFlibOfAPI}, and the
 
180
font database called \vflibcap\ is explained in section
 
181
\ref{SEC:Vflibcap}.  An interesting feature of \VFlib\ is the
 
182
ability to provide fonts without font files.  Section
 
183
\ref{SEC:ClassesWithoutFontFiles} explains this feature.  The author
 
184
has developed several sample programs using \VFlib, and one of these is
 
185
introduced briefly in section \ref{SEC:SamplePrograms}.  
 
186
Section \ref{SEC:Conclusion} gives concluding remarks.
 
187
 
 
188
 
 
189
%%%-----------------------------------------------------------------------
 
190
 
 
191
\section{Basic Concepts}
 
192
\label{SEC:ConceptsOfVFlib}
 
193
 
 
194
\subsection{System components}
 
195
 
 
196
The \VFlib\ system consists of two parts:
 
197
 
 
198
\begin{enumerate}
 
199
\item A library (\file{libVFlib.a}) \\
 
200
  It provides several C functions.  Any application software using
 
201
  \VFlib\ must link with this library.
 
202
\item A font database file (\file{vflibcap}) \\
 
203
  This file defines fonts and their properties (called {\em capabilities}),
 
204
  such as point size and the font file format.  Its syntax is lisp-like
 
205
  notation.
 
206
\end{enumerate}
 
207
 
 
208
When we initialize \VFlib, we can specify a \vflibcap\ file to be used
 
209
and thus different font sets can be used by different software.
 
210
 
 
211
\subsection{Font classes and font drivers}
 
212
 
 
213
\VFlib\ can handle multiple font file formats.  Reading a font file
 
214
according to the font file format is done by an internal module in
 
215
\VFlib\ corresponding to its font file format.  This internal module
 
216
is called a {\em font driver}.  Service units provided by font drivers
 
217
are called {\em font classes}.  From an end-user's point of view,
 
218
various font formats are distinguished by various names of font
 
219
classes.  Font drivers are internal to \VFlib\ and invisible to
 
220
end-users.
 
221
 
 
222
Some font drivers may not read font files on disk: they may generate
 
223
glyphs and outlines by internal computation only.  In addition, some
 
224
font drivers may return glyphs which are obtained as glyphs by another
 
225
font class.
 
226
 
 
227
\subsection{A view of \VFlib\ font from end-users perspective}
 
228
 
 
229
Each (virtual) font by \VFlib\ has its inherent information of point
 
230
size, pixel size, and resolution of the target device.  In addition,
 
231
font metrics are defined for each glyph.  
 
232
Some font file formats may not have such concepts.
 
233
For instance, TrueType font files are vector font
 
234
files and do not have information on point size.  
 
235
Syotai Kurabu format fonts do not have font metric information at all.  
 
236
In such case, either (1)~the lacking information 
 
237
is given in \vflibcap\ or (2)~the specific font driver gives such 
 
238
information as default values. 
 
239
 
 
240
\subsection{Font names and font searching mechanism}
 
241
 
 
242
In \VFlib, a font is specified by a {\em font name} on opening.
 
243
First, \VFlib\ checks whether the font name is given in \vflibcap\ or
 
244
not.  If the font name is found, \VFlib\ reads the description for the
 
245
font in \vflibcap.  The description contains a font class name; \VFlib\ 
 
246
then invokes a font driver corresponding to the font class name.
 
247
Finally the font driver opens the font file (if necessary).
 
248
 
 
249
If the font name is not given in a \vflibcap\ file, a font searching
 
250
mechanism is invoked.  Since there are many font files for X~Window
 
251
and \TeX, this feature is introduced to avoid writing an entry for
 
252
each font file.  Various font drivers will be called to see whether
 
253
the font can be opened; a list of font drivers for font searching is
 
254
given in the \vflibcap\ file.  If a font driver succeeds in opening the
 
255
font, font searching finishes and the \VFlib\ font opening function
 
256
returns successfully.  Otherwise, font open fails.
 
257
 
 
258
Fonts described in a \vflibcap\ file are called {\em explicit fonts} and
 
259
fonts that are searched for by the font search feature are called {\em
 
260
  implicit fonts}.
 
261
 
 
262
\subsection{Two modes of opened fonts}
 
263
 
 
264
The following two modes are provided to obtain glyphs of fonts.
 
265
\begin{itemize}
 
266
\item High resolution device-oriented mode (mode 1)\\
 
267
  The size of glyphs is specified by the physical size of
 
268
  glyphs and device resolution. 
 
269
\item Low resolution device-oriented mode (mode 2)\\
 
270
  Glyph sizes are specified by pixel size rather than by
 
271
  device resolution.  
 
272
\end{itemize}
 
273
When the size of a glyph in the
 
274
source font is different from the target size, \VFlib\ scales the
 
275
source glyph internally.
 
276
Thus, users need not know know original size of glyphs in font files.
 
277
 
 
278
Two modes are provided by the following reason.
 
279
When we write a application programs that prints documents on printer, 
 
280
it is convenient to specify glyph size by point and device resolution
 
281
such as glyph of 12 point for a 300 dpi printer.
 
282
On the other hand, when we write a application programs 
 
283
that displays documents on CRT screen,
 
284
it is convenient to specify glyph size by pixel.
 
285
 
 
286
\subsection{Internal Structure}
 
287
 
 
288
The \VFlib\ library consists of a {\em core} and several {\em font
 
289
  drivers}.  The \VFlib\ core provides entry functions of the API, 
 
290
as well as a font driver table, opened font table, \vflibcap\ access module,
 
291
and other utility modules.  The internal structure of \VFlib\ is
 
292
depicted in Figure \ref{FIG:VFlibInternal}.
 
293
 
 
294
\begin{figure}
 
295
  \begin{center}
 
296
    \mbox{\includegraphics[scale=1.0]{internal.eps}}
 
297
  \end{center}
 
298
  \caption{Internal structure of \VFlib}
 
299
  \label{FIG:VFlibInternal}
 
300
\end{figure}
 
301
 
 
302
Each font driver has corresponding functions for each font operation
 
303
of \VFlib.  Such functions are implemented to provide \VFlib\ 
 
304
API-compatible behaviour.  
 
305
The set of capabilities that can be used for each font class 
 
306
in \vflibcap\ file may differ; each font class defines 
 
307
the capabilities it needs.
 
308
 
 
309
 
 
310
%%%-----------------------------------------------------------------------
 
311
 
 
312
\section{The API}
 
313
\label{SEC:VFlibOfAPI}
 
314
 
 
315
In this section we describe the API of \VFlib.  The API that \VFlib\ 
 
316
defines is simple.  For example, as a contrast, \freetype\ defines 
 
317
a rich set of functions including access to kerning information.  
 
318
The simplicity of \VFlib\ API is a result of the limitation that 
 
319
it must be common to every font format that \VFlib\ supports.  
 
320
\VFlib\ does not have features for typesetting such as obtaining 
 
321
kerning information of fonts.  But it is enough strong to print and 
 
322
display typesetted documents such as DVI files.
 
323
 
 
324
\subsection{Data types}
 
325
 
 
326
\VFlib\ defines the following three data types for font access: bitmaps
 
327
and metrics for modes~1 and~2.
 
328
 
 
329
\begin{itemize}  
 
330
\item Bitmap object \\
 
331
  A bitmap object is a set of font metrics and bitmap data.  The
 
332
  following is the definition of bitmap structure.
 
333
 
 
334
\begin{quote}
 
335
\begin{small}
 
336
\setlength{\baselineskip}{1em}
 
337
\begin{verbatim}
 
338
struct vf_s_bitmap {
 
339
  int             bbx_width, bbx_height; /* in pixels */
 
340
  int             off_x, off_y;          /* in pixels */
 
341
  int             mv_x,  mv_y;           /* in pixels */
 
342
  unsigned char*  bitmap;
 
343
  int             raster;
 
344
};
 
345
\end{verbatim}
 
346
\end{small}
 
347
\end{quote}
 
348
 
 
349
  The members \prog{bbx\_width} and \prog{bbx\_height} are the width
 
350
  and height of the bitmap, respectively.  The members \prog{bitmap}
 
351
  and \prog{raster} are pointers to the glyph data and the number of
 
352
  bytes of a raster.  The members \prog{off\_x} and \prog{off\_y} 
 
353
  form a vector from the reference point to the upper-left corner of a
 
354
  bitmap.  The members \prog{mv\_x} and \prog{mv\_y} form a vector to
 
355
  the next reference point.  Metric information is given in pixel form.
 
356
  
 
357
\item Metric object (modes 1 and 2) \\
 
358
  Metric objects for modes~1 (high resolution device-oriented mode)
 
359
  and~2 (low resolution device-oriented mode) are defined similarly 
 
360
  as bitmap objects except that they do not have \prog{bitmap} and
 
361
  \prog{raster} members.  Member types of mode~1 metric objects 
 
362
  are \prog{double}, not \prog{int}; their units are points rather 
 
363
  than pixels.
 
364
\end{itemize}
 
365
 
 
366
\subsection{Functions}
 
367
 
 
368
\begin{itemize}
 
369
\item \prog{int VF\_Init(char* \var{vflibcap},
 
370
                         char* \var{variable\_list})} \\
 
371
  Initialize \VFlib.  The first argument \var{vflibcap} is the file name
 
372
  of a \vflibcap\ file.  The second argument {\it variable\_list} is a 
 
373
  list of parameters passed to \VFlib\ for parameterization of \vflibcap.
 
374
  (See subsection \ref{SUBSEC:VFLIBCAP:PARAM} for details of
 
375
  parameterization.)
 
376
 
 
377
\item \prog{int  VF\_OpenFont1(char* \var{font\_name},
 
378
                               double \var{dpi\_x},
 
379
                               double \var{dpi\_y}, 
 
380
                               double \var{point\_size}, 
 
381
                               double \var{mag\_x},
 
382
                               double \var{mag\_y})} \\
 
383
  Open a font in mode~1.  The font name is given by the first
 
384
  argument.  Two arguments \var{mag\_x} and \var{mag\_y} are
 
385
  horizontal and vertical magnification factors.  The actual font size
 
386
  is determined by these arguments.  This function returns a font
 
387
  identifier (font id) for the opened font.  All font operations take
 
388
  this font id to specify a target font.
 
389
 
 
390
\item \prog{int VF\_OpenFont2(char *\var{font\_name},
 
391
                              int \var{pixel\_size},  
 
392
                              double \var{mag\_x}, 
 
393
                              double \var{mag\_y})} \\
 
394
  Open a font in low resolution mode.  This function is similar to
 
395
  \prog{VF\_OpenFont1()} except font size is given in pixels.
 
396
 
 
397
\item \prog{VF\_BITMAP  VF\_GetBitmap1(int \var{font\_id}, 
 
398
                                       long \var{code\_point},
 
399
                                       double \var{mag\_x}, 
 
400
                                       double \var{mag\_y})} \\
 
401
  Obtain a glyph bitmap of a given font id (in mode~1) and code point.
 
402
  The font id \var{font\_id} must be an id returned by
 
403
  \prog{VF\_OpenFont1()}.  The size of the bitmap to be obtained can
 
404
  be specified by the \var{mag\_x}, and \var{mag\_y} arguments.  
 
405
 
 
406
\item \prog{VF\_BITMAP  VF\_GetBitmap2(int \var{font\_id}, 
 
407
                                       long \var{code\_point},
 
408
                                       double \var{mag\_x},
 
409
                                       double \var{mag\_y})} \\
 
410
  Obtain a glyph bitmap of a given font (in mode~2) and code point.
 
411
\end{itemize}
 
412
 
 
413
\VFlib\ defines other functions such as \prog{VF\_""METRIC1
 
414
  VF\_""Get""Metric1()} and \prog{VF\_""METRIC2 VF\_""Get""Metric2()}
 
415
to obtain font metrics of a character of mode~1 and~2 fonts,
 
416
respectively; \prog{VF\_""OUTLINE VF\_""Get""Outline()} to obtain
 
417
\VFlib\ format vector data of a character of mode~1 fonts; and
 
418
\prog{VF\_""BITMAP VF\_""Outline""To""Bitmap()} to convert \VFlib\ format
 
419
vector data to a bitmap.  By calling
 
420
\prog{VF\_""Install""Font""Driver()}, a font driver is installed.
 
421
 
 
422
 
 
423
%%%-----------------------------------------------------------------------
 
424
 
 
425
\section{A Font Database File ``\vflibcap''}
 
426
\label{SEC:Vflibcap}
 
427
 
 
428
A \vflibcap\ file is a database of font definitions for \VFlib.  It is
 
429
read when \VFlib\ is initialized.  A simple example of a \vflibcap\ file
 
430
is shown below:
 
431
 
 
432
\begin{quote}
 
433
\begin{small}
 
434
\setlength{\baselineskip}{1em}
 
435
\begin{verbatim}
 
436
(define-default  VFlib
 
437
  (uncompression-programs  (".Z" "zcat") (".gz" "gzip -cd"))
 
438
  (implicit-font-classes  pcf bdf)
 
439
  (extension-hints  (".bdf" bdf) (".pcf" pcf)))
 
440
 
 
441
(define-default  bdf
 
442
  (filename-extensions ".bdf")
 
443
  (font-directories  "/usr/local/share/fonts/X11//")
 
444
  (compression-extensions ".gz" ".Z"))
 
445
 
 
446
(define-default  pcf
 
447
  (filename-extensions ".pcf")
 
448
  (font-directories  "/usr/X11R6/lib/X11/fonts//"
 
449
                     "/usr/openwin/lib/X11/fonts//")
 
450
  (compression-extensions ".gz" ".Z"))
 
451
 
 
452
(define-font  timR24    ; Times Roman 24pt, BDF format
 
453
  (font-class bdf)
 
454
  (dpi 300) (point-size 24)
 
455
  (font-file "timR24.bdf"))
 
456
 
 
457
(define-font  timR18    ; Times Roman 18pt, PCF format
 
458
  (font-class pcf)
 
459
  (dpi 300) (point-size 24)
 
460
  (font-file "timR18.pcf"))
 
461
\end{verbatim}
 
462
\end{small}
 
463
\end{quote}
 
464
 
 
465
By a \prog{define-default} construct, a default values of a font class
 
466
is defined.  By a \prog{define-font} construct, a font is defined.  
 
467
Semicolon (\prog{;}) starts a comment.
 
468
In this example, there are three definitions for font class default
 
469
(\prog{VFlib}, \prog{BDF}, and \prog{PCF}) and two font definitions
 
470
(\prog{timR24} and \prog{timR18}). The first three entries are used to
 
471
give default parameters for \VFlib\ and each font class.  We explain
 
472
these entries later and explain the other two entries first.  Although
 
473
many capabilities are defined, we explain only the fundamental ones.
 
474
 
 
475
\subsection{Font entries}
 
476
 
 
477
The entry \prog{timR24} has several capabilities.  A capability
 
478
\prog{font-""class} specifies the font class name.  In this example,
 
479
\prog{timR24} belongs to the \prog{bdf} font class.  
 
480
The capabilities \prog{dpi} and \prog{point-""size} give 
 
481
device resolution and point size of a font.
 
482
These values are used when this font is opened in mode~1.  
 
483
A capability \prog{pixel-""size} gives the pixel size.  
 
484
This value is used when this font is opened in mode~2. 
 
485
The capabilities \prog{pixel-""size}, \prog{dpi}, and \prog{point-""size}
 
486
can be omitted since a BDF font file contains their values.  
 
487
A capability \prog{font-""file} gives the file name of the font.
 
488
Similarly, \prog{timR18} is defined except in cases of PCF fonts.
 
489
 
 
490
The two font files \prog{timR24.bdf} and \prog{timR18.pcf} are both
 
491
bitmap fonts used in X~Window.  Although pixel size, point size, and
 
492
target device resolution are together with the bitmap given in the
 
493
font file, \VFlib\ internally enlarges or shrinks bitmaps to yield the
 
494
requested size.  From a user's point of view, only the font names
 
495
(\prog{timR24} and \prog{timR18}) are visible; users need not be aware
 
496
of font formats.
 
497
 
 
498
\subsection{Default descriptions}
 
499
 
 
500
In the example above, there are three default descriptions.  The first
 
501
entry \prog{VFlib} is used to give global parameters of \VFlib.  In
 
502
our example, the relation between the filename extension and an
 
503
uncompression program is given by the capability
 
504
\prog{uncompression-""programs}; it specifies that files whose names
 
505
end in \prog{.Z} and \prog{.gz} are uncompressed by running commands
 
506
\prog{zcat} and \prog{gzip -cd}, respectively. 
 
507
The capability \prog{implicit-""font-""classes} specifies a
 
508
list of font classes that search implicit fonts.  When a font is
 
509
opened and a corresponding entry is missing in \vflibcap, font drivers
 
510
given by this capability are called to search the font in given order.
 
511
Suppose a font named \prog{timR10.bdf} is requested to open.  Since
 
512
such an entry does not exist in the \vflibcap\ file, the font is
 
513
searched as an implicit font by calling the PCF font driver first, and
 
514
then the BDF font driver.  A capability \prog{extension-""hints} gives
 
515
a relation of font name extension and font class.  In the example, if
 
516
an extension of a font name is \prog{.pcf} (\prog{.bdf}), the PCF
 
517
(BDF) font driver is called for implicit font search.  For example, if
 
518
a font named \prog{timR08.bdf} is requested to open, the BDF font
 
519
driver is called.  This is useful for searching implicit fonts fast.
 
520
 
 
521
The next definition \prog{BDF} is a default description for the BDF
 
522
font class.  A capability \prog{font-""directories} is a list of font
 
523
directories in which font files are stored.  If the directory name is
 
524
terminated by \prog{//}, files are searched recursively under the
 
525
directory.  The entry \prog{compression-""extensions} gives a list of
 
526
file compressions that BDF font class supports.
 
527
Similarly, default definition for \prog{PCF} font class is given.
 
528
 
 
529
\subsection{Parameterized \vflibcap}
 
530
\label{SUBSEC:VFLIBCAP:PARAM}
 
531
 
 
532
Capability values in \vflibcap\ can be overridden at execution time.
 
533
By this feature, called {\em parameterization}, several applications 
 
534
can share the same \vflibcap\ file.
 
535
The next example is a \vflibcap\ for printer driver for \TeX\ DVI file
 
536
for 300 dpi Canon Laser Shot.
 
537
Note that all fonts are implicit fonts.
 
538
 
 
539
\begin{quote}
 
540
\begin{small}\setlength{\baselineskip}{1em}
 
541
\begin{verbatim}
 
542
(define-default  VFlib
 
543
  (implicit-font-classes  pk)
 
544
  (extension-hints  ("pk" pk))
 
545
  (variable-values  (TeX_USE_KPATHSEA      "Yes")
 
546
                    (TeX_DPI               "300")
 
547
                    (TeX_KPATHSEA_MODE     "cx")
 
548
                    (TeX_KPATHSEA_PROGRAM  "/usr/local/bin/xldvi"))
 
549
  (use-kpathsea           $TeX_USE_KPATHSEA)
 
550
  (kpathsea-mode          $TeX_KPATHSEA_MODE)
 
551
  (kpathsea-program-name  $TeX_KPATHSEA_PROGRAM) )
 
552
 
 
553
(define-default  TeX
 
554
  (dpi $TeX_DPI)
 
555
  (tfm-directories  "TEXMF" "/usr/local/fonts/tfm")
 
556
  (tfm-filename-extensions  ".tfm"))
 
557
 
 
558
(define-default pk
 
559
  (font-directories  "TEXMF" "/usr/local/fonts/pk"))
 
560
\end{verbatim}
 
561
\end{small}
 
562
\end{quote}
 
563
 
 
564
In the \prog{VFlib} entry, the capability \prog{variables-""values}
 
565
gives a list of variable names and their default values.  In this
 
566
example, there are three variables. For instance, the default value of
 
567
\prog{TeX\_""DPI} is \prog{300}.  A capability value can be a value of
 
568
a variable if a dollar sign (\prog{\$}) followed by a variable name is given.  
 
569
In the \prog{VFlib} entry, initialization parameters for \pkg{kpathsea}
 
570
are given.
 
571
 
 
572
In the \prog{TeX} entry, which is used to specify a common 
 
573
default description  for \TeX\ related font classes, 
 
574
the value of the capability \prog{dpi} 
 
575
is given as the value of a variable \prog{TeX\_""DPI}, for example.
 
576
Capabilities \prog{tfm-directories} is a list of TFM files directories, 
 
577
and \prog{tfm-""filename-""extensions} is a extension of a file name 
 
578
for TFM files.
 
579
The name \prog{"TEXMF"} in \prog{tfm-""directories} is a special name 
 
580
to seach a file using \pkg{kpathsea}.
 
581
 
 
582
The entry \prog{pk} entry is used to specify default description 
 
583
for font files in PK format.
 
584
A PK file is search by \pkg{kpathsea} first since the first item
 
585
of the value of the capability \prog{font-""directories} is \prog{"TEXMF"}.
 
586
If it is not found, then it is searched in \prog{/usr/""local/""fonts/pk}
 
587
directory next.
 
588
 
 
589
Default variable values can be overridden by giving a list of pairs of
 
590
variable names and their values when \VFlib\ is initialized by
 
591
\prog{VF\_Init()}. If a Unix environment variable
 
592
\prog{VFLIBCAP\_""PARAM\_\var{var}} (e.g.,
 
593
\prog{VFLIBCAP\_""PARAM\_TeX\_DPI} is defined, its value becomes the
 
594
value of the \vflibcap\ variable \prog{TeX\_""DPI}.)
 
595
The example \vflibcap\ file can be used for 600 dpi HP Laser Jet 4 printers 
 
596
if we override variable values so that
 
597
\prog{TeX\_""DPI} is \prog{600} and \prog{TeX\_""KPATHSEA\_""MODE} is
 
598
\prog{ljfour} on execution time without any file modification.
 
599
 
 
600
 
 
601
%%%-----------------------------------------------------------------------
 
602
 
 
603
\section{Font Classes without Font Files}
 
604
\label{SEC:ClassesWithoutFontFiles}
 
605
 
 
606
\begin{figure}
 
607
\begin{center}
 
608
\mbox{\includegraphics[scale=0.75]{comic-jp.eps}}
 
609
\end{center}
 
610
\caption{Mixture of {\it gothic} and {\it mincho} fonts in Japanese comics}
 
611
\label{FIG:JpComics}
 
612
\end{figure}
 
613
 
 
614
Fonts provided by font classes need not be associated with font files.
 
615
As examples of such font classes, 
 
616
the {\em Japanese comic} font class and
 
617
the {\em try} font class are implemented.
 
618
 
 
619
\subsection{The Japanese comic font class}
 
620
 
 
621
In Japanese comics, a gothic font is used for Kanji
 
622
characters and a {\it mincho} font is used for Kana
 
623
characters as shown in Figure \ref{FIG:JpComics}.  
 
624
Without creating a new font, we can implement such fonts by 
 
625
the  Japanese comic font driver: 
 
626
a font $F$ of the Japanese comic class needs two sub-fonts that are
 
627
specified in a \vflibcap\ file; fonts for Kanji characters, say $F_1$,
 
628
and Kana characters, say $F_2$.  
 
629
A glyph for code point $c$ of font $F$ is obtained from $F_1$ if $c$ 
 
630
is a Kanji character, and from $F_2$ if $c$ is a Kana character.  
 
631
The font classes of $F_1$ and $F_2$ need not be the same.
 
632
 
 
633
 
 
634
\subsection{The try font class}
 
635
 
 
636
The try font class provides a feature to open a font among list of fonts.
 
637
Each font $f$ of the try font class has a list of fonts, say $g_1, g_2, ...$.
 
638
When $f$ is requested to open, the font driver tries to open fonts
 
639
$g_1, g_2, ...$ in this order until one of them, 
 
640
say $g_s$, is opened successfully.
 
641
Then, any font operation on $f$ is applied on $g_s$ and 
 
642
therefore, $g_s$ is used as a font $f$.
 
643
 
 
644
This font class is useful when we want to use non-standard 
 
645
(i.e., site dependent) fonts.
 
646
Suppose that a non-standard font $f_n$ is listed followed by
 
647
a standard font $f_s$ in a font list of $f$ of try font class.
 
648
Then, to open $f$ is the same as opening $f_n$ if it is avaiable; 
 
649
otherwise, $f_s$ is used.
 
650
Since $f_s$ is a standard font, opening $f$ always succeeds.
 
651
Candidate fonts $g_1, g_2, ...$ can be a fonts of different font classes;
 
652
for instance, $g_1$ can be a TrueType font and $g_2$ can be a PCF font. 
 
653
 
 
654
 
 
655
 
 
656
%%%-----------------------------------------------------------------------
 
657
 
 
658
\section{Sample Programs}
 
659
\label{SEC:SamplePrograms}
 
660
 
 
661
\VFlib\ is distributed with sample programs.  
 
662
One of them is a previewer for DVI files.  
 
663
In a DVI interpreter, a \TeX\ font is opened
 
664
by the following sequence.
 
665
 
 
666
\begin{figure}
 
667
\begin{center}
 
668
%\mbox{\includegraphics[scale=1.2]{xmdvi-image-rgb.eps}}
 
669
%\mbox{\includegraphics[scale=1.2]{xmdvi-image-gray.eps}}
 
670
\mbox{\includegraphics[scale=1.2]{xmdvi-image-bw.eps}}
 
671
\end{center}
 
672
\caption{A DVI file previewer \pkg{xmdvi}}
 
673
\label{FIG:Xmdvi}
 
674
\end{figure}
 
675
 
 
676
\begin{verbatim}
 
677
   sprintf(f_name, "%s.pk", name);
 
678
   fid = VF_OpenFont1(f_name, h_dpi, v_dpi, -1, mag, mag);
 
679
\end{verbatim}
 
680
 
 
681
The variable \prog{name} is a font name as appearing in a DVI file
 
682
(e.g., \prog{cmr10}); \prog{h\_dpi} and \prog{v\_dpi} are the
 
683
horizontal and vertical device resolution of the target device in dpi,
 
684
respectively.  The variable \prog{mag} is a magnification factor.  The
 
685
PK font driver finds an appropriate font file from parameters given in
 
686
\prog{VF\_OpenFont1()} and the default values given in \prog{TeX} 
 
687
entry in \vflibcap. For instance, if the font
 
688
name is \prog{cmr10.pk} and \prog{h\_dpi} = \prog{v\_dpi} = 300, and
 
689
\prog{mag} = 1.2, the PK font driver looks for the font file
 
690
\prog{cmr10.360pk}.  Glyphs are simply obtained by calling the
 
691
\prog{VF\_GetBitmap1()} function.
 
692
 
 
693
Figure \ref{FIG:Xmdvi} shows a screen shot of a sample previewer on
 
694
X~Window using Motif.  This previewer supports drawing EPS figures and
 
695
color changes.
 
696
 
 
697
 
 
698
%%%-----------------------------------------------------------------------
 
699
 
 
700
\section{Conclusion}
 
701
\label{SEC:Conclusion}
 
702
 
 
703
In this paper, we have introduced a font library \VFlib\ which
 
704
supports multiple font formats with a unified API.  
 
705
It is especially useful for DVI drivers.
 
706
 
 
707
\VFlib\ has been tested on 
 
708
FreeBSD 2.2.2 and Linux for Pentimun, 
 
709
Solaris 2.5.1 and SunOS 4.1.4 for SPARC, and
 
710
SunOS 4.1 for SPARC; 
 
711
there is no difficulty to port it to other Unix-like operating systems.  
 
712
The source code and the latest information on \VFlib\ 
 
713
is available at 
 
714
|http://|""|www.|""|se.|""|hiroshima-u.|""|ac.|""|jp/|"%
 
715
"|~kakugawa/|""|VFlib/|.
 
716
 
 
717
 
 
718
%%%-----------------------------------------------------------------------
 
719
\section*{Acknowledgements}
 
720
The author would like to thank Werner Lemberg for helpful comments 
 
721
on specification and implementation of \VFlib.
 
722
He also thank Ken'ich Handa and Satoru Tomura for 
 
723
valuable discussions.
 
724
 
 
725
 
 
726
%%%-----------------------------------------------------------------------
 
727
 
 
728
\bibliographystyle{plain}
 
729
\bibliography{vflib35}
 
730
\nocite{*}
 
731
 
 
732
 
 
733
%%%-----------------------------------------------------------------------
 
734
 
 
735
\end{document}
 
736
 
 
737
%%%EOF