/// <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); }
/// <summary> /// Creates node list object associated with the text. /// </summary> /// <param name="options">The font render options</param> /// <param name="text">The text to process</param> /// <param name="font">The <see cref="QFont"/> to process the text with</param> /// <param name="maxSize">The maximum size of the processed text</param> /// <param name="alignment">The text alignment</param> /// <returns>The processed text</returns> public static ProcessedText ProcessText(QFont font, QFontRenderOptions options, string text, SizeF maxSize, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here maxSize.Width = TransformWidthToViewport(maxSize.Width, options); var nodeList = new TextNodeList(text); nodeList.MeasureNodes(font.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 ((!options.WordWrap || node.Length >= maxSize.Width) && node.Type == TextNodeType.Word) { nodesToCrumble.Add(node); } } foreach (TextNode node in nodesToCrumble) { nodeList.Crumble(node, 1); } //need to measure crumbled words nodeList.MeasureNodes(font.FontData, options); var processedText = new ProcessedText(); processedText.TextNodeList = nodeList; processedText.MaxSize = maxSize; processedText.Alignment = alignment; return(processedText); }
/// <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, RectangleF bounds, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here 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 >= bounds.Width && 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.bounds = bounds; processedText.alignment = alignment; return(processedText); }
/// <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, SizeF maxSize, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here maxSize.Width = TransformWidthToViewport(maxSize.Width); 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 ((!Options.WordWrap || node.Length >= maxSize.Width) && 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.maxSize = maxSize; processedText.alignment = alignment; return processedText; }
/// <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, RectangleF bounds, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here 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 >= bounds.Width && 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.bounds = bounds; processedText.alignment = alignment; return processedText; }
private ProcessedText SafeProcessText(Rectangle clientRectangle, string text, float maxWidth, QFontAlignment alignment) { //TODO: bring justify and alignment calculations in here maxWidth = TransformWidthToViewport(clientRectangle, 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; }