- From: Erik van der Poel <erik@netscape.com>
- Date: Tue, 30 Nov 1999 17:32:38 -0800
- To: www-style@w3.org
Erik van der Poel wrote: > > Erik van der Poel 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 > > 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. I asked about this on the www-font list: http://lists.w3.org/Archives/Public/www-font/1999OctDec/ It turns out that TrueType fonts are supposed to give the em square's ascent and descent values in the OS/2 table's sTypoAscender and sTypoDescender fields. Adobe's OpenType fonts apparently do this correctly, but I found that Times New Roman on Windows has ascent and descent values that don't add up to the units-per-em value. However, one piece of advice on www-font was to use those values to estimate the baseline position in the em square. Transformed and rounded values can also be found via GetOutlineTextMetrics. (The OS/2 table's exact numbers can be retrieved using GetFontData.) > 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. We can estimate the baseline position in the em square by looking at the FONT_ASCENT and FONT_DESCENT properties (i.e. using the ratio between them). So, we may be able to go for solution 1. However, implementations would then have to estimate where the baseline lies in the em square. It's not clear how accurate the TrueType sTypoAscender and sTypoDescender fields are in practice. We may be able to get the font vendors to correct their fonts in the long run. Also, plain English text may look optically centered with this solution, but I wonder about other languages that use accents in the upper area. I'm inclined to choose 2. Erik
Received on Tuesday, 30 November 1999 20:35:59 UTC