示例#1
0
        public static FormattedText Create(string text, Font font, TextAlignment alignment, SizeConstraint constraint)
        {
            if (text == null)
            {
                return new FormattedText(null, new Box2(0, 0, 0, 0), text, font, alignment, constraint);
            }
            else
            {
                var instances = new List<GlyphInstance>(text.Length);
                var x = 0f;

                foreach (var c in text)
                {
                    var glyph = font.GetGlyph(c);

                    if (glyph != null)
                    {
                        instances.Add(new GlyphInstance(new Box2(x, 0, glyph.Size.X, glyph.Size.Y), glyph.Sprite));
                        x += glyph.Size.X;
                    }
                }

                return new FormattedText(instances, new Box2(0, 0, x, font.Height), text, font, alignment, constraint);
            }
        }
示例#2
0
        public static FormattedText Create(string text, Font font, TextAlignment alignment, SizeConstraint constraint)
        {
            if (text == null)
            {
                return(new FormattedText(null, new Box2(0, 0, 0, 0), text, font, alignment, constraint));
            }
            else
            {
                var instances = new List <GlyphInstance>(text.Length);
                var x         = 0f;

                foreach (var c in text)
                {
                    var glyph = font.GetGlyph(c);

                    if (glyph != null)
                    {
                        instances.Add(new GlyphInstance(new Box2(x, 0, glyph.Size.X, glyph.Size.Y), glyph.Sprite));
                        x += glyph.Size.X;
                    }
                }

                return(new FormattedText(instances, new Box2(0, 0, x, font.Height), text, font, alignment, constraint));
            }
        }
示例#3
0
        public void Draw(Vector2 position, Font font, string text, Color4ub color)
        {
            foreach (var c in text)
            {
                var glyph = font.GetGlyph(c);

                if (glyph != null)
                {
                    Draw(new Box2(position, glyph.Size), glyph.Sprite, color);
                    position = new Vector2(position.X + glyph.Size.X, position.Y);
                }
            }
        }
示例#4
0
        public void Draw(Vector2 position, Font font, string text, Color4ub color)
        {
            foreach (var c in text)
            {
                var glyph = font.GetGlyph(c);

                if (glyph != null)
                {
                    Draw(new Box2(position, glyph.Size), glyph.Sprite, color);
                    position = new Vector2(position.X + glyph.Size.X, position.Y);
                }
            }
        }