Sunday, 11 August 2013

Is there a way to get the width and height of a Canvas's inner content?

Is there a way to get the width and height of a Canvas's inner content?

Is there a way to get the inner width and height of a canvas based on it's
content?
I want to allow the user to write text to a canvas and the user is allowed
to pick the font size, font family, etc. Problem is since they have
control over the font and the length of text I don't have a way of knowing
what to set the width and height of the canvas to.
So is there a way to have the canvas be as big as the content inside it
(like the display "inline block" property of CSS) or a way to get the
width and height of the inner content of a canvas (in that case I would
just adjust the width and height of it after each letter in the text is
written)?

No comments:

Post a Comment