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);
        }
예제 #2
0
 public static List <string> GetFixedTextLines(string text, int fontIndex, int width, bool splitWords = true)
 {
     return(TextParseReturnValue.GetFixedTextLines(fonts[fontIndex], width, text, splitWords));
 }
예제 #3
0
 public static TextParseReturnValue FixText(string text, int fontIndex, int width)
 {
     return(TextParseReturnValue.FixText(fonts[fontIndex], width, text));
 }