Skip to content

Commit 95ed0ea

Browse files
committed
Add support for RTL mirroring of operators
1 parent 0bfc043 commit 95ed0ea

File tree

1 file changed

+80
-24
lines changed

1 file changed

+80
-24
lines changed

spec.html

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,13 +1738,23 @@ <h4>Layout of operators</h4>
17381738
<a data-xref-type="css-property">color</a>
17391739
of the <code>&lt;mo&gt;</code> element.
17401740
</p>
1741+
<p>
1742+
Let <code>dir</code> be the element's computed
1743+
<a data-xref-type="css-property">direction</a>.
1744+
</p>
17411745
<p>Operators are laid out as follows:</p>
17421746
<ol class="algorithm">
17431747
<li>
17441748
If the content of the <code>&lt;mo&gt;</code> element is not
17451749
made
17461750
of a single character <code>c</code> then fall back to the
17471751
layout algorithm of <a href="#layout-of-mtext"></a>.
1752+
If it is not possible to <a>get a glyph</a> corresponding to
1753+
<code>c</code> given directionality <code>dir</code>, then
1754+
fall back to the layout algorithm of <a href="#layout-of-mtext"></a>.
1755+
Otherwise, let <code>g</code> be the result of running
1756+
<a>get a glyph</a> corresponding to <code>c</code>
1757+
given directionality <code>dir</code>.
17481758
</li>
17491759
<li>
17501760
If the operator has the [=embellished operator/stretchy=] property:
@@ -1754,10 +1764,8 @@ <h4>Layout of operators</h4>
17541764
<ol>
17551765
<li>
17561766
If it is not possible to <a>shape a stretchy glyph</a>
1757-
corresponding to <code>c</code> in the inline direction
1758-
with the
1759-
<a>first available font</a>
1760-
then fall back to the
1767+
<code>g</code> in the inline direction with the
1768+
<a>first available font</a> then fall back to the
17611769
layout algorithm of <a href="#layout-of-mtext"></a>.
17621770
</li>
17631771
<li>
@@ -1777,13 +1785,13 @@ <h4>Layout of operators</h4>
17771785
<li>
17781786
The <a>inline size</a> and (ink) block metrics of the math content
17791787
are given by algorithm to
1780-
<a>shape a stretchy glyph</a> to <a>inline dimension</a>
1781-
<code>T<sub>inline</sub></code>.
1788+
<a>shape a stretchy glyph</a> <code>g</code> to
1789+
<a>inline dimension</a> <code>T<sub>inline</sub></code>.
17821790
</li>
17831791
<li>
17841792
The painting of the operator is performed by the
17851793
algorithm
1786-
to <a>shape a stretchy glyph</a>
1794+
to <a>shape a stretchy glyph</a> <code>g</code>
17871795
stretched to <a>inline dimension</a>
17881796
<code>T<sub>inline</sub></code> and
17891797
at position determined by the previous box metrics.
@@ -1796,10 +1804,8 @@ <h4>Layout of operators</h4>
17961804
<ol>
17971805
<li>
17981806
If it is not possible to <a>shape a stretchy glyph</a>
1799-
corresponding to <code>c</code> in the block direction
1800-
with the
1801-
<a>first available font</a>
1802-
then fall back to the
1807+
<code>g</code> in the block direction with the
1808+
<a>first available font</a> then fall back to the
18031809
layout algorithm of <a href="#layout-of-mtext"></a>.
18041810
</li>
18051811
<li>
@@ -1862,7 +1868,7 @@ <h4>Layout of operators</h4>
18621868
Let <code>minsize</code> and <code>maxsize</code>
18631869
be the [=embellished operator/minsize=] and [=embellished operator/maxsize=] properties on the
18641870
operator. Percentage values are interpreted relative
1865-
to the height of the glyph for <code>c</code>.
1871+
to the height of <code>g</code>.
18661872
Let <code>T</code> =
18671873
<code>T<sub>ascent</sub></code> +
18681874
<code>T<sub>descent</sub></code> be the target size.
@@ -1920,7 +1926,7 @@ <h4>Layout of operators</h4>
19201926
<a>line-descent</a>
19211927
of the math content
19221928
are obtained by the algorithm to
1923-
<a>shape a stretchy glyph</a>
1929+
<a>shape a stretchy glyph</a> <code>g</code>
19241930
to <a>block dimension</a>
19251931
<code>T<sub>ascent</sub></code> +
19261932
<code>T<sub>descent</sub></code>.
@@ -1937,7 +1943,7 @@ <h4>Layout of operators</h4>
19371943
</li>
19381944
<li>
19391945
The painting of the operator is performed by the
1940-
algorithm to <a>shape a stretchy glyph</a>
1946+
algorithm to <a>shape a stretchy glyph</a> <code>g</code>
19411947
stretched to <a>block dimension</a>
19421948
<code>T<sub>ascent</sub></code> +
19431949
<code>T<sub>descent</sub></code>
@@ -1962,10 +1968,8 @@ <h4>Layout of operators</h4>
19621968
<ol>
19631969
<li>
19641970
If it is not possible to <a>shape a stretchy glyph</a>
1965-
corresponding to <code>c</code> in the block direction
1966-
with the
1967-
<a>first available font</a>
1968-
then fall back to the
1971+
<code>g</code> in the block direction with the
1972+
<a>first available font</a> then fall back to the
19691973
layout algorithm of <a href="#layout-of-mtext"></a>.
19701974
<div class="note">
19711975
Here we treat a non-[=embellished operator/stretchy=] [=embellished operator/largeop=]
@@ -1986,7 +1990,7 @@ <h4>Layout of operators</h4>
19861990
<a>line-descent</a>
19871991
of the math content
19881992
are obtained by the algorithm to
1989-
<a>shape a stretchy glyph</a>
1993+
<a>shape a stretchy glyph</a> <code>g</code>
19901994
to <a>block dimension</a>
19911995
<a>DisplayOperatorMinHeight</a>.
19921996
The <a>inline size</a> of the math content is the width of
@@ -2015,7 +2019,7 @@ <h4>Layout of operators</h4>
20152019
</li>
20162020
<li>
20172021
The painting of the operator is performed by the
2018-
algorithm to <a>shape a stretchy glyph</a>
2022+
algorithm to <a>shape a stretchy glyph</a> <code>g</code>
20192023
stretched to <a>block dimension</a>
20202024
<a>DisplayOperatorMinHeight</a>
20212025
and at position determined by the previous box metrics
@@ -2878,8 +2882,11 @@ <h5>Radical symbol</h5>
28782882
of that element.
28792883
</p>
28802884
<p>
2881-
The <dfn>radical glyph</dfn> is the glyph obtained for the
2882-
character U+221A SQUARE ROOT.
2885+
Let <code>dir</code> be the computed <a data-xref-type="css-property">direction</a>
2886+
of the <code>&lt;msqrt&gt;</code> or <code>&lt;mroot&gt;</code> element.
2887+
The <dfn>radical glyph</dfn> is the glyph obtained as a result of running
2888+
<a>get a glyph</a> corresponding to the U+221A SQUARE ROOT character
2889+
given <code>dir</code>.
28832890
</p>
28842891
<p>
28852892
The <dfn>radical gap</dfn> is given by
@@ -2896,8 +2903,8 @@ <h5>Radical symbol</h5>
28962903
<p>
28972904
The <dfn>box metrics of the radical glyph</dfn>
28982905
and <dfn>painting of the surd</dfn> are given by the algorithm to
2899-
<a>shape a stretchy glyph</a> to <a>block dimension</a> the
2900-
target size for the radical glyph.
2906+
<a>shape a stretchy glyph</a> to the
2907+
target size for the radical glyph in the <a>block dimension</a>.
29012908
</p>
29022909
</section>
29032910
<section>
@@ -5679,6 +5686,55 @@ <h4>Algorithms for glyph stretching</h4>
56795686
such as
56805687
the one suggested in <a href="#unicode-based-glyph-assemblies"></a>.
56815688
</div>
5689+
<p>
5690+
The algorithm to <dfn>get a glyph</dfn> corresponding to a character <code>c</code> given a directionality <code>dir</code>
5691+
is the following:
5692+
</p>
5693+
<ul class="algorithm">
5694+
<li>
5695+
Let <code>g</code> be the glyph corresponding to <code>c</code>
5696+
in the <a>first available font</a>.
5697+
If it is not possible to find such a glyph, then exit with failure.
5698+
</li>
5699+
<li>
5700+
If <code>dir</code> is <code>rtl</code>:
5701+
<ul>
5702+
<li>
5703+
If there exists an OpenType rtlm variant of
5704+
<code>g</code> in the <a>first available font</a>,
5705+
then return it and exit with success. [[OPEN-FONT-FORMAT]]
5706+
</li>
5707+
<li>
5708+
Otherwise, if <code>c</code> has the Bidi_Mirrored property [[BIDI]]:
5709+
<ul>
5710+
<li>
5711+
If <code>c</code> has a corresponding mirrored codepoint,
5712+
<code>c'</code>, then return the glyph corresponding
5713+
to <code>c'</code> and exit with success.
5714+
If it is not possible to find such a glyph, then exit with failure.
5715+
</li>
5716+
<li>
5717+
Otherwise, exit with failure.
5718+
</li>
5719+
</ul>
5720+
<div class="note">
5721+
These failure cases are for when a character should be mirrored
5722+
according to its Bidi_Mirrored property, but no corresponding codepoint
5723+
or glyph exists.
5724+
</div>
5725+
</li>
5726+
<li>
5727+
Otherwise, return <code>g</code> and exit with success.
5728+
</li>
5729+
</ul>
5730+
</li>
5731+
<li class="assert">
5732+
Assert: <code>dir</code> is <code>ltr</code>.
5733+
</li>
5734+
<li>
5735+
Return <code>g</code> and exit with success.
5736+
</li>
5737+
</ul>
56825738
</section>
56835739
</section>
56845740
</section>

0 commit comments

Comments
 (0)