コード例 #1
0
        public Size GetTextSize(string str, BGICanvas.Direction dir, int size)
        {
            float width = 0;

            foreach (byte c in BGICanvas.Encoding.GetBytes(str))
            {
                BGICharacter ch = this[c];
                if (ch != null)
                {
                    width += ch.Width;
                }
            }
            if (dir == BGICanvas.Direction.Horizontal)
            {
                return(new Size(BGICanvas.Trunc(width * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), (int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size])));
            }
            else
            {
                return(new Size((int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), BGICanvas.Trunc(width * BGICharacter.scaleup[size] / BGICharacter.scaledown[size])));
            }
        }