Title: calculating the width of text

I’m trying to calculate the amount of text that can fit into a specified width on an SVG image.  My calculations are based on the FontMetrics.stringWidth method.

For example, I have some text I want to put into a space that is 250 units long.  The FontMetrics.stringWidth gives 249 for the width of the text, however, the text overruns in the image.

I’m assuming this is because the SVG image and the FontMetrics.stringWidth are returning coordinates in different units (or a bug in my code.  Can’t ever rule that out).  I believe FontMetrics.stringWidth uses pixels (please correct me if I’m wrong).  What does SVG use by default?  It should be pixels correct? 

Is there a reason why the text doesn’t line up?  Is there an easier way of determining what text will fit in a given space?

Thanks,

Tom

Reply via email to