58
« on: June 24, 2012, 08:55:28 am »
Since there's no measureText function anywhere, I've been measuring the size of a string by constructing a Text object, getting the bounds, and then discarding it. Is that a reasonable way to measure text, or would you say I should be using just a Font and calculating the size one character at a time by accessing the glyphs?
To put this another way, does constructing a text object with a string do anything towards rendering, or does it just store the string and font attributes and calculate the size of the string, leaving any rendering to when draw() is called?
I'll note that the lack of a measureText function in Font surprised me at first, since this is kind of an important thing to have. I've actually been having small performance issues in rendering large quantities of text and have figured out that the measuring, wrapping algorithm, and rendering take the most time overall. I think my wrapping algorithm could also use some work, but I'd like to know if there's any point in changing the measuring algorithm as well.