Skip to content

Commit b06c3e9

Browse files
committed
Update script level proposals after yesterday's discussions.
1 parent 5f3b272 commit b06c3e9

2 files changed

+38
-57
lines changed

math-script-level-and-math-style-comments.md

+6-41
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,8 @@
22

33
## Script level increment in `munder`, `mover`, `munderover` scripts
44

5-
When these elements are really drawn as under/over scripts then the script
6-
level increment should not happen when `accentunder` or `accent` are specified:
7-
8-
<pre>
9-
munder[accentunder="false"] > :nth-child(2),
10-
mover[accent="false"] > :nth-child(2),
11-
munderover[accentunder="false"] > :nth-child(2),
12-
munderover[accent="false"] > :nth-child(3) {
13-
math-script-level: inherit;
14-
}
15-
</pre>
16-
17-
Unfortunately whether the elements are drawn with under/over scripts as well
18-
as the default values of the `accentunder` and `accent` attributes have to be
19-
determined from the MathML DOM and even using an
20-
[operator dictionary](https://www.w3.org/Math/draft-spec/appendixc.html).
21-
This is not possible to do in the CSS side. Maybe this feature could be removed
22-
from MathML and the authors should explicitly indicate whether they want
23-
to prevent increment in scriptlevel in this case.
24-
Gecko implements it via pseudo-element set in the layout code
25-
but that's [causing some issues](https://bugzilla.mozilla.org/show_bug.cgi?id=1361766).
5+
The current proposal does not handle the case when underover scripts are
6+
"accents". See [issue 76](https://github.com/mathml-refresh/mathml/issues/76).
267

278
## `scriptsizemultiplier` and `scriptminsize` attributes
289

@@ -32,14 +13,7 @@ approximately one over square root of 2) and ensure
3213
script level change cannot scale down `font-size` lower than a minimal value.
3314
This is implemented in Gecko but that [makes things very complex](https://dxr.mozilla.org/mozilla-central/source/servo/components/style/properties/gecko.mako.rs#2481).
3415

35-
It's not clear whether the `scriptsizemultiplier` and `scriptminsize` attributes
36-
are used a lot in practice so this MathML attributes could probably be removed.
37-
Additionally, taking into account `scriptminsize` (even the default value of
38-
8pt) means that for very deeply nested mathematical formulas, the `font-size`
39-
will stop being scaled down in scripts etc. It's not clear whether that's
40-
an important use case and whether that's better than reaching too small
41-
̀font-size`. There are user features (e.g. zoom-in) to workaround that kind
42-
of not frequent issues.
16+
We should probably [remove these attributes](https://github.com/mathml-refresh/mathml/issues/1#issuecomment-474261094) from MathML Core.
4317

4418
## OpenType MATH values: `scriptPercentScaleDown` and `scriptScriptPercentScaleDown`
4519

@@ -49,15 +23,6 @@ going from script level 0 to script level 1 (`scriptPercentScaleDown`) or 2
4923
`scriptsizemultiplier` is not really want, instead the one specified by the
5024
font designer should be used.
5125

52-
This proposal chose a simple solution as it's not clear whether reading the
53-
MATH table is a good idea or possible during the style resolution. Also
54-
`scriptPercentScaleDown` and `scriptScriptPercentScaleDown` are not implemented
55-
by any web engine right now ([Gecko bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1187682)). An algorithm could be:
56-
57-
* Use S = `scriptPercentScaleDown` when `math-script-level` goes from 0 to 1.
58-
* Use S = `scriptScriptPercentScaleDown` divided by `scriptPercentScaleDown` when `math-script-level` goes from 1 to 2.
59-
* Use S = 0.71 in other situation when `math-script-level` is incremented by 1.
60-
* Generalize to values of Δ other than +1 by using product and inversion.
61-
62-
with adjustments when specified scales are zero and deciding whether to ignore
63-
suggested values from the MATH table.
26+
Note that TeX or Microsoft Office ignore other script level changes, which would
27+
be equivalent to replacing 0.71 with 1 in the definition of S<sub>p,p+1</sub>.
28+
The current definition tries to preserve MathML's special behavior.

math-script-level-and-math-style-explainer.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on this proposal see
1212
## Examples
1313

1414
* `<div class="my-underover"><div>Base</div><div>Overscript</div><div>Underscript</div></div>`
15-
and `.my-underover > :not(:first-child) { math-script-level: add 1; }` would
15+
and `.my-underover > :not(:first-child) { math-script-level: add(1); }` would
1616
scale down the font size in under and over scripts.
1717

1818
* In the previous example, one could do
@@ -36,7 +36,7 @@ on this proposal see
3636
* Polyfills and native implementations can emulate MathML behavior such as
3737
`<mstyle displaystyle="true">...</mstyle>`,
3838
`<mstyle scriptlevel="2">...</mstyle>` or `<mstyle scriptlevel="+3">...</mstyle>` by mapping to `math-style: display`, `math-script-level: 2;` and
39-
`math-script-level: add 3;` respectively.
39+
`math-script-level: add(3);` respectively.
4040

4141
## Rationale
4242

@@ -139,7 +139,7 @@ such constraints into consideration.
139139
<table>
140140
<tbody>
141141
<tr><th>Name:</th><td>math-script-level'</td></tr>
142-
<tr><th>Value:</th><td>auto || add? &amp;&amp; &lt;integer&gt;</td></tr>
142+
<tr><th>Value:</th><td>auto | add(&lt;integer&gt;) | &lt;integer&gt;</td></tr>
143143
<tr><th>Initial:</th><td>inline</td></tr>
144144
<tr><th>Applies to:</th><td>All elements</td></tr>
145145
<tr><th>Inherited:</th><td>yes</td></tr>
@@ -160,27 +160,43 @@ value of `math-style` is 'inline' then the computed value of
160160
`math-script-level` is the inherited value plus one.
161161

162162
If the specified value of `math-script-level` is of the form
163-
'add &lt;integer&gt;' then
163+
'add(&lt;integer&gt;)' then
164164
the computed value of `math-script-level` is the inherited value
165165
plus the specified integer.
166166

167167
If the specified value of `math-script-level` is of the form '&lt;integer&gt;'
168-
then
169-
the computed value of `math-script-level` is set to the specified integer.
170-
171-
`math-script-level` affects the calculation of the computed value of
172-
`font-size`. If `font-size` is not specified, then it is obtained by
173-
multiplying the inherited value by S to the Δ power, where S is a scale factor
174-
set to 0.71 and Δ is the change of script level i.e.
175-
computed `math-script-level` minus inherited `math-script-level`.
168+
then the computed value of `math-script-level` is set to the specified integer.
169+
170+
If ̀font-size` is specified then `math-script-level` does not affect the
171+
computed value of ̀font-size`.
172+
Otherwise, if A is the inherited `math-script-level` and B the computed
173+
`math-script-level` then the computed value of `font-size`
174+
is obtained by multiplying the inherited value of ̀font-size` by the nonzero
175+
scale factor S<sub>A,B</sub>, defined recursively as follows:
176+
* S<sub>p,p</sub> = 1 for every integer p.
177+
* S<sub>0,1</sub> = `scriptPercentScaleDown` if a nonzero value is provided by
178+
the OpenType MATH table of the current font. Otherwise use the suggested
179+
default S<sub>0,1</sub> = 0.8.
180+
* S<sub>0,2</sub> = `scriptScriptPercentScaleDown` if a nonzero value is
181+
provided by the OpenType MATH table of the current font. Otherwise use the
182+
suggested default S<sub>0,1</sub> = 0.6.
183+
* S<sub>1,2</sub> = S<sub>0,2</sub> / S<sub>0,1</sub>.
184+
* S<sub>p,p+1</sub> = 0.71 for every integer p ≠ 0, 1.
185+
* S<sub>p,q</sub> is the product of S<sub>i,i+1</sub> where i ranges from p to
186+
q - 1 for every integers p, q such that q ≥ p + 2 and (p,q) ≠ (0,2).
187+
* S<sub>p,q</sub> = 1 / S<sub>p,q</sub> for every integers p, q such that
188+
q < p.
189+
190+
The clamping of `font-size` implied by ̀font-min-size` and `font-max-size` must
191+
apply after the change due to `math-script-level`.
176192

177193
### Native implementations of `display`, `displaystyle` and `scriptlevel`
178194

179195
The proposal allows to partially implement the `display`, `displaystyle` and
180196
`scriptlevel` attributes as follows:
181197

182-
* Map `scriptlevel="+U"` to 'math-script-level: add U' (where U is an [unsigned integer](https://www.w3.org/Math/draft-spec/chapter2.html#type.unsigned-integer)).
183-
* Map `scriptlevel="-U"` to 'math-script-level: add -U' (where U is an [unsigned integer](https://www.w3.org/Math/draft-spec/chapter2.html#type.unsigned-integer)).
198+
* Map `scriptlevel="+U"` to 'math-script-level: add(U)' (where U is an [unsigned integer](https://www.w3.org/Math/draft-spec/chapter2.html#type.unsigned-integer)).
199+
* Map `scriptlevel="-U"` to 'math-script-level: add(-U)' (where U is an [unsigned integer](https://www.w3.org/Math/draft-spec/chapter2.html#type.unsigned-integer)).
184200
* Map `scriptlevel="U"` to 'math-script-level: U' (where U is an [unsigned integer](https://www.w3.org/Math/draft-spec/chapter2.html#type.unsigned-integer)).
185201

186202
Then add rules equivalent to the following user agent stylesheet for MathML.
@@ -223,7 +239,7 @@ mfrac > * {
223239
math-style: inline;
224240
}
225241
mroot > :not(:first-child) {
226-
math-script-level: add 2;
242+
math-script-level: add(2);
227243
math-style: inline;
228244
}
229245
msub > :not(:first-child),
@@ -233,7 +249,7 @@ mmultiscripts > :not(:first-child),
233249
munder > :not(:first-child),
234250
mover > :not(:first-child),
235251
munderover > :not(:first-child) {
236-
math-script-level: add 1;
252+
math-script-level: add(1);
237253
math-style: inline;
238254
}
239255
</pre>

0 commit comments

Comments
 (0)