-
Notifications
You must be signed in to change notification settings - Fork 672
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
[css-fonts-4] Managing the scaling of font-size within MathML rendering #5389
Comments
We'd implemented the original Only one suggestion really - would it be an idea to reset the internal script-level to 0 if the font-size is specified as anything other than a I ask because, as specified, "the internal scriptlevel is 0 on the root element" - that's the root element of the document, not of the math equation? If so, then my issue is that I can't reset the internal script level and change the font-size at the same time. And I don't see anything that limits the use of this to MathML element only. <html style="font-size: 16px"> <!-- root element. script-level starts at 0 -->
<div style="font-size: scriptlevel(1)">
This text is 11.36px
<div style="font-size: 16px">
This text is 16px again, because the font-size was specified as a length, not a `scriptlevel()` function.
<math>
<mtext>This is still 16px</mtext>
<munderover> <!-- user-agent stylesheet increments script-level of 2nd and 3rd children -->
<mo>∏</mo>
<mi>a</mi> <!-- I'd expected 11.36px, but it's actually 8px because scriptlevel is 2, not 1 -->
<mi>b</mi>
</munderover>
</math>
</div>
</div>
</html> I could get around this by adding It's obviously not very likely, but having a property like internal-script-level that isn't visible to the user, that inherits all the way through the node hierarchy and that can't be reset without also resetting another property feels a little sketchy. The above would be a real pig for an author to debug. I don't know how often a fixed font-size is used for internal elements in MathML - in our batch of testcases here, only once, within an In short, my only suggestion would be to
The combination shuold ensure that a Alternatively, specify that the internal script-level is reset to 0 on a |
@faceless2: Merging the scriptlevel property into font-size is known to cause these issues, it is not clear how to address them. This change was a tradeoff between the need of MathML and what integrates better into CSS, so let's see what the WG people say. The point I'm currently more concerned about after this merge is that fantasai said introducing an "internal property" like we implemented in chromium is a bad idea. However, I still don't know how to make this work for absolute changes of scriptlevel otherwise (incidentally this is not needed for relative changes, which are the only ones required in the default UA sheet). I already asked her by email so we'll wait for her explanation before commenting further. In any case my two cents:
|
If it's of interest, the test modifying |
Fwiw, I think my original concern was that the previous iteration of this feature--which used a separate property as the counter--depended on concepts that don't exist in CSS, like whether We could keep the depth counter as its own property, something like
Then for
Here's the side-effects of various options:
Option D: If you really want a declaration like I'll note that we're running into a similar need for a font-size scaling factor for drop caps, see #4988 ; it would be interesting to note what the similarities and differences are wrt expected behavior. (For example, in the drop caps case, we suspect that font-relative lengths should be unaffected by |
Thanks @fantasai ! MathML3 says that an explicit font-size overrides the effect of scriptlevel change, so that excludes option A, B-1 and C. Option B-2 looks more or less what MathML Core was trying to achieve in the orignal proposal. To make it work, MathML Core would only need to ensure font-size is set to math at least for the default UA stylesheet inheritance and when the scriptlevel attribute is used ; or maybe even on all MathML elements but the Additionally, using this explicit
to ensure the math-depth is 0 on the About option D, I don't think that's necessary for the MathML use case. The reason why I tried to incorporate it into font-size was to simplify the proposal to make it more easily acceptable to the CSSWG but if people are happy with a separate math-depth counter, I wouldn't add more complexity. |
Probably 'auto' should have a different, less-confusing name. Maybe 'auto-add'? 'auto-compact'? |
The CSS Working Group just discussed
The full IRC log of that discussion<astearns> topic: Managing the scaling of font-size within MathML rendering<astearns> github: https://github.com//issues/5389 <fantasai> s/inhertied/inherited 'math-shift'/ <fantasai> s/value/values 'normal' and 'compact'/ <bkardell_> faceless2: fwiw, I think what is there is workable for us, but I don't know how anyone else does it... my question was about how it inherits through elements that aren't math <fantasai> various options proposed in https://github.com//issues/5389#issuecomment-689965166 <bkardell_> fredw: fantasai has suggested several things at the end, I think they addressed the concerns you had with my initial proposal? <fantasai> fred explains why one seems better in https://github.com//issues/5389#issuecomment-689989000 <bkardell_> fredw: it seems, imo to resolve all the issues <bkardell_> faceless2: font-size inherit would probably resolve my worries, that's a good idea <bkardell_> fredw: the original proposal was to have this counter - it was based on what firefox implements... we tried to modify the proposal to make it simpler, but that just caused more issues. fantasai suggested these -- b2) seems good to me <emilio> q+ <bkardell_> fantasai: the problem with the original proposal was "if the font-size is not set explicitly" - which isn't a thing we can do. The proposal in the interim was things would be internal, but that causes the font-size property to be more complex than it is already which is bad. I think it makes more sense to keep the counter, and just have the font-size have a seperate keyword that just says "go look at that math-size value" <bkardell_> fantasai: math-depth: auto adds 1 if the size is cramped and not otherwise... <fantasai> probably should rename the 'auto' keyword <bkardell_> fredw: it's not cramped it's math-style - when math-style is compact, the counter is incremented by 1. This is used to cover fractions <bkardell_> fredw: if you check the example bkardell_ included at the beginning you can see the difference in them <bkardell_> NeilS: there is that one weird fraction rule <astearns> ack emilio <bkardell_> emilio: I don't love the proposed solution because it adds a prop on which font-size depends, which is bad because so many things ultimately depends on font-size. I think that adds another pass on style resolution <bkardell_> astearns: is it a second pass or just another check? <bkardell_> astearns: it's only extra stuff you have to do if it is non-zero <bkardell_> emilio: that might be doable... I will have to think about it... but it means that there is a state where you might have a wrong font size... I will have to think about it... <bkardell_> emilio: it may be true that we can fix up the font size... I need to double check <bkardell_> astearns: please double check because I agree that could be bad if it is hard <bkardell_> fantasai: the other solution was worse? <fantasai> s/was worse/is to keep the counter as part of the font-size property itself/ <bkardell_> emilio: I will have to go and check what ff does <fantasai> s/itself/itself, are you thinking that's better??/ <bkardell_> emilio: we fix up the font size after the fact, right? <bkardell_> fredw: I think the issue in gecko was we were supporting the min font size <bkardell_> emilio: it might not be such a big issue as I thought it was <bkardell_> fantasai: it should have no dependency on anything but itself <bkardell_> emilio: ok, I am not very concerned then <fantasai> oh, and I guess also dependency on 'math-style'... <bkardell_> emilio: I will double check it, but I dont think we should block on resolving this actually... I like it better <bkardell_> proposed: add a math keyword to font-size which refers to the new math-depth property to get the scaling factor, which acts as a depth counter as described in the issue. <bkardell_> fredw: it is not like this in any browser, but it isn't too hard to align them on this <bkardell_> astearns: Let's resolve to get this in a spec and file separate issues on smaller things like 'should we rename the auto value'? <fredw> this was where min-font-size was removed: https://github.com//issues/3739 <bkardell_> RESOLVED to spec out the a math keyword to font-size which refers to the new math-depth property to get the scaling factor, which acts as a depth counter as described in the issue 2b, and open smaller issues for other things |
The proposal has been updated to use option B-2: |
This imports the proposal from MathML Core to manage font scaling in math formulas using a new 'math-level' property. This mechanism involves a new 'math-style' property that describes compactness of formulas as well as a new 'math' keyword to specify relative font-size change using the a scale factor calculated from the 'math-level' changes. w3c#5389 w3c#5387
Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389
Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389
Experimental font-size: scriptlevel(...) syntax was implemented in [1]. This CL updates it to match what was agreed with the CSSWG [2] as well as new WPT tests [3]: - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add This CL also updates the MathML UA stylesheet to use the new syntax. To compute font-size, one need the inherited math-style and the inherited/computed math-depth. So math-style does not need to be High priority. Additionally Blink computes the High priority alphabetically, so math-depth must be handled specially. [1] https://chromium-review.googlesource.com/c/chromium/src/+/2184131 [2] w3c/csswg-drafts#5389 [3] web-platform-tests/wpt#25694 Bug: 6606, 1023292 Change-Id: I8a5bf245fa6158633261ed167800fc5feb0c3564 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423843 Commit-Queue: Frédéric Wang <[email protected]> Reviewed-by: Rune Lillesveen <[email protected]> Reviewed-by: Rob Buis <[email protected]> Cr-Commit-Position: refs/heads/master@{#810610}
… syntax, a=testonly Automatic update from web-platform-tests Update math-level depth to match the new syntax (#25694) Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389 -- wpt-commits: 9614b05463a96ce2cd496dc322ea558c3a3c7909 wpt-pr: 25694
… syntax, a=testonly Automatic update from web-platform-tests Update math-level depth to match the new syntax (#25694) Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389 -- wpt-commits: 9614b05463a96ce2cd496dc322ea558c3a3c7909 wpt-pr: 25694 UltraBlame original commit: d32ea8a9512bde0359e35f69fe08d3d8d89f79dd
… syntax, a=testonly Automatic update from web-platform-tests Update math-level depth to match the new syntax (#25694) Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389 -- wpt-commits: 9614b05463a96ce2cd496dc322ea558c3a3c7909 wpt-pr: 25694 UltraBlame original commit: d32ea8a9512bde0359e35f69fe08d3d8d89f79dd
… syntax, a=testonly Automatic update from web-platform-tests Update math-level depth to match the new syntax (#25694) Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389 -- wpt-commits: 9614b05463a96ce2cd496dc322ea558c3a3c7909 wpt-pr: 25694 UltraBlame original commit: d32ea8a9512bde0359e35f69fe08d3d8d89f79dd
… syntax, a=testonly Automatic update from web-platform-tests Update math-level depth to match the new syntax (#25694) Discussed with the CSSWG at [1]. Syntax changes are - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add The old tests math-script-level-001 and math-script-level-003 are restored and adjusted to check the computed math-level in various situations and that the math-level does not have any effect when the specified font-size is not 'math'. [1] w3c/csswg-drafts#5389 -- wpt-commits: 9614b05463a96ce2cd496dc322ea558c3a3c7909 wpt-pr: 25694
Is the new |
@fred-wang @bkardell |
Ah okay the proposed |
@svgeesus: Sorry for missing your ping, I've been very busy with non-spec work in the past months. That's a good question and it has also been confusing for me because I initially thought the idea was to add the new properties to the relevant CSS specs but @fantasai suggested to keep stuff in the MathML Core spec when I sent the PR #5536 (comment) Anyway, I don't have strong preference on my side, I'm fine with "patching" the CSS spec in MathML Core for now. Since you already submitted 09efeb0 I can simplify that part in the MathML Core spec, though. Thanks! |
Experimental font-size: scriptlevel(...) syntax was implemented in [1]. This CL updates it to match what was agreed with the CSSWG [2] as well as new WPT tests [3]: - Split scriptlevel(...) into math-depth: ... and font-size: math. - Rename auto to auto-add This CL also updates the MathML UA stylesheet to use the new syntax. To compute font-size, one need the inherited math-style and the inherited/computed math-depth. So math-style does not need to be High priority. Additionally Blink computes the High priority alphabetically, so math-depth must be handled specially. [1] https://chromium-review.googlesource.com/c/chromium/src/+/2184131 [2] w3c/csswg-drafts#5389 [3] web-platform-tests/wpt#25694 Bug: 6606, 1023292 Change-Id: I8a5bf245fa6158633261ed167800fc5feb0c3564 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423843 Commit-Queue: Frédéric Wang <[email protected]> Reviewed-by: Rune Lillesveen <[email protected]> Reviewed-by: Rob Buis <[email protected]> Cr-Commit-Position: refs/heads/master@{#810610} GitOrigin-RevId: 0feb1d195c8a413c53e808ed95df7e1b78089703
(Part of #5384 - MathML Core related CSS)
Note: We're very interested in CSSWG feedback on this - it has already changed once based on feedback and tests updated, etc - and there has been some additional feedback that perhsaps this should be a single value instead which indicates that perhaps it should consult another (new property). We're ivery nterested to nail this one down better.
Script levels in MathML are about managing the font-size in subexpressions (like scripts and fractions). This example illustrates and describes some of the concepts/implications. The method for doing this is not quite as simple as inheriting, so the MathML-Core spec introduces a new
scriptlevel()
function (See example in the MathML Core spec )Depending on context (exponents, fractions, etc) and particulars of rendering style (compact/inline), the font-size of of parts of expressions scale down at different and fairly well established rates - for example, the scaling factor adjustment of a superscript is not the same as that of a root's prescript. The example below shows several contextual scaling variations.
The common rules derive from TexBook, but they are subtle and deserve to be exposed for tweaking and extension by authors. To this end, MathML adds a new
scriptlevel
function for CSS Fonts Module Level 4 which allows authors to express that the value should be automatically derived (default), or explicitly set to a specific level or that it should be the current level + some integer with rules defined in section 4.5 of the specTests in https://github.com/web-platform-tests/wpt/tree/master/css/css-fonts/math-script-level-and-math-style
The text was updated successfully, but these errors were encountered: