예제 #1
0
 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;
 }
예제 #2
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);
        }
예제 #3
0
        /// <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));
        }
예제 #4
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 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);
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
 /// <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));
 }
예제 #7
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="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);
 }
예제 #8
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>
 public void Print(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options)
 {
     Print(text, font, color, rect, options, TextAlignment.Near, TextDirection.LeftToRight);
 }
예제 #9
0
        /// <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);
        }
예제 #10
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 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);
        }
예제 #11
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>
		public void Render(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment)
		{
			Render(text, font, color, rect, options, alignment, TextDirection.LeftToRight);
		}
예제 #12
0
		/// <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);
		}
예제 #13
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);
		}
예제 #14
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="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);
		}
예제 #15
0
 /// <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);
 }
예제 #16
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>
 public void Render(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options, TextAlignment alignment)
 {
     Render(text, font, color, rect, options, alignment, TextDirection.LeftToRight);
 }
예제 #17
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>
 public void Print(string text, Font font, Color color, RectangleF rect, TextPrinterOptions options)
 {
     Print(text, font, color, rect, options, TextAlignment.Near, TextDirection.LeftToRight);
 }