return {
font: {
family: node.attrs.font.replace(/^.*?"(\w+)".*$/, '$1'),
- size: typeof node.attrs['font-size'] === 'undefined' ? null : node.attrs['font-size']
+ size: typeof node.attrs['font-size'] === 'undefined' ? null : node.attrs['font-size'],
+ anchor : typeof node.attrs['text-anchor'] === 'undefined' ? null : node.attrs['text-anchor'],
}
};
}
*/
function styleToString(style) {
// TODO figure out what is 'normal'
- return 'font: normal normal normal 10px/normal ' + style.font.family +
- ( style.font.size === null ? '' : '; font-size: ' + style.font.size + 'px' );
+
+ var r = [
+ 'font-family:' + style.font.family,
+ 'font-weight:normal',
+ 'font-style:normal',
+ 'font-stretch:normal',
+ 'font-variant:normal'
+ ];
+ if (style.font.size !== null ) {
+ r.push('font-size: ' + style.font.size + 'px')
+ }
+
+ return r.join(';')
+
}
/**
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) + '"';
}
}