Skip to content

Commit 7ed76b0

Browse files
committed
Add support for RTL mirroring of operators
1 parent 9e704e9 commit 7ed76b0

File tree

1 file changed

+85
-29
lines changed

1 file changed

+85
-29
lines changed

spec.html

+85-29
Original file line numberDiff line numberDiff line change
@@ -1738,13 +1738,21 @@ <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
1747-
layout algorithm of <a href="#layout-of-mtext"></a>.
1751+
layout algorithm of <a href="#layout-of-mtext"></a>
1752+
and return.
1753+
Otherwise, let <code>g</code> be the result of running
1754+
<a>get a glyph</a> corresponding to <code>c</code>
1755+
with directionality <code>dir</code>.
17481756
</li>
17491757
<li>
17501758
If the operator has the [=embellished operator/stretchy=] property:
@@ -1754,11 +1762,10 @@ <h4>Layout of operators</h4>
17541762
<ol>
17551763
<li>
17561764
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
1761-
layout algorithm of <a href="#layout-of-mtext"></a>.
1765+
<code>g</code> in the inline direction with the
1766+
<a>first available font</a> then fall back to the
1767+
layout algorithm of <a href="#layout-of-mtext"></a>
1768+
and return.
17621769
</li>
17631770
<li>
17641771
The <a>min-content inline size</a> and
@@ -1772,18 +1779,19 @@ <h4>Layout of operators</h4>
17721779
<code>T<sub>inline</sub></code>
17731780
then
17741781
fall back to the
1775-
layout algorithm of <a href="#layout-of-mtext"></a>.
1782+
layout algorithm of <a href="#layout-of-mtext"></a>
1783+
and return.
17761784
</li>
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,11 +1804,10 @@ <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
1803-
layout algorithm of <a href="#layout-of-mtext"></a>.
1807+
<code>g</code> in the block direction with the
1808+
<a>first available font</a> then fall back to the
1809+
layout algorithm of <a href="#layout-of-mtext"></a>
1810+
and return.
18041811
</li>
18051812
<li>
18061813
The <a>min-content inline size</a> and
@@ -1815,7 +1822,8 @@ <h4>Layout of operators</h4>
18151822
<code>(U<sub>ascent</sub>, U<sub>descent</sub>)</code>
18161823
then
18171824
fall back to the
1818-
layout algorithm of <a href="#layout-of-mtext"></a>.
1825+
layout algorithm of <a href="#layout-of-mtext"></a>
1826+
and return.
18191827
</li>
18201828
<li>If the operator has the [=embellished operator/symmetric=] property
18211829
then set the target sizes
@@ -1920,7 +1928,7 @@ <h4>Layout of operators</h4>
19201928
<a>line-descent</a>
19211929
of the math content
19221930
are obtained by the algorithm to
1923-
<a>shape a stretchy glyph</a>
1931+
<a>shape a stretchy glyph</a> <code>g</code>
19241932
to <a>block dimension</a>
19251933
<code>T<sub>ascent</sub></code> +
19261934
<code>T<sub>descent</sub></code>.
@@ -1937,7 +1945,7 @@ <h4>Layout of operators</h4>
19371945
</li>
19381946
<li>
19391947
The painting of the operator is performed by the
1940-
algorithm to <a>shape a stretchy glyph</a>
1948+
algorithm to <a>shape a stretchy glyph</a> <code>g</code>
19411949
stretched to <a>block dimension</a>
19421950
<code>T<sub>ascent</sub></code> +
19431951
<code>T<sub>descent</sub></code>
@@ -1962,11 +1970,10 @@ <h4>Layout of operators</h4>
19621970
<ol>
19631971
<li>
19641972
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
1969-
layout algorithm of <a href="#layout-of-mtext"></a>.
1973+
<code>g</code> in the block direction with the
1974+
<a>first available font</a> then fall back to the
1975+
layout algorithm of <a href="#layout-of-mtext"></a>
1976+
and return.
19701977
<div class="note">
19711978
Here we treat a non-[=embellished operator/stretchy=] [=embellished operator/largeop=]
19721979
glyph as stretchy with target dimension <a>DisplayOperatorMinHeight</a>.
@@ -1986,7 +1993,7 @@ <h4>Layout of operators</h4>
19861993
<a>line-descent</a>
19871994
of the math content
19881995
are obtained by the algorithm to
1989-
<a>shape a stretchy glyph</a>
1996+
<a>shape a stretchy glyph</a> <code>g</code>
19901997
to <a>block dimension</a>
19911998
<a>DisplayOperatorMinHeight</a>.
19921999
The <a>inline size</a> of the math content is the width of
@@ -2015,7 +2022,7 @@ <h4>Layout of operators</h4>
20152022
</li>
20162023
<li>
20172024
The painting of the operator is performed by the
2018-
algorithm to <a>shape a stretchy glyph</a>
2025+
algorithm to <a>shape a stretchy glyph</a> <code>g</code>
20192026
stretched to <a>block dimension</a>
20202027
<a>DisplayOperatorMinHeight</a>
20212028
and at position determined by the previous box metrics
@@ -2878,8 +2885,11 @@ <h5>Radical symbol</h5>
28782885
of that element.
28792886
</p>
28802887
<p>
2881-
The <dfn>radical glyph</dfn> is the glyph obtained for the
2882-
character U+221A SQUARE ROOT.
2888+
Let <code>dir</code> be the computed <a data-xref-type="css-property">direction</a>
2889+
of the <code>&lt;msqrt&gt;</code> or <code>&lt;mroot&gt;</code> element.
2890+
The <dfn>radical glyph</dfn> is the glyph obtained as a result of running
2891+
<a>get a glyph</a> corresponding to the U+221A SQUARE ROOT character
2892+
given <code>dir</code>.
28832893
</p>
28842894
<p>
28852895
The <dfn>radical gap</dfn> is given by
@@ -2896,8 +2906,8 @@ <h5>Radical symbol</h5>
28962906
<p>
28972907
The <dfn>box metrics of the radical glyph</dfn>
28982908
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.
2909+
<a>shape a stretchy glyph</a> to the
2910+
target size for the radical glyph in the <a>block dimension</a>.
29012911
</p>
29022912
</section>
29032913
<section>
@@ -5679,6 +5689,52 @@ <h4>Algorithms for glyph stretching</h4>
56795689
such as
56805690
the one suggested in <a href="#unicode-based-glyph-assemblies"></a>.
56815691
</div>
5692+
<p>
5693+
The algorithm to <dfn>get a glyph</dfn> corresponding to a character <code>c</code> given a directionality <code>dir</code>
5694+
is the following:
5695+
</p>
5696+
<ul class="algorithm">
5697+
<li>
5698+
Let <code>g</code> be the glyph corresponding to <code>c</code>.
5699+
</li>
5700+
<li>
5701+
If <code>dir</code> is <code>rtl</code>:
5702+
<ul>
5703+
<li>
5704+
If there exists an OpenType rtlm variant of
5705+
<code>g</code>, then return it. [[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 codepoint, <code>c'</code>,
5712+
for which its glyph is typically the mirror image of <code>g</code>,
5713+
then return the glyph corresponding to <code>c'</code>.
5714+
</li>
5715+
<li>
5716+
Otherwise, transform <code>g</code> by scaling it by a factor
5717+
of -1 horizontally and return the result.
5718+
<div class="note">
5719+
This exists as a fallback for when a character should be mirrored
5720+
according to its Bidi_Mirrored property, but no corresponding codepoint
5721+
or glyph exists.
5722+
</div>
5723+
</li>
5724+
</ul>
5725+
</li>
5726+
<li>
5727+
Otherwise, return <code>g</code>.
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>.
5736+
</li>
5737+
</ul>
56825738
</section>
56835739
</section>
56845740
</section>

0 commit comments

Comments
 (0)