1

Is there a way to set letter-spacing in raphael js text? It can be done easily in CSS, how can I do it in raphael? Any hacks would also do..

rohan_vg
  • 1,087
  • 3
  • 15
  • 27

2 Answers2

2

Paper.print() has a letter-spacing attribute:

var txt = r.print(10, 50, "O HAI", r.getFont("Comic Sans"), 30, 'middle', 1).attr({fill: "#fff"});
                                                                          ^
                                                           this is the letter spacing

See the docs on that.

Note that this needs "cufon-style" font files to be included and will render a non-selectable path object instead of real text.

m90
  • 11,434
  • 13
  • 62
  • 112
1

It can be done with normal css. take a look here : http://tutorials.jenkov.com/svg/text-element.html . The css is applied to svg too.
Here's a live demo that shows svg text with letter-spacing.

gion_13
  • 41,171
  • 10
  • 96
  • 108
  • @rohan_vg That is because firefox has not supported the svg letter-spacing attribute for the last 10 years: see https://bugzilla.mozilla.org/show_bug.cgi?id=371787. – mpacer Jan 24 '16 at 01:34