XNA has Spritefont class, which has a MeasureString method, which can return the Width and Height of a string
. I'm trying to understand how to create a method that will efficiently return a string with Environment.Newline
inserted in the right places, so that if fits a certain Width and Height (Rectangle is used as a parameter for that).
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I found following code: XNA - Basic Word Wrapping
To add to Alina's answer, here is an extended version of that function, that will also linebreak single words that are longer than maxLineWidth
To handle a block of text with carriage returns you need to modify the code as below: