Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }