-
Notifications
You must be signed in to change notification settings - Fork 719
[css-inline-3] vertical-align: super and font metrics #5225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The metrics from the font are OS2 table values ySubscriptYOffset and ySuperscriptYOffset. They're ignored, and our testing notes have "Firefox uses 0.34em and -0.2em, Safari 0.333em and -0.2005em" Another possibility is to incorporate this into #4792 - you could have @font-face {
font-family: ...
superscript-position: auto;
subscript-position: from-font;
} where I can see you're working through a lot of font metrics issues at the moment, which is great - I think many of them could be solved by implementing #4792 (earlier comment on this issue by me was posted too soon due to fat fingers - I deleted it) |
So sounds like we have a few questions here with a few options each:
|
For what it's worth Gecko's layout code thinks it's asking for the font metrics, but the font code uses a constant. Note that that constant is separately used by the code that handles |
@dbaron ... that seems bad. I think font-variant-position should definitely be using the font metrics if they exist, since it's supposed to try to match against actual glyphs in the font. |
Blink uses almost similar values
|
@kojiishi 1 is what unit? :) |
CSS pixels. |
The CSS Working Group just discussed
The full IRC log of that discussion |
Suggestion based on the impl data above (thanks everyone!): Make the ratios be -1em/5 for subscripts and 1em/3 for superscripts. This will be a slight shift for all implementations, but should be pretty close. |
I suggest adding something like the following:
|
It feels like giving authors the ability to use font metrics for super/subscript position, without giving them the option to use font-metrics for super/subscript size, is solving only half the problem. OpenType has fields for both superscript and subscript size, so in theory they could differ. The only solution I can see for this is adding |
The CSS Working Group just discussed
The full IRC log of that discussion |
WebKit would be willing to try to use the parent font's metrics in WebKit (and see how it goes). |
I don't understand the resolution:
Ratios of what? font size? amount to raise/lower the line for sup/sub? Something else? |
0.2em was the amount to shift down for |
I agree with @faceless2:
I think we should revisit this resolution in light of #4792 |
https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/rendering/RootInlineBox.cpp#L1041 if (verticalAlign == VerticalAlign::Sub)
verticalPosition += fontSize / 5 + 1;
else if (verticalAlign == VerticalAlign::Super)
verticalPosition -= fontSize / 3 + 1;
Is the intention for this resolution to document what browsers are already doing, or was the intention of this resolution to cause browsers to change their behavior? |
@litherum a bit of both. It was observed that browsers were using hardcoded ratios, but slightly different ones. So documenting the use of a ratio, and have browsers change behavior to use the same ratio. |
I'd like to propose loosening the spec to allow for the |
@litherum if there’s a good reason for the |
Edits are in, so I want to close this issue. (Handling font metrics explicitly provided by CSS is a problem for the day after we actually spec that feature. Of course those should be honored, but they don't exist atm so I can't spec honoring them.) @litherum did you want to argue for standardizing the +1px? It's kinda weird, no? |
I don't want to argue for standardizing the |
@litherum would it work then to open a new issue with that request, outlining your reasons why? |
The "why" is just "it isn't necessary to change behavior here." We can't just go around changing the positioning of text just because it makes mathematical formulas simpler. |
@litherum We do try to improve interop, though, unless there's a reason to allow divergent behavior. So, why should we allow divergent behavior here, rather than all using the same formula? |
I think I’d flip that around. Does the flexibility to increase the formula by 1px break websites? Clearly not, because WebKit is an existence proof. |
I don’t agree with the flip. There are plenty of places where we choose a value/formula/algorithm to use, and only very reluctantly agree to variations because there are places where we are concerned it would break web content. In this case we agree there’s no concern about breaking web content, because everyone is using different formulas now. It’s an improvement to switch to a single formula. It’s less of an improvement if we allow the +1 variation, so that has to be justified. |
I'm not terribly enthusiastic about multiple variation either, but I don't see a huge issue on everyone aligning on 1em/3+1px, 1em/5+1px instead of 1em/3, 1em/5. Having a rationale for the +1px would be good, but even if there isn't really one, the fact that blink and safari are already both on the +1 version could be sufficient. Then among browsers it's only Firefox that needs to change (and it needed to change anyway). |
From a browser developer’s point of view, the flip is relevant. The CSSWG is proposing that browsers make a behavior change, and for what? Will it be a progression? I agree it would cause browsers to match each other more closely, but you have to remember that way more users use the same browser over time (multiple releases) than who use multiple browsers at the same time. And from an author’s point of view, they just asked “please make this text sup.” They didn’t specify an exact pixel offset. If superscript positions are 1px different in some browsers, does that break their content? Seems unlikely. So from a user’s point of view, the risks outweigh the benefits, and from an author’s point of view, they probably don’t care about this specific 1px difference in these specific formulas. I don’t agree that standardizing things just for standardization’s sake is the right thing to do in every case.
This would be a reasonable path forward. I can try to dig up the rationale for the +1px. |
We currently encourage UAs to use the parent font's metrics when positioning a superscript or subscript using
vertical-align
, but it doesn't seem like browser implementations, at least, do that. And I'm guessing making such a change would have noticeable Web-compat implications.Should we introduce additional keywords, like
font-super
/font-sub
or an additionaluse-font
keyword to allow for using font metrics?The text was updated successfully, but these errors were encountered: