Re: Line layout in browsers

On Wed, Jan 23, 2008 at 01:09:03AM -0800, David Perrell wrote:
> 
> Hello, all.
> 
> Thanks to this thread I believe I understand the overlapping SPAN. But I'm
> curious regarding the source for a couple of contentions.
> 
> | ...the default value of "normal" for line-
> | height results in the browser using the line height that is built into
> | the font itself.
> 
> How is the line-height built into the font? There is no line-height, per se,
> in PostScript font metrics*. It's my impression from a cursory reading that
> the TrueType metrics are similar.

I think you get a line gap value in the "hhea table". Some information
here: http://typophile.com/node/13081.

But it may be a bit hit-and-miss exactly what information you get in
any particular font. I don't know all the details.

[...]
> ALSO, I'm still curious regarding the logic behind the vertical positioning
> of text within line boxes. I set up a series of DIVs with 100px font size
> and >= line heights (http://www.hpaa.com/css2/span.htm) and found that text
> is too low relative to the box in both FF and Opera on Win2K. CSS 2.1,
> section 10.8.1 states: "User agents center glyphs vertically in an inline
> box..." That is clearly not the case here.

I think they actually must mean "in a line box" there, since they're
talking about centering things with half-leading.

The height of an inline box depends on the font in some not completely
specified way (see 10.6.1). Inline box height is not equal to
line-height, and therefore nothing is centered within inline boxes with
leading. Therefore I take it from the context they mean "line box".

Either that or I'm misunderstanding something.

Now I would have thought that if you set line-height and font-size both
to 100px, as you do in the first of your examples, then the lowest
descender and the highest ascender should correspond exactly to the
bottom and top of the line box respectively.

Increase line-height and you increase leading (leading = line-height -
font-size), and the leading goes half-above and half-below, so the
midpoint between max ascent and max descent should remain centered in the
line box.

But this isn't always what you see. I suspect the reason may be that not
all fonts' _actual_ max ascent and descent are the same as the ones they
state (in their "hhea" etc. tables).

-- 
Ben Cotterell
Senior Software Engineer, ANT Software Limited

Received on Thursday, 24 January 2008 15:27:35 UTC