예제 #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
 private FormattedText(List <GlyphInstance> instances, Box2 bounds, string text, Font font, TextAlignment alignment, SizeConstraint constraint)
 {
     m_instances = instances;
     Bounds      = bounds;
     Text        = text;
     Font        = font;
     Alignment   = alignment;
     Constraint  = constraint;
 }
예제 #3
0
 private FormattedText(List<GlyphInstance> instances, Box2 bounds, string text, Font font, TextAlignment alignment, SizeConstraint constraint)
 {
     m_instances = instances;
     Bounds = bounds;
     Text = text;
     Font = font;
     Alignment = alignment;
     Constraint = constraint;
 }
예제 #4
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));
            }
        }