Пример #1
0
 public LineSplitter(Font font, PointF scale, string text)
 {
     _font      = font;
     _scale     = scale;
     _text      = text;
     _spaceSize = font.Width(((TextureFilm)font).Get(' '));
 }
Пример #2
0
        private void GetWordMetrics(string word, PointF metrics)
        {
            float w = 0;
            float h = 0;

            var length = word.Length;

            for (var i = 0; i < length; i++)
            {
                var rect = ((TextureFilm)_font).Get(word[i]);
                w += _font.Width(rect) + (w > 0 ? _font.tracking : 0);
                h  = Math.Max(h, _font.Height(rect));
            }

            metrics.Set(w, h);
        }
Пример #3
0
        protected internal virtual void UpdateVertices()
        {
            _Width  = 0;
            _Height = 0;

            if (text == null)
            {
                text = "";
            }

            Quads      = Quad.CreateSet(text.Length);
            RealLength = 0;

            var length = text.Length;

            for (var i = 0; i < length; i++)
            {
                var rect = ((TextureFilm)font).Get(text[i]);

                var w = font.Width(rect);
                var h = font.Height(rect);

                Vertices[0] = Width;
                Vertices[1] = 0;

                Vertices[2] = rect.Left;
                Vertices[3] = rect.Top;

                Vertices[4] = Width + w;
                Vertices[5] = 0;

                Vertices[6] = rect.Right;
                Vertices[7] = rect.Top;

                Vertices[8] = Width + w;
                Vertices[9] = h;

                Vertices[10] = rect.Right;
                Vertices[11] = rect.Bottom;

                Vertices[12] = Width;
                Vertices[13] = h;

                Vertices[14] = rect.Left;
                Vertices[15] = rect.Bottom;

                Quads.Put(Vertices);
                RealLength++;

                _Width += w + font.tracking;
                if (h > Height)
                {
                    _Height = h;
                }
            }

            if (length > 0)
            {
                _Width -= font.tracking;
            }

            Dirty = false;
        }
Пример #4
0
 public BitmapTextMultiline(string text, Font font)
     : base(text, font)
 {
     SpaceSize = font.Width(((TextureFilm)font).Get(' '));
 }