diff options
author | wout <wout@impinc.co.uk> | 2012-12-20 22:19:45 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-20 22:19:45 +0100 |
commit | 071b2f2c8618c09e4944a4c9ac40853e9b6a7d13 (patch) | |
tree | 0115ed12c6fcfd93021d0026e212118ba2df495e /src/text.js | |
parent | 675e347a10372a10ecdfd4fa6624c062f1ee7102 (diff) | |
download | svg.js-071b2f2c8618c09e4944a4c9ac40853e9b6a7d13.tar.gz svg.js-071b2f2c8618c09e4944a4c9ac40853e9b6a7d13.zip |
Added anchor option for text element
Diffstat (limited to 'src/text.js')
-rw-r--r-- | src/text.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/text.js b/src/text.js index 3b50216..655815d 100644 --- a/src/text.js +++ b/src/text.js @@ -4,6 +4,7 @@ SVG.Text = function Text() { this.style = { 'font-size': 16 }; this.leading = 1.2; + this.anchor = 'start'; }; // inherit from SVG.Element @@ -38,7 +39,7 @@ SVG.extend(SVG.Text, { if (o[a[i]] != null) this.style['font-' + a[i]] = o[a[i]]; - a = ('leading kerning anchor').split(' '); + a = ('leading anchor').split(' '); for (i = a.length - 1; i >= 0; i--) if (o[a[i]] != null) @@ -54,12 +55,9 @@ SVG.extend(SVG.Text, { if (this.style['font-' + a[i]] != null) s += 'font-' + a[i] + ':' + this.style['font-' + a[i]] + ';'; - a = ('leading kerning anchor').split(' '); - - for (i = a.length - 1; i >= 0; i--) - if (this[a[i]] != null) - s += a[i] + ':' + this[a[i]] + ';'; - + if (this.anchor != null) + s += 'text-anchor:' + this.anchor + ';'; + return s; } |