@@ -112,8 +112,6 @@ exports.convertToTspans = function(_context, gd, _callback) {
112
112
var x = + _context . attr ( 'x' ) ;
113
113
var y = + _context . attr ( 'y' ) ;
114
114
115
- var newX = x - newSvgW *
116
- { start : 0 , middle : 0.5 , end : 1 } [ _context . attr ( 'text-anchor' ) || 'start' ] ;
117
115
// font baseline is about 1/4 fontSize below centerline
118
116
var textHeight = fontSize || _context . node ( ) . getBoundingClientRect ( ) . height ;
119
117
var dy = - textHeight / 4 ;
@@ -123,15 +121,26 @@ exports.convertToTspans = function(_context, gd, _callback) {
123
121
transform : 'rotate(' + [ - 90 , x , y ] +
124
122
')' + strTranslate ( - newSvgW / 2 , dy - newSvgH / 2 )
125
123
} ) ;
126
- newSvg . attr ( { x : x , y : y } ) ;
127
124
} else if ( svgClass [ 0 ] === 'l' ) {
128
- newSvg . attr ( { x : x , y : dy - ( newSvgH / 2 ) } ) ;
125
+ y = dy - newSvgH / 2 ;
129
126
} else if ( svgClass [ 0 ] === 'a' && svgClass . indexOf ( 'atitle' ) !== 0 ) {
130
- newSvg . attr ( { x : 0 , y : dy } ) ;
127
+ x = 0 ;
128
+ y = dy ;
131
129
} else {
132
- newSvg . attr ( { x : newX , y : ( y + dy - newSvgH / 2 ) } ) ;
130
+ var anchor = _context . attr ( 'text-anchor' ) ;
131
+
132
+ x = x - newSvgW * (
133
+ anchor === 'middle' ? 0.5 :
134
+ anchor === 'end' ? 1 : 0
135
+ ) ;
136
+ y = y + dy - newSvgH / 2 ;
133
137
}
134
138
139
+ newSvg . attr ( {
140
+ x : x ,
141
+ y : y
142
+ } ) ;
143
+
135
144
if ( _callback ) _callback . call ( _context , mathjaxGroup ) ;
136
145
resolve ( mathjaxGroup ) ;
137
146
} ) ;
0 commit comments