w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.46k stars 657 forks source link

[css-values] baseline-position unit? #661

Open tbredin opened 7 years ago

tbredin commented 7 years ago

I've just found out about the ch and ex units described here: https://www.w3.org/TR/css3-values/#relative-lengths

Baseline position: (perhaps in a format like top: 1bpos for example) would give us information on the vertical position of the baseline relative to the top of the box model (without padding?) for a given font. This position varies a lot from one font to another

This is something that could become extremely useful in vertical rhythm projects such as Sassline and MegaType, which go to great length to attempt to find this position through other means. When combined with ex (and a speculative cap height), we also start to build up a very useful picture of a font's vertical metrics.

Is this something that might be considered in future? Further reading on some existing issues with typographic metrics on the web

upsuper commented 7 years ago

Relative to the top of its container? That is infeasible, because that would make its value depend on layout result, which would lead to cyclic dependency. It is possible, though, to get the baseline position based on the first font in font-family, but I guess that's not what you are looking for.

SelenIT commented 7 years ago

I suppose it would be useful to have access to ascent and descent metrics from the font (and cap height, too, if possible) as font-relative units. Combined with font-size and calc() function, this would enable better control over line box formation and aligning things with text (including, but not limited to, calculating the baseline position).

xfq commented 6 years ago

Related: Font Metrics API