# setting kerning for a glyph and a ligature

How can one specify in PL-file the kerning for a glyph and a ligature (say, digit and en-dash) except for setting it for the first part of the ligature (which I would like to avoid)?

• I don't think it's possible to have separate kerning for `0`/hyphen and `0`/en-dash unless you input the en-dash directly as `\char...` (masked by a macro, of course). – egreg Sep 15 '14 at 13:28
• @egreg Are you sure? The reason I ask is that if you construct a ligature from existing glyphs, you copy the kerning from the originals to ensure correct kerning on each side. So if I'm constructing `fi`, I'd copy the left kerning pairs from `f` and the right kerning pairs from `i`. If it wasn't possible for the kerning to be different, there couldn't be any need to do this, could there? For example, `latin.mtx` includes `\setleftkerning{ffi}{f}{1000}` and `\setrightkerning{ffi}{i}{1000}` to get the kerning of `ffi` with other characters right. – cfr Sep 15 '14 at 14:43
• Why is this tagged `dvips`, by the way? It is in no way specific to that but is relevant to all cases where standard TeX fonts are used, including pdfTeX etc. – cfr Sep 15 '14 at 14:52
• I tried adding `(LABEL C 0)(KRN O 174 R 2)(STOP)` to the ligatures of `cmr12`; then `0-`, `0--` and `0---` show no kerning; if I change `174` in `55`, the kern is added to all three instances. Note: I used `cmr12` because `cmr10` is preloaded, so a new TFM is not read in. – egreg Sep 15 '14 at 15:02
• @cfr The TeXbook, of course; `cmr10` is on page 427. But also `pdflatex nfssfont` can be handy: you interactively set the font you want the table of. Type `cmr10` at the first prompt and `\table\bye` at the second one. The commands are the same as described in the METAFONTbook for `testfont.tex`, but with `nfssfont` you can also call a font by LaTeX attributes: just hit return at the first prompt instead of supplying a TFM name and you'll be presented with questions for encoding, family, weight, shape and size. – egreg Sep 15 '14 at 21:57

My experiment, described below, seems to prove that this is impossible. When TeX finds the cluster of characters

``````abc
``````

(where `abc` represents any three characters) it looks whether a kerning pair or ligature for `ab` is defined and, in this case it inserts the kern or makes the ligature. If the ligaturing mechanism has substituted `d` to `ab`, a kern or ligature between `d` and `c` is tried; otherwise the pair `bc` is considered.

Here's the description of the experiment.

1. I converted `cmr12.tfm` to `cmr12.pl` with `tftopl`.

2. I added the lines

``````(LABEL C 0)
(KRN O 174 R 2)
(STOP)
``````

to the `LIGTABLE` property, which should define a kerning pair between `0` and the em-dash and ran `pltotf`.

3. I ran TeX on the test file

``````\font\x=cmr12 \x % load the modified font metric file
0-\par
0--\par
0---\par
\bye
``````

and no kern showed up.

4. I changed the lines above in the `cmr12.pl` file into

``````(LABEL C 0)
(KRN O 55 R 2)
(STOP)
``````

(octal 55 is the slot for the hyphen), converted again to a `.tfm` file and ran again TeX on the test file above; in this case the kern showed up on all three lines.

The situation after a ligature is different and, indeed, `cmr12.pl` shows the same kerning pairs for `f` and octal 13 (ligature `ff`), to wit

``````   (LABEL C f)
(LIG C i O 14)
(LIG C f O 13)
(LIG C l O 15)
(KRN O 47 R 0.069734)
(KRN O 77 R 0.069734)
(KRN O 41 R 0.069734)
(KRN O 51 R 0.069734)
(KRN O 135 R 0.069734)
(STOP)
(LABEL O 13)
(LIG C i O 16)
(LIG C l O 17)
(KRN O 47 R 0.069734)
(KRN O 77 R 0.069734)
(KRN O 41 R 0.069734)
(KRN O 51 R 0.069734)
(KRN O 135 R 0.069734)
(STOP)
``````

which confirms my preliminary analysis.

Of course a kerning pair between 0 and the en-dash can be specified, but it will come into action only if

``````0\char'173
``````

is input (maybe via direct input of the en-dash with a mechanism similar to what `inputenc` does for LaTeX).