Re: [css3-fonts][css-text-decor] Decorating superscripts/subscripts

fantasai wrote:

> The CSS3 Fonts module offers a 'font-variant-position' property as
> an improved substitute for superscripts and subscripts. The goal is,
> I hope, that going forward, authors would use this mechanism to
> produce "real" superscripts and subscripts, using correctly-adjusted
> glyphs from the font rather than manually synthesizing them by means
> of 'vertical-align' and 'font-size' adjustments.

This 'font-variant-position' property [1] is not a replacement for the
existing subscript/superscript mechanism in HTML which uses a
combination of 'font-size' and 'vertical-align' to render elements in
superscripts and subscripts.

We discussed this in great detail in the past and actually resolved on
this at the Hamburg F2F [2]:

> - RESOLVED: the 'font-variant-position' property is defined independent
>             of the existing use of the font-size/vertical-align properties
>             to synthesize subscripts/superscripts

The use of variant glyphs for superscripts and subscripts doesn't
allow for nested superscripts and subscripts, nor does it allow for
images or other elements included in the superscript or subscript
content.  It's use is limited to simple, typographic superscripts and
subscripts that match the surrounding text.

> There's a problem with this however, which is that, since it's now
> just done by glyph substitution, the text-decoration code doesn't
> know about it, and can't draw underlines, strike-throughs, or
> overlines correctly.

I think you're misrepresenting "correct" behavior here.  If an author
underlines a section of text containing a superscript or subscript and
uses 'font-variant-position' to choose the appropriate variant glyphs,
the text will display close to the way it does today (modulo Webkit
text-decoration bugs):

Testcase:
http://people.mozilla.org/~jdaggett/tests/superscript-underline.html

Rendering in Firefox on OSX:
http://lists.w3.org/Archives/Public/www-archive/2013May/att-0025/superscript-underline.png

If an author wants to underline *just* the content in the superscript
or subscript span, the baseline for the variant glyphs is the same as
the surrounding text and the underline will appear at the same place
it does for surrounding text.  The same is true Unicode
superscript/subscript codepoints (U+2070:209C), they are treated as
glyphs with the same baseline as surrounding text (see Wikipedia for a
list of these [3]).  This is just a limitation of using variant
glyphs.

> So, somehow, we need to have a concept of the synthesized text's
> size and baseline, and be keying the decorations off of that.

We discussed why this isn't possible at the Hamburg F2F last year.  As
John Hudson was gracious enough to point out again, there aren't
really reliable metrics that can be used to infer the baseline of
variant superscript/subscript glyphs.  I posted a discussion of this
with examples [4] and at the F2F meeting we discussed these:

Comparing synthesized superscripts/subscripts to variants
http://people.mozilla.org/~jdaggett/tests/subsupermetrics.png

If an author wants to use subscripts and superscripts that best match
the surrounding content, the use of variant glyphs is ideal.  However,
if they want complicated presentation behavior then the existing model
of using font-size/vertical-align is a better choice.  For example, in
the Wikipedia case where superscripts are contained in square brackets
(e.g. [2]) and hovering over the link shows an underline, the existing
HTML model is a better choice, since most fonts don't provide
superscript variant glyphs for the square brackets anyways.

This feature addresses the needs of a specific, common set of use
cases.  I don't think we need to try and unify it with the approach
used in the past and the wording in the spec reflects that.

Regards,

John Daggett

[1] font-variant-position
http://dev.w3.org/csswg/css-fonts/#font-variant-position-prop

[2] Hamburg F2F discussion of superscript/subscript feature
http://lists.w3.org/Archives/Public/www-style/2012May/0530.html

[3] Wikipedia page on superscript/subscript variant codepoints in Unicode
http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

[4] discussion of differences between variant glyphs and HTML
http://lists.w3.org/Archives/Public/www-style/2012May/0369.html

Received on Tuesday, 14 May 2013 02:05:15 UTC