Exemplo n.º 1
0
    /// <summary>
    /// Gets how wide the specified character
    /// would be, in pixels, when displayed.
    /// </summary>
    /// <param name="prevChar">The character previous to that being measured.</param>
    /// <param name="str">The character to measure.</param>
    /// <returns>The width, in pixels, of the character, as displayed (includes the xAdvance).</returns>
    public float GetWidth(char prevChar, char c)
    {
        SpriteChar chr = GetSpriteChar(c);

        if (chr == null)
        {
            return(0);
        }

        return(chr.xAdvance + chr.GetKerning(prevChar));
    }
Exemplo n.º 2
0
    public float GetWidth(string str)
    {
        if (str.Length < 1)
        {
            return(0f);
        }
        float num = this.GetSpriteChar(str[0]).xAdvance;

        for (int i = 1; i < str.Length; i++)
        {
            SpriteChar spriteChar = this.GetSpriteChar(str[i]);
            num += spriteChar.xAdvance + spriteChar.GetKerning(str[i - 1]);
        }
        return(num);
    }
Exemplo n.º 3
0
    public float GetWidth(StringBuilder sb, int start, int end)
    {
        if (start >= sb.Length || end < start)
        {
            return(0f);
        }
        end = Mathf.Clamp(end, 0, sb.Length - 1);
        float num = this.GetSpriteChar(sb[start]).xAdvance;

        for (int i = start + 1; i <= end; i++)
        {
            SpriteChar spriteChar = this.GetSpriteChar(sb[i]);
            num += spriteChar.xAdvance + spriteChar.GetKerning(sb[i - 1]);
        }
        return(num);
    }
Exemplo n.º 4
0
    public float GetWidth(char prevChar, char c)
    {
        SpriteChar spriteChar = this.GetSpriteChar(c);

        return(spriteChar.xAdvance + spriteChar.GetKerning(prevChar));
    }