Duality.Resources.Font.MeasureText C# (CSharp) Méthode

MeasureText() public méthode

Measures the size of a text rendered using this Font.
public MeasureText ( string text ) : System.Vector2
text string The text to measure.
Résultat System.Vector2
        public Vector2 MeasureText(string text)
        {
            Vector2 textSize = Vector2.Zero;

            float curOffset = 0.0f;
            GlyphData glyphData;
            Rect uvRect;
            float glyphXOff;
            float glyphXAdv;
            for (int i = 0; i < text.Length; i++)
            {
                this.ProcessTextAdv(text, i, out glyphData, out uvRect, out glyphXAdv, out glyphXOff);

                textSize.X = Math.Max(textSize.X, curOffset + glyphXAdv - this.spacing);
                textSize.Y = Math.Max(textSize.Y, glyphData.height);

                curOffset += glyphXAdv;
            }

            textSize.X = MathF.Round(textSize.X);
            textSize.Y = MathF.Round(textSize.Y);
            return textSize;
        }