/// <summary>
/// Creates node list object associated with the text.
/// </summary>
/// <param name="text"></param>
/// <param name="bounds"></param>
/// <returns></returns>
public ProcessedText ProcessText(string text, float maxWidth, QFontAlignment alignment)
{
//TODO: bring justify and alignment calculations in here
maxWidth = TransformWidthToViewport(maxWidth);
var nodeList = new TextNodeList(text);
nodeList.MeasureNodes(fontData, Options);
//we "crumble" words that are two long so that that can be split up
var nodesToCrumble = new List <TextNode>();
foreach (TextNode node in nodeList)
{
if (node.Length >= maxWidth && node.Type == TextNodeType.Word)
{
nodesToCrumble.Add(node);
}
}
foreach (var node in nodesToCrumble)
{
nodeList.Crumble(node, 1);
}
//need to measure crumbled words
nodeList.MeasureNodes(fontData, Options);
var processedText = new ProcessedText();
processedText.textNodeList = nodeList;
processedText.maxWidth = maxWidth;
processedText.alignment = alignment;
return(processedText);
}