[Fontinst] character depth; maths accents

cfrees at imapmail.org cfrees at imapmail.org
Tue Aug 10 15:24:52 CEST 2010

On Mon 9th Aug, 2010 at 18:57, Lars Hellström seems to have written:

> Dr. Clea F. Rees skrev:
>> I'm trying to generate support files for a new maths font using
>> fontinst and I've run into the following problem. I can recreate the
>> problem using cmex10 so I don't think it is a font issue but, rather,
>> either a fontinst issue or a me issue.
>> Suppose I reencode cmex10:
>>     ...
>>     \transformfont{cmex10-omx}{\reencodefont{omx}{\fromafm{cmex10}}}
> Taking cm metrics from AFM files is usually to be asking for trouble: glyph 
> names may be off, bounding boxes need not yield the proper metrics, and so 
> on. May I however assume that you know this and are using \fromafm{cmex10} 
> only because it's what you'd have to do for the other font?
Yes. At least, I hadn't really thought about the general issue for cm
fonts but I was only doing this because it shadowed what I needed to do
for IrianisADFMath. I am not actually trying to take metrics from cm
AFMs in order to use them. I was just trying to understand what was
happening with Irianis.
>>     ...
>> and then install as follows:
>>     \installfont{cmex7v10}{cmex10-omx,mathex}{omx}{OMX}{cmex}{m}{n}{}
>>     ...
>> [Note: this will actually trigger many errors but simplifies what's
>> happening.]
>> Then for certain characters, I will get a very large negative depth
> From what you've written later, I conclude these characters are not the 
> delimiter characters (for which it is traditional to have large depths)... 
> And I should of course have understood that from the start, as the depths of 
> those are normally /positive/ (corresponding to a negative y-coordinate of 
> the bottom side of the bbox). Your situation is that the depths are 
> /negative/, which corresponds to a positive y-coordinate of the bottom side 
> of the bbox, as would indeed be expected for a straightforward accent.
>> which causes TeX to position maths accents incorrectly. For example an
>> excerpt from the vpl file:
>> (CHARACTER D 98 (COMMENT hatwide)
>>    (CHARWD R 0.555)
>>    (CHARHT R 0.744)
>>    (CHARDP R -0.562)
>>    (MAP
>>       (SETCHAR D 98) (COMMENT hatwide)
>>       )
>>    (NEXTLARGER D 99) (COMMENT hatwider)
>>    )
>> (CHARACTER D 99 (COMMENT hatwider)
>>    (CHARWD R 1.0)
>>    (CHARHT R 0.772)
>>    (CHARDP R -0.575)
>>    (MAP
>>       (SETCHAR D 99) (COMMENT hatwider)
>>       )
>>    (NEXTLARGER D 100) (COMMENT hatwidest)
>>    )
>> (CHARACTER D 100 (COMMENT hatwidest)
>>    (CHARWD R 1.444)
>>    (CHARHT R 0.772)
>>    (CHARDP R -0.575)
>>    (MAP
>>       (SETCHAR D 100) (COMMENT hatwidest)
>>       )
>>    )
>> The effect of this is to position the accents on the baseline. But
>> unfortunately, TeX expects the accents to be positioned correctly for a
>> letter of height x. The upshot is that accents end up in the middle of
>> letters.
> Well, that's actually a different matter; TeX uses a different method for 
> accent placement in math (just stack things in a vbox, with kerns to adjust 
> vertical position of accent to letter, but no \baselineskip or similar) than 
> in text, and the math method is sensitive to the depths of accent characters.
>> I see this for maths accents in oml.etx, omx.etx and msbm.etx, at
>> least. It doesn't occur for accents in ot1.etx even though these have
>> similar-looking bounding box statements in the afm files. For example,
>> hatwide, hatwider, hatwidest, tildewide, tildewider, tildewidest and
>> vector are definitely affected and probably tie, as well. But caron,
>> hat etc. are fine.
>> I have been trying to figure this out for a while. Karl Berry pointed
>> out the large negative depth I'm seeing in the tfm files for the new
>> font as opposed to the absence of such a depth in the tfm for cmex10.
>> That prompted me to experiment a little. I don't get the large negative
>> depth if I use afm2pl rather than fontinst
> This could be a matter of afm2pl not ever making the depth negative, but 
> that's just a guess.
>> but I'm not sure how to get
>> varchar and nextlarger etc. using that method. But I do get the issue
>> if I start with cmex10.afm and not just with the new font.
>> If anybody can cast any light on this, that would be great. Right now
>> I'm working on a work-around but it is not terribly elegant.
> Senare skrev Dr. Clea F. Rees:
>> A couple of days ago, I noted that fontinst causes problems with the
>> placement of maths-specific accents.
>> Is this because newlatin.mtx contains this:
>> \foreach(accent){grave,acute,circumflex,tilde,dieresis,hungarumlaut,%
>>       ring,caron,breve,macron,dotaccent}
>>    \ifisglyph{\str{accent}}\then
>>       \resetglyph{\str{accent}}
>>          \glyph{\str{accent}}{1000}
>>          \resetdepth{0}
>>       \endresetglyph
>>    \Fi
>> \endfor(accent)
>> but there is no similar code in mathit.mtx (for OML) or mathex.mtx (for
>> OMX) and no metrics file at all for MSBM?
> Precisely! latin.mtx/newlatin.mtx are used to generate OT1 fonts, which would 
> traditionally be the source of "basic" accents in math, so they these files 
> had to make them conform to this technical requirement. This dates back to 
> fontinst 1.314, 27 January 1994.
> From the list of changes, Alan doesn't seem to have done anything to 
> mathex.mtx after fontinst 1.305 (9 January 1994) however, and I've only done 
> some bugfixes (back in 2000). Hence it merely seems noone has gotten around 
> to fixing this yet! Code contributions are welcome.

I was wondering about just adding the code from newlatin.mtx to
mathit.mtx, mathex.mtx and some metrics file for msbm and altering this
list of accents appropriately but I wasn't sure if there might not be
some reason this shouldn't be done.

> A factor that might have been hiding it is that if you "copy" a glyph using 
> the idiom
>  \setglyph{new}
>     \glyph{old}{1000}
>  \endsetglyph
> then \depth{new} will be \max{\depth{old}}{0}; the same happens if you 
> similarly try to adjust the vertical position of the accent. It is only  for 
> raw glyphs that you might get a negative depth.

Interesting. vector is renamed in my set up using \renameglyph but that
obviously does not have the same effect.

>> This isn't a big deal for me because the font I've got puts the accents
>> (at least the wide ones) in the wrong place anyway (relative to TeX's
>> expectations, at least) - so even if fontinst did the right thing, the
>> metrics would still have to be corrected. But I thought it might be
>> helpful to add similar code to the metrics files for maths, if anybody
>> would be willing to do that.
>> Also, I would like to know whether I am aware of the list of maths
>> accents. At the moment, I am correcting depth for:
>> vector
>> tie [not sure whether I should be in this case or not]
> I don't think that is used as a math accent, so no, but OTOH it hardly hurts.
>> hatwide
>> hatwider
>> hatwidest
>> tildewide
>> tildewider
>> tildewidest
>> If anybody could confirm this list is complete (w/ or w/o tie) or tell
>> me if I've missed something, I would be very grateful.
> I suppose this is the kind of information for which one would consult the 
> relevant encoding specifications. Too bad several of those haven't been 
> written yet. :-(

Thanks very much for all your answers,

More information about the fontinst mailing list