5

Is there a method or workaround to return the text width of a string in a Text Shape, in KineticJs?

I would need it to position precisely the TextShape on the canvas.

seinecle
  • 10,118
  • 14
  • 61
  • 120

2 Answers2

9

Kinetic.Text has getTextHeight() and getTextWidht() methods to do this for you.

Rich
  • 315
  • 2
  • 6
4

This might help you. It demonstrates how to get the width of some text. There is also a link to another example showing how to do this for multi-line text, here.

jaker
  • 7,730
  • 1
  • 20
  • 22