How do I implement word wrap?
问题 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). 回答1: I found following code: XNA - Basic Word Wrapping public string WrapText(SpriteFont spriteFont, string text, float maxLineWidth) { string[] words =