Пример #1
0
        public TextLayout(string text, Vector2 bounds, Font font, float fontSize, TextFormat format)
        {
            surface = GameEngine.TryQueryComponent<ISurface>();
            if (surface == null) throw new InvalidOperationException("A surface must be registered before a text layout can be created.");
            surface.DpiChanged += OnSurfaceDpiChanged;

            this.text = text;
            this.bounds = bounds;
            this.font = font;
            this.fontSize = fontSize;
            this.format = format;

            dpiChanged = false;
            Glyphs = new List<PositionedGlyph>();
            Layout();
        }
Пример #2
0
 /// <summary>
 /// Draws formatted text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="bounds">The bounds the text will be displayed in.</param>
 /// <param name="font">The font of the text.</param>
 /// <param name="size">The font size in points.</param>
 /// <param name="brush">The brush used to draw the text.</param>
 /// <param name="format">The format of the text.</param>
 public void DrawText(string text, Rectangle bounds, Font font, float size, TextFormat format, Brush brush)
 {
     var layout = new TextLayout(text, bounds.Size, font, size, format);
     DrawTextLayout(layout, bounds.Location, brush);
 }
Пример #3
0
        /// <summary>
        /// Draws formatted text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="bounds">The bounds the text will be displayed in.</param>
        /// <param name="font">The font of the text.</param>
        /// <param name="size">The font size in points.</param>
        /// <param name="brush">The brush used to draw the text.</param>
        /// <param name="format">The format of the text.</param>
        public void DrawText(string text, Rectangle bounds, Font font, float size, TextFormat format, Brush brush)
        {
            var layout = new TextLayout(text, bounds.Size, font, size, format);

            DrawTextLayout(layout, bounds.Location, brush);
        }