font: {
family: node.attrs.font.replace(/^.*?"(\w+)".*$/, '$1'),
size: typeof node.attrs['font-size'] === 'undefined' ? null : node.attrs['font-size'],
- anchor : typeof node.attrs['text-anchor'] === 'undefined' ? null : node.attrs['text-anchor''],
+ anchor : typeof node.attrs['text-anchor'] === 'undefined' ? null : node.attrs['text-anchor'],
}
};
}
return initial;
},
{
- style: 'text-anchor: middle; ' + styleToString(style) + ';' }
- ),
+ style: 'text-anchor: ' + (style.font.anchor ? (style.font.anchor +';' ): 'middle;') +
+ styleToString(style) + ';'
+ }
+ ),
node.matrix,
tag('tspan',
{
reduce(
node.attrs,
function(initial, value, name) {
- if ( name === 'path' ) name = 'd';
+ if ( name === 'path' ) {
+ name = 'd';
+ }
- initial[name] = value.toString();
+ initial[name] = (typeof(value) == 'undefined') ? '' : value.toString();
return initial;
},
- {}
+ {
+ style: node.attrs.style
+ }
),
node.matrix
);
for ( i in node.attrs ) {
var name = i;
-
+ var val = node.attrs[i].toString();
switch ( i ) {
case 'src':
name = 'xlink:href';
break;
case 'transform':
name = '';
-
break;
+
+ case 'stroke':
+ case 'fill':
+ val = Raphael.getRGB(val).hex;
+ break;
}
if ( name ) {
- attrs += ' ' + name + '="' + escapeXML(node.attrs[i].toString()) + '"';
+ attrs += ' ' + name + '="' + escapeXML(val) + '"';
}
}