@@ -50,7 +50,7 @@ export class CHTMLmsub extends CHTMLscriptbase {
5050 * @override
5151 */
5252 protected getOffset ( bbox : BBox , sbox : BBox ) {
53- return - this . getV ( bbox , sbox ) ;
53+ return [ 0 , - this . getV ( bbox , sbox ) ] ;
5454 }
5555
5656}
@@ -63,6 +63,8 @@ export class CHTMLmsub extends CHTMLscriptbase {
6363export class CHTMLmsup extends CHTMLscriptbase {
6464 public static kind = MmlMsup . prototype . kind ;
6565
66+ public static useIC : boolean = true ;
67+
6668 /*
6769 * @override
6870 */
@@ -76,7 +78,8 @@ export class CHTMLmsup extends CHTMLscriptbase {
7678 * @override
7779 */
7880 public getOffset ( bbox : BBox , sbox : BBox ) {
79- return this . getU ( bbox , sbox ) ;
81+ const x = ( this . baseCore . bbox . ic ? .2 * this . baseCore . bbox . ic + .05 : 0 ) ;
82+ return [ x , this . getU ( bbox , sbox ) ] ;
8083 }
8184
8285}
@@ -99,6 +102,8 @@ export class CHTMLmsubsup extends CHTMLscriptbase {
99102 }
100103 } ;
101104
105+ public static noIC : boolean = true ;
106+
102107 /*
103108 * Cached values for the script offsets and separation (so if they are
104109 * computed in computeBBox(), they don't have to be recomputed for toCHTML())
@@ -131,6 +136,10 @@ export class CHTMLmsubsup extends CHTMLscriptbase {
131136 this . sup . toCHTML ( stack ) ;
132137 stack . appendChild ( this . html ( 'mjx-spacer' , { style : { 'margin-top' : this . em ( q ) } } ) ) ;
133138 this . sub . toCHTML ( stack ) ;
139+ const corebox = this . baseCore . bbox ;
140+ if ( corebox . ic ) {
141+ this . sup . chtml . style . marginLeft = this . em ( ( 1.2 * corebox . ic + .05 ) / this . sup . bbox . rscale ) ;
142+ }
134143 }
135144
136145 /*
@@ -162,8 +171,21 @@ export class CHTMLmsubsup extends CHTMLscriptbase {
162171 if ( this . UVQ ) return this . UVQ ;
163172 const tex = this . font . params ;
164173 const t = 3 * tex . rule_thickness ;
165- let [ u , v ] = ( this . isCharBase ( ) ? [ 0 , 0 ] : [ this . getU ( basebox , supbox ) ,
166- Math . max ( basebox . d + tex . sub_drop * subbox . rscale , tex . sub2 ) ] ) ;
174+ const subscriptshift = this . length2em ( this . node . attributes . get ( 'subscriptshift' ) , tex . sub2 ) ;
175+ const drop = ( this . isCharBase ( ) ? 0 : basebox . d + tex . sub_drop * subbox . rscale ) ;
176+ //
177+ // u and v are the veritcal shifts of the scripts, initially set to minimum values and then adjusted
178+ //
179+ let [ u , v ] = [ this . getU ( basebox , supbox ) , Math . max ( drop , subscriptshift ) ] ;
180+ //
181+ // q is the space currently between the super- and subscripts.
182+ // If it is less than 3 rule thicknesses,
183+ // increase the subscript offset to make the space 3 rule thicknesses
184+ // If the bottom of the superscript is below 4/5 of the x-height
185+ // raise both the super- and subscripts by the difference
186+ // (make the bottom of the superscript be at 4/5 the x-height, and the
187+ // subscript 3 rule thickness below that).
188+ //
167189 let q = ( u - supbox . d * supbox . rscale ) - ( subbox . h * subbox . rscale - v ) ;
168190 if ( q < t ) {
169191 v += t - q ;
@@ -173,6 +195,10 @@ export class CHTMLmsubsup extends CHTMLscriptbase {
173195 v -= p ;
174196 }
175197 }
198+ //
199+ // Make sure the shifts are at least the minimum amounts and
200+ // return the shifts and the space between the scripts
201+ //
176202 u = Math . max ( this . length2em ( this . node . attributes . get ( 'superscriptshift' ) , u ) , u ) ;
177203 v = Math . max ( this . length2em ( this . node . attributes . get ( 'subscriptshift' ) , v ) , v ) ;
178204 q = ( u - supbox . d * supbox . rscale ) - ( subbox . h * subbox . rscale - v ) ;
0 commit comments