QuickFont.TextNodeList.MeasureNodes C# (CSharp) Метод

MeasureNodes() публичный Метод

public MeasureNodes ( QFontData fontData, QFontRenderOptions options ) : void
fontData QFontData
options QFontRenderOptions
Результат void
        public void MeasureNodes(QFontData fontData, QFontRenderOptions options)
        {
            foreach(TextNode node in this){
                if(node.Length == 0f)
                    node.Length = MeasureTextNodeLength(node,fontData,options);
            }
        }

Usage Example

Пример #1
0
        /// <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);
        }
All Usage Examples Of QuickFont.TextNodeList::MeasureNodes