The Birth of a Virtual Font The AdjKerns Utility

Yannis Haralambous

1 Introduction

Making a baby can be a difficult process: you need at least two people (with the adequate tools) you need some favorable circumstances, and you need motivation.

What about virtual fonts? well, we have motivation enough: several languages are not covered by DC fonts, in particular Welsh, Esperanto, Maltese, many African languages (the glyphs for the latter are included in Joerg Knappens FC fonts) etc. These languages need virtual fonts to be typeset. The circumstances are favorable enough. Up to now, though, we were missing one tool.

Here is the problem: you want to substitute a character in the DC font by some special character you need in your target language. OK. How to construct the virtual representation for this character? well, for that we have Eberhard Mattes’ QDTeXVPL. It will give us the description of all characters we need. Now suppose you replace an ‘A’ with some accent, by an ‘E’ with some other accent. What about all the kerning pairs involving that ‘A’ you took away? And what all those new kerning pairs you need for the ‘E’?

Do you want to replace the old kerning pairs by new ones, by hand?? well, you can try; but if you ever attempt to take a coffee break, then you will never be able to recognize again what you have changed, and what remains to be changed. Not to mention the nasty habit of PL files of having kerning pairs applying to more than one characters. This optimizes parsing speed, but surely makes it more difficult to make manual changes.

The utility I’m presenting does all this automatically. It will read a [V]PL file and will

• remove all kerning pairs involving removed characters;

• introduce kernng pairs for new characters;

• add or remove ligatures.

To illustrate the use of this program, I provide a real-world example, namely a virtual font for Esperanto. You will follow the whole process of giving birth to this font, starting by its mother: the common dcr10 font.

2 How it works

AdjKerns has been written in ANSI C^{1}. It should run everywhere; it has been tested on a Macintosh (MPW 3.2 and Think C 5.0).

The command line should look like this:

AdjKerns [-c foo.kcf] [-o <something>] <input file>

The input file is a PL or a VPL file^{2}. Out of this file AdjKerns will read only the LIGTABLE, the rest will remain untouched.

The rules on how to modify the LIGTABLE are read from the configuration file foo.kcf. This file is optional; if you don’t include any rules, then AdjKerns will just rewrite your [V]PL file, by ignoring any optimization attempts of the LIGTABLE. The file will be bigger, but the result will be the same; it will be easier to modify, though.

The -o option specifies the output file. If no such is specified, then the input file is overwritten (you don’t need that file anyway…).

Let’s see now the syntax of the KCF file. The following lines are allowed:

KERN <char> LIKE <char>
KERN <char> LEFT LIKE <char>
KERN <char> RIGHT LIKE <char>
KERN <char> LEFT LIKE <char> RIGHT LIKE <char>
UNKERN <char>
ADD <lig> <char> <char> -> <char>
ADD <lig> BOUNDARYCHAR <char> -> <char>
REMOVE <lig> <char> <char> -> <char>
REMOVE <lig> BOUNDARYCHAR <char> -> <char>
% comments, like in TeX

where <char> means (like in a [V]PL file, either C followed by a character, or D followed by a decimal number, or O followed by an octal number, or H followed by a hexadecimal number. <lig> means one of the following: LIG, /LIG, LIG/,

/LIG/, /LIG>, LIG/>, /LIG/>, /LIG/>>.

Everytime you kern some letter, all previous kerning pairs and ligatures are erased. By the UNKERN command you can erase these, without inserting a new character. Commands are executed sequentially, and there is no consistence test; so you can ask something and then the opposite: nobody will complain.

1Be aware! its author is a lousy C programmer, so don’t trust the program as you trust TEX. Keep a critical eye for possible bugs, and report them!

2If you look closer you’ll see that there is no big difference; the latter has a few more possibilities, otherwise the syntax is the same.

3 An Example: Esperanto

Esperanto needs the following characters which are not provided in the DC font: ĉ, ŝ, ĵ, ĝ, ĥ, ŭ (and the corresponding uppercase letters). Dirk Everdeen which is an Esperanto guru (and has prepared a β version of Esperanto hyphenation patterns) asked me to use the following input mechanism: these letters should be accessed by ligatures cx, sx, jx, gx, hx, ux, because the letter ‘x’ is not used in Esperanto.

Since the “phantom” letter ‘x’ comes after the real letter, there is no problem with kerning (like in the case of the input ligature ts of the wncyr fonts). So this method could eventually be adopted as a standard transliteration of Esperanto. But this is another issue^{3}.

Our problem now is to create a virtual font with these letters, the right kerning pairs and the right ligatures. I have chosen positions which would harm the least amount of languages: only Turkish and Slovakian are excluded when using this virtual font.

How to call it? well, of course eocr10 since eo is the two-letter code for Esperanto.

3.1 First step: character description

How do we describe the accented characters? Let’s use Eberhard Mattes’ QDTeXVPL. For this we need a configuration file, which will specify the positions of new characters, and their descriptions in the form of TEX macros. Here is this file (let’s call it esperanto-wannabe.tex):

\font\f=dcr10
\input qdtexvpl
\texvpl{^^ad}{\f\^s}
\texvpl{^^8d}{\f\^S}
\texvpl{^^a0}{\f\^c}
\texvpl{^^80}{\f\^C}
\texvpl{^^a8}{\f\^h}
\texvpl{^^88}{\f\^H}
\texvpl{^^a9}{\f\^\j}
\texvpl{^^89}{\f\^J}
\texvpl{^^a7}{\f\^g}
\texvpl{^^87}{\f\^G}
\texvpl{^^b8}{\f\u u}
\texvpl{^^98}{\f\u U}
\bye

3To be solved by the Esperanto subgroup of the Technical Working Group on Multiple Language Coordination.

The good thing is that we can quickly describe the characters using TEX macros, like \^, \u, \j. The bad thing is that this is all we can do. Fine tuning must be done by hand.

You run this file through TEX and get file espernato-wannabe.dvi. Then you run QDTeXVPL with the followint command line:

QDTeXVPL -d10.0 esperanto-wannabe.dvi esperanto-wannabe.vpl

Here is an extract of what we get:

(MAPFONT D 16
    (FONTNAME dcr10)
    (FONTCHECKSUM O 30523766474)
    (FONTDSIZE R 10.000000))
(CHARACTER O 255
    (CHARWD R 0.394347)
    (CHARHT R 0.694275)
    (CHARDP R 0.000000)
    (MAP
        (MOVERIGHT R -0.052765)
        (SELECTFONT D 16)
        (SETCHAR O 2)
        (MOVERIGHT R -0.447113)
        (SETCHAR C s)))
(CHARACTER O 215
    (CHARWD R 0.555420)
    (CHARHT R 0.939255)
    (CHARDP R 0.000000)
    (MAP
        (PUSH)
        (MOVERIGHT R 0.027771)
        (MOVEDOWN R -0.244980)
        (SELECTFONT D 16)
        (SETCHAR O 2)
        (POP)
        (SETCHAR C S)))
..

Now we have to replace these characters inside dcr10.pl and name the new file eocr10.vpl (hopefully someday somebody will find the time to write some utility to do this automatically).

3.2 Second step: adjusting kerning pairs and ligatures

As you saw, we have modified character descriptions, but neither kerning pairs, nor ligatures. This will be done by AdjKerns. Here is the necessary configuration file eo.kcf:

% Kerning and ligature configuration for
% Esperanto virtual fonts, based on DC
% Semi-official (not yet aproved by TWGMLC)
KERN H AD LIKE C s
KERN H 8D LIKE C S
KERN H A0 LIKE C c
KERN H 80 LIKE C C
KERN H A8 LIKE C h
KERN H 88 LIKE C H
KERN H A9 LIKE C j
KERN H 89 LIKE C J
KERN H A7 LIKE C g
KERN H 87 LIKE C G
KERN H B8 LIKE C u
KERN H 98 LIKE C U
ADD LIG C s C x -> H AD
ADD LIG C S C x -> H 8D
ADD LIG C S C X -> H 8D
ADD LIG C c C x -> H A0
ADD LIG C C C x -> H 80
ADD LIG C C C X -> H 80
ADD LIG C h C x -> H A8
ADD LIG C H C x -> H 88
ADD LIG C H C X -> H 88
ADD LIG C j C x -> H A9
ADD LIG C J C x -> H 89
ADD LIG C J C X -> H 89
ADD LIG C g C x -> H A7
ADD LIG C G C x -> H 87
ADD LIG C G C X -> H 87
ADD LIG C u C x -> H B8
ADD LIG C U C x -> H 98
ADD LIG C U C X -> H 98

Note that we have included ligatures both for ‘Cx’ and ‘CX’ etc.: the former will be used in text, the latter in titles. Now we run AdjKerns, with the following command line:

AdjKerns -c eo.kcf eocr10.vpl

After some lines:

**************************************************************

     This is program AdjKerns (= Adjust Kerning Pairs)
                      Version beta-1
         written for you by a lousy C programmer
               (Yannis Haralambous, 1993)
      It shall help you make efficient virtual fonts
        This software belongs to the public domain
**************************************************************
Loading input file preamble...
Reading kern and ligature data...
Reading lines from configuration file and executing them...
.............................
Finished reading the configuration file
Writing down new lig/kern data...
Writing input file remaining data...

we get the expected result (our file eocr10.vpl is overwritten.

3.3 Final step: using the font

Once we have the VPL file, we are done. Run VFtoVP and use the font. Here is a small text file to test the font (file eotest.tex):

\magnification=1200
\font\myfont=eocr10
\myfont
Berto staras antaux la vendejo. Sxi estas rigardanta la
montran fenestregon. Si vidas multajn obiektojn. En la
montra fenestrego trovigxas skatoloj kai faruno. Sub
klosxo kusxas fromagxo, kiu havas multajn truojn. Ankaux
botelojn sxi estas vidanta. La boteloj, kiujn sxi estas
rigardanta, estas egale grandaj. En la mezo de la
fenestrego pendas afisxo, sur kiu estas skribita la
frazo: ,,Cxi tie oni parolas Esperanton``. La pordo
de la vendejo estas malfermita. En la vendejo en angulo
oni vidas barelon kun haringoj. Haringoj estas fisxoj.
La fromagxa klosxo estas farita el vitro. La posedanto
de la vendejo nun estas vendanta fumajxojn kaj cindrujon
al sinjoro. Berto demandas la vendistinon, cxu cxokolado
kaj dolcxajxoj estas haveblaj. La vendistino neas tion.
Ankaux teo, kafo kaj rizo ne plu estas haveblaj. Vino

estas trinkajxo. Berto volas acxeti unue fromagxon kaj
due haringojn. La acxetita fromagxo kostas unu marko. Nun
sxi estas portanta la acxetitan hejmen.
\end

taken from a Esperanto reader my mother had at school (nice brown and thin ,,Nachkriegspapier“).

4 Go forth, etc. etc.

I am tempted to say “Go forth and make masterpieces of virtual fonts”, but I have a small request: if you wish to make fonts for languages (Welsh, Maltese, etc.) please contact the Technical Working Group on Multiple Language Coordination first; it might very well be that somebody is already preparing this language; and if not, you may be that person. But in any case, we can share our experiences to make consistent and compatible TEX Language Packages.

5 Availability

You will find all the mentionned files, as well as the sources (and Macintosh-

executables) of AdjKerns on spi.ens.fr, directories /pub/tex/yannis/adjkerns
and /pub/tex/yannis/adjkerns/examples. QDTeXVPL can be found in Stuttgart,
directory /soft/tex/fonts/utilities/qdtexvpl.

A TEX Language Package for Esperanto is prepared by the TWGMLC (Technical Working Group on Multiple Language Coordination).