What is VFlib?

We have many font files and many different font file formats are available. When we need a software to display or print characters which does not depend on a windowing system and/or an operating system, we must write interface routines for accessing font files in each application software again and again. To do this, programmers must have knowledge on font file formats; it will be a hard task for programmers if the number of font formats that an application software supports becomes large.

VFlib is a font library written in C providing several functions to obtain bitmaps of characters. VFlib hides the font format of font files and provides a unified API for all supported font formats. Thus, programmers for application software need not have knowledge on font file formats. Instead, any software using VFlib can support various font file formats immediately.

As described above, VFlib supports many font file formats and absorbs differences between font file formats. Currently, VFlib supports the following font file formats: PCF, BDF, HBF, TrueType, Type1, GF, PK, Virtual fonts, TFM, SyotaiKurabu (a vector font format for Japanese Kanji), JG (another vector font format for Japanese Kanji).

The internal structure of VFlib is as follows:

[Image: Internal Structure of VFlib]

The VFlib system consists of two parts:

A library (libVFlib.a and/or libVFlib.so)
It provides several C functions. Any application software using VFlib must link this library. VFlib uses kpathsea, FreeType, and T1Lib libraries. Application software linked with VFlib must be linked with these external libraries.
A font database file (vflibcap)
When we open a font, information about the font file (font format, location, possibly necessary glyph modifications etc.) is necessary. This file describes such information; it is read when the initialization function of VFlib is called.

We can obtain bitmaps of a font by the following procedure:

VF_Init("/usr/local/share/VFlib/vflibcap", NULL);
--- Initialization of VFlib.
fid = VF_OpenFont1("cmr10.pk", dpi_h, dpi_v, -1, mag_h, mag_v);
--- Open a font and obtain a font ID. Parameters are revice resolution, point size, and magnification factor.
bm = VF_GetBitmap1(fid, code_point, mag_h, mag_y);
--- Obtain a bitmap of a given font ID.
A font database file vflibcap defines a relation of logical font name (i.e., cmr10.pk) and its concrete definition. By a vflibpca, cmr10.pk can be a font file from a PK font file cmr10.300pk. It can be a Type 1 font cmr10.pfb by another vflibcap definition. VFlib is implemented to provide unified view for different font formats; application software need not aware of the difference of font formats and uses different font formats tranceparently.