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