[Fontinst] Adjusting kerning information before reglyphing

Lars Hellström lars.hellstrom at residenset.net
Tue Jul 26 19:44:23 CEST 2005

At 16.40 +0200 2005-07-26, Stephen Hartke wrote:
>Here's what kern mtx file looks like:
>In FontForge, I created new characters (an upright, non-italicized
>circumflex in the italics font, and one that is raised above capital
>letters) so that I can visually see exactly how the math accents
>should be placed.  To calculate the kern in fontinst, I need to know
>the left character, the width of the left character, the kern between
>the left character and the temp skewchar, and the left and right
>bounding box info for the temp skewchar.  I had tried earlier just
>passing the temp skewchar name, but it's easy to define two variables
>to have the numeric data. However, finding the left character width is
>a little more challenging.

Yes, that's the trickiest part. If one wants to do the calculations after
reglyphing, one needs to translate the glyph name in several places. If one
wants to do the calculations at reglyphing, one needs to make this
information available.

>The inputted file kernmathaccentsomldata.tex contains more lines just
>like the three above its input command. I did this to keep the data
>file generated by my bash script separate from the hand-written macros
>in the kerning mtx file.

A wise precausion.

>%  parameters: character, kern, skewchar bbleft, skewchar bbright
>  \setkern{#1}{tie}
>  {
>    \add

Here is one problem. Under the \reglyphfont redefinition of \setkern, the
last argument is not treated as an integer expression but as a string
expression, which means \add and friends don't work. The
\resetint{temp}{...} and \strint{temp} in my second example is a
work-around for this.

>    {
>      #2 %\kerning{#1}{\skewchar}
>    }
>    {
>      \half
>      {
>        \add
>        {
>          \sub
>          {
>            \width{#1}

Here's the other problem: \width tries to access metric information for the
glyph, so we need to make sure that is available. (Otherwise the errors can
indeed be cryptic.) The easiest way to ensure this is probably to \inputmtx
the raw font at some suitable place before the \reglyphfont, as follows:

  % \renameglyph commands, etc.
  \inputmtx{<reencoded base font>}
  \reglyphfont{<reglyphed kern data>}{<kern data file>}

You may even find it convenient to place the definition of \fixaccentkern
in the \reglyphfonts--\endreglyphfonts block, so that the <kern data
file>.mtx file can be reduced to precisely the metric data (plus the MTX
file header and footer).

Lars Hellström

More information about the fontinst mailing list