X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=plugins%2Fraphael.export.js;h=bdd3b91367ebd675bab7835eddb740ec8bc91399;hb=c1180d91c1b3e343e3a9e25318149931f61c3e52;hp=c48e139687631a1964f7223ce221e8d2b250f316;hpb=3583abc147d9b6e480a3f9b7c21c16a7e7eade9e;p=raphael diff --git a/plugins/raphael.export.js b/plugins/raphael.export.js index c48e139..bdd3b91 100644 --- a/plugins/raphael.export.js +++ b/plugins/raphael.export.js @@ -100,7 +100,8 @@ 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'], } }; } @@ -162,8 +163,10 @@ return initial; }, { - style: 'text-anchor: middle; ' + styleToString(style) + ';' } - ), + style: 'text-anchor: ' + (style.font.anchor ? (style.font.anchor +';' ): 'middle;') + + styleToString(style) + ';' + } + ), node.matrix, tag('tspan', { @@ -185,13 +188,17 @@ 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 ); @@ -229,7 +236,7 @@ for ( i in node.attrs ) { var name = i; - + var val = node.attrs[i].toString(); switch ( i ) { case 'src': name = 'xlink:href'; @@ -237,12 +244,16 @@ 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) + '"'; } }