Re: font-size and accents, again

I wrote:
> 
> When a
> piece of text is centered vertically, it can be centered with respect to
> at least 3 distinct things:
> 
>   1. the font's em square
>   2. the font's bounding box (max ascent + max descent)
>   3. the text's vertical height

3. is not a good idea because the line box would end up getting
influenced by the particular pieces of text that happened to be in it,
as opposed to being influenced by the font being used. For example, if
one inline element had the text "IBM" and another inline element had the
text "ape", both in the same font, the inline box for "IBM" would be
higher than the inline box for "ape", thus enlarging the line box
unnecessarily.

1. is impossible to implement, as far as I can tell. Neither the Windows
API nor the TrueType file format appear to give us the info we need for
this. We would need to know where the baseline lies in the em square. X
doesn't give us this info either. The FONT_ASCENT apparently includes
some leading, since the spec says that it is the recommended line
spacing (together with FONT_DESCENT). Also, when you add these 2, you
often get a height larger than the PIXEL_SIZE field, which is more
closely related to the em square.

2. is the only one left. It does not suffer the same problem as 3, and
it can be implemented, at least on Windows (tmAscent and tmDescent) and
X (max_bounds.ascent and descent).

It is important to note, however, that this centering issue is separate
from the font size issue. When line-height is 1em, it is the height of
the em square, not the bounding box height.

Erik

Received on Tuesday, 30 November 1999 02:34:27 UTC