public static TextParseReturnValue FixText(SpriteFont spriteFont, int width, string text) { string line = String.Empty; TextParseReturnValue returnValue = new TextParseReturnValue(); returnValue.Text = String.Empty; string[] wordArray = text.Split(' '); foreach (string word in wordArray) { if (spriteFont.MeasureString(line + word).Length() > width) { returnValue.Text = returnValue.Text + line + Environment.NewLine; returnValue.LineCount = returnValue.LineCount + 1; line = String.Empty; } line = line + word + " "; } returnValue.Text = returnValue.Text + line; return(returnValue); }
public static List <string> GetFixedTextLines(string text, int fontIndex, int width, bool splitWords = true) { return(TextParseReturnValue.GetFixedTextLines(fonts[fontIndex], width, text, splitWords)); }
public static TextParseReturnValue FixText(string text, int fontIndex, int width) { return(TextParseReturnValue.FixText(fonts[fontIndex], width, text)); }