From 64f34e6dfd4e8935a0c49c85957042e2349de438 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sun, 16 Sep 2012 01:02:23 -0400 Subject: [PATCH] Add _importText --- src/svg/ImportSVG.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/svg/ImportSVG.js b/src/svg/ImportSVG.js index 6b92b44f..7653034a 100644 --- a/src/svg/ImportSVG.js +++ b/src/svg/ImportSVG.js @@ -68,6 +68,9 @@ var ImportSVG = this.ImportSVG = Base.extend({ case 'g': item = this.importGroup(svg); break; + case 'text': + item = this._importText(svg); + break; default: break; } @@ -165,5 +168,31 @@ var ImportSVG = this.ImportSVG = Base.extend({ var line = new Path.Line(from, to); return line; + }, + + /** + * Creates a PointText Paper.js item + * + * takes a svg text node (xml dom) + * returns a PointText item + */ + _importText: function(svgText) + { + //TODO: Extend this for multiple values + var x = svgText.x.baseVal.getItem(0).value || 0; + var y = svgText.y.baseVal.getItem(0).value || 0; + //END:Todo + + var dx; //character kerning + var dy; //character baseline + var rotate; //character rotation + var textLength; //the width of the containing box + var lengthAdjust; // + var textContent = svgText.textContent || ""; + + var topLeft = new Point(x, y); + var text = new PointText(topLeft); + text.content = textContent; + return text; } }); \ No newline at end of file