I've got an array that holds strings, and I wanted to know how I could take a string and cut a part off at a specified pixel length and add it into the array.
For Example,
string[] string1 = { "Hello World" };
I'm using XNA so I can get the pixel length by using,
FontName.MeasureString(string1[0]).Length()
So for example, if the above code returns 100 pixels long how can I cut the string at 70 pixels long and add it back to the array to get this:
string1 = { "Hello Wo", "rld" } // Hello Wo(100px), rld(30px)
I've look at using StringBuilder but it measures strings in character length. If there are no possible ways to accomplish this, would there be a way to instead find out how many characters are in between the start of the string and the pixel point of where I want the string to cut off at, so then I would be able to use StringBuilder.
Aucun commentaire:
Enregistrer un commentaire