@@ -111,24 +111,28 @@ exports.convertToTspans = function(_context, gd, _callback) {
111111
112112 var newSvgW = getSize ( g , 'width' ) ;
113113 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 *
115119 { start : 0 , middle : 0.5 , end : 1 } [ _context . attr ( 'text-anchor' ) || 'start' ] ;
116120 // font baseline is about 1/4 fontSize below centerline
117121 var textHeight = fontSize || getSize ( _context , 'height' ) ;
118122 var dy = - textHeight / 4 ;
119123
120124 if ( svgClass [ 0 ] === 'y' ) {
121125 mathjaxGroup . attr ( {
122- transform : 'rotate(' + [ - 90 , + _context . attr ( 'x' ) , + _context . attr ( 'y' ) ] +
126+ transform : 'rotate(' + [ - 90 , x , y ] +
123127 ')' + strTranslate ( - newSvgW / 2 , dy - newSvgH / 2 )
124128 } ) ;
125- newSvg . attr ( { x : + _context . attr ( 'x' ) , y : + _context . attr ( 'y' ) } ) ;
129+ newSvg . attr ( { x : x , y : y } ) ;
126130 } 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 ) } ) ;
128132 } else if ( svgClass [ 0 ] === 'a' && svgClass . indexOf ( 'atitle' ) !== 0 ) {
129133 newSvg . attr ( { x : 0 , y : dy } ) ;
130134 } else {
131- newSvg . attr ( { x : newX , y : ( + _context . attr ( 'y' ) + dy - newSvgH / 2 ) } ) ;
135+ newSvg . attr ( { x : newX , y : ( y + dy - newSvgH / 2 ) } ) ;
132136 }
133137
134138 if ( _callback ) _callback . call ( _context , mathjaxGroup ) ;
0 commit comments