[Fontinst] Adjusting kerning information before reglyphing
Stephen Hartke
hartke at gmail.com
Tue Jul 26 16:40:51 CEST 2005
Lars,
On 7/26/05, Lars Hellström <lars.hellstrom at residenset.net> wrote:
> Hmm... we may get by with some hacking. The way fontinst reads files is
> always to \input them (which in the case of AFM and PL files means we need
> to play some pretty advanced redefinition tricks in order to fool TeX into
> usefully parsing these files, but that's a different matter). The file
> conversion commands work by redefining the few supported commands to write
> their data to the output file, whereas the "unsupported" commands just
> continue to work as they normally do. Since most commands by default just
> locally set data in internal tables, they don't seem to have any effect in
> these contexts, but they are executed and you may well use them to
> preprocess data for \setkern proper.
>
> Some examples:
>
> \setcommand\midadjust#1#2{\setkern{theskewchar}{#1}{#2}}
>
> will make \midadjust{a}{10} behave as if the file had said
> \setkern{theskewchar}{a}{10}.
>
> \setcommand\altmidadjust#1#2{
> \resetint{temp}{\sub{#2}{250}}
> \setkern{theskewchar}{#1}{\strint{temp}} % \int{temp} won't work.
> }
>
> will make \altmidadjust{a}{260} behave as if the file had said
> \setkern{theskewchar}{a}{10}.
>
> A lot depends on what processing you need to make, though. Could you give
> some concrete examples?
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.
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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\relax
\metrics
\setcommand\fixaccentkern#1#2#3#4%
% parameters: character, kern, skewchar bbleft, skewchar bbright
{
\setkern{#1}{tie}
{
\add
{
#2 %\kerning{#1}{\skewchar}
}
{
\half
{
\add
{
\sub
{
\width{#1}
}
{
\italic{#1}
}
}
{
\add
{
#3 %\bbleft{\skewchar}
}
{
#4 %\bbright{\skewchar}
}
}
}
}
}
}
\def\circumbbleft{94} \def\circumbbright{406}
\fixaccentkern{a}{-480}{\circumbbleft}{\circumbbright}
\fixaccentkern{c}{-440}{\circumbbleft}{\circumbbright}
%\input kernmathaccentsomldata.tex
\endmetrics
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This method works fine for the glyphs not renamed if I just include it
in the mtx list of installfont. However, it doesn't then work for the
glyphs that are renamed (which includes a fair number of normal
glyphs, such as a,f,i,l,u,v,w,x,Delta,Pi,Phi).
I also tried making a new mtx file that just inputmtx's the font data,
then inputmtx's the kern mtx. I then use this new file as the source
mtx file for reglyphing. This failed however.
The error messages by the way are completely cryptic. I can send you
directly all of the scripts and files if you want to actually run them
for yourself.
Thanks for your help!
Stephen
More information about the fontinst
mailing list