public TextBlock(string text, Font font, RectangleF bounds, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { Text = text; Font = font; Bounds = bounds; Options = options; Alignment = alignment; Direction = direction; UsageCount = 0; }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to print text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to print text.</param> public void Render(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { Contract.Requires(!_disposed, new ObjectDisposedException(GetType().ToString()).Message); Contract.Requires(!string.IsNullOrEmpty(text)); Contract.Requires(font != null); Contract.Requires((rect.Width >= 0) && (rect.Height >= 0)); var block = new TextBlock(text, font, rect, options, alignment, direction); TextOutput.Render(ref block, color, Rasterizer); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (_disposed) { throw new ObjectDisposedException(this.GetType().ToString()); } Contract.Requires(!string.IsNullOrEmpty(text)); Contract.Requires(font != null); Contract.Requires((rect.Width >= 0) && (rect.Height >= 0)); var block = new TextBlock(text, font, rect, options, alignment, direction); return(Rasterizer.MeasureText(ref block)); }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to print text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to print text.</param> public void Print(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (disposed) { throw new ObjectDisposedException(this.GetType().ToString()); } if (!ValidateParameters(text, font, rect)) { return; } TextBlock block = new TextBlock(text, font, rect, options, alignment, direction); TextOutput.Print(ref block, color, Rasterizer); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (disposed) { throw new ObjectDisposedException(this.GetType().ToString()); } if (!ValidateParameters(text, font, rect)) { return(TextExtents.Empty); } TextBlock block = new TextBlock(text, font, rect, options, alignment, direction); return(Rasterizer.MeasureText(ref block)); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment) { return(Measure(text, font, rect, options, alignment, TextDirection.LeftToRight)); }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="position">The OpenTK.Vector2 that defines the position for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to print text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to print text.</param> public void Render(string text, Font font, Color color, Vector2 position, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { Render(text, font, color, new RectangleF(position.X, position.Y, 0, 0), options, alignment, direction); }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> public void Print(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options) { Print(text, font, color, rect, options, TextAlignment.Near, TextDirection.LeftToRight); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (disposed) throw new ObjectDisposedException(this.GetType().ToString()); if (!ValidateParameters(text, font, rect)) return TextExtents.Empty; TextBlock block = new TextBlock(text, font, rect, options, alignment, direction); return Rasterizer.MeasureText(ref block); }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to print text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to print text.</param> public void Print(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (disposed) throw new ObjectDisposedException(this.GetType().ToString()); if (!ValidateParameters(text, font, rect)) return; TextBlock block = new TextBlock(text, font, rect, options, alignment, direction); TextOutput.Print(ref block, color, Rasterizer); }
/// <summary> /// Prints text using the specified color and layout options. /// </summary> /// <param name="text">The System.String to print.</param> /// <param name="font">The System.Drawing.Font that will be used to print text.</param> /// <param name="color">The System.Drawing.Color that will be used to print text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to print text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to print text.</param> public void Render(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment) { Render(text, font, color, rect, options, alignment, TextDirection.LeftToRight); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <param name="direction">The OpenTK.Graphics.TextDirection that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment, TextDirection direction) { if (_disposed) { throw new ObjectDisposedException(this.GetType().ToString()); } Contract.Requires(!string.IsNullOrEmpty(text)); Contract.Requires(font != null); Contract.Requires((rect.Width >= 0) && (rect.Height >= 0)); var block = new TextBlock(text, font, rect, options, alignment, direction); return Rasterizer.MeasureText(ref block); }
/// <summary> /// Measures text using the specified layout options. /// </summary> /// <param name="text">The System.String to measure.</param> /// <param name="font">The System.Drawing.Font that will be used to measure text.</param> /// <param name="rect">The System.Drawing.Rectangle that defines the bounds for text layout.</param> /// <param name="options">The OpenTK.Graphics.TextPrinterOptions that will be used to measure text.</param> /// <param name="alignment">The OpenTK.Graphics.TextAlignment that will be used to measure text.</param> /// <returns>An OpenTK.Graphics.TextExtents instance that contains the results of the measurement.</returns> public TextExtents Measure(string text, Font font, RectangleF rect, TextPrinterOptions options, TextAlignment alignment) { return Measure(text, font, rect, options, alignment, TextDirection.LeftToRight); }