示例#1
0
        public float DrawCharacter(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, byte character, IList <Rectangle> updates)
        {
            BGICharacter ch = this[character];

            if (ch != null)
            {
                var drawUpdates = updates ?? new List <Rectangle>();
                ch.Draw(bgi, x, y, dir, size, updates);
                if (updates == null)
                {
                    bgi.UpdateRegion(drawUpdates);
                }
                return(ch.GetWidth(size));
            }
            return(0);
        }
示例#2
0
        public Size GetRealTextSize(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.GetWidth(size);
                }
            }
            if (dir == BGICanvas.Direction.Horizontal)
            {
                return(new Size(BGICanvas.Round(width), (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.Round(width)));
            }
        }