# Re: bug in fontinst 1.801: duplicated kernings (was: ae fonts Q)

• To: Alan Jeffrey <ajeffrey@cs.depaul.edu>
• Subject: Re: bug in fontinst 1.801: duplicated kernings (was: ae fonts Q)
• From: Lars Hellström <Lars.Hellstrom@math.umu.se>
• Date: Tue, 29 Sep 1998 13:01:29 +0100 (MET)
• Cc: fontinst@cogs.susx.ac.uk

Alan Jeffrey wrote:
>Lars Hellström wrote:
>
>> I have written a modification of the relevant parts in fontinst which would
>> fix the "bug" you describe (as well as allow kerns to be changed after they
>> have been set), but I should update that before I could expect anyone else
>> to try to use it. It should work fine under v1.504, though.
>
>I thought of doing this the first time around (have a \setkern and a
>\resetkern) but decided against it on grounds of running time: perhaps I
>was wrong...  or perhaps I'm misremembering.  Do you have an idea of
>whether there's a run-time cost associated with your fix?

The basic idea behind my fix is to change the routines under \etxtovpl that
writes kerning and ligature instructions to the VPL file so that they write
at most one kerning or ligature instruction for each pair of characters,
namely the one which would end up first in the VPL file. Both \setkern and
\resetkern just add three tokens to the \l-GLYPH and \r-GLYPH macros, but
\setkern adds them at the end and \resetkern adds them at the beginning.
This means a \setkern will not contribute any material to VPL file unless
it is the very first one and a \resetkern will override any previous
\setkerns and \resetkerns.

It takes the same time to run as the present implementation, and uses the
same amount of token memory as the present implementation would do if there
are multiple \setkern commands, but it does use more memory on the save
stack since it needs to remember for which characters ligature/kerning
positions needed is exactly the number of ligatures+kerns in the longest
ligature-kerning program.

I did also consider the possibility to remove the relevant kerning
instructions from the \l-GLYPH and \r-GLYPH macros, but I found that to be
too slow for use in every \resetkern command. It does however seem
tolerable in cases where you want to remove the kerns in every glyph pair
$(a,b)$ such that $a \in A$ and $b \in B$, where $A$ and $B$ are sets of
glyphs ($A$ might for example be the set of letters A--Z and $B$ the set of
letters a--z), since it then seems to have running time $O\bigl( |A|+|B| \bigr)$ rather than $O\bigl( |A| \cdot |B| \bigr)$ as one might have
feared. :-)   I have implemented an \unsetkerns command which does this,
but I haven't tested it thoroughly yet. :-(

Lars Hellström