/// <summary> /// Prints the specified text with the given maximum size, alignment and render options /// </summary> /// <param name="font">The <see cref="QFont"/> to print the text with</param> /// <param name="text">The text to print</param> /// <param name="position">The position of the text</param> /// <param name="maxSize">The maximum bounding size of the text</param> /// <param name="alignment">The text alignment</param> /// <param name="opt">The render options</param> /// <returns>The size of the printed text</returns> public SizeF Print(QFont font, string text, Vector3 position, SizeF maxSize, QFontAlignment alignment, QFontRenderOptions opt) { var dp = new QFontDrawingPrimitive(font, opt); DrawingPrimitives.Add(dp); return(dp.Print(text, position, maxSize, alignment, opt.ClippingRectangle)); }
/// <summary> /// Prints the specified text with the given render options /// </summary> /// <param name="font">The <see cref="QFont"/> to print the text with</param> /// <param name="text">The text to print</param> /// <param name="position">The position of the text</param> /// <param name="opt">The text render options</param> /// <returns>The size of the printed text</returns> public SizeF Print(QFont font, ProcessedText text, Vector3 position, QFontRenderOptions opt) { var dp = new QFontDrawingPrimitive(font, opt); DrawingPrimitives.Add(dp); return(dp.Print(text, position, opt.ClippingRectangle)); }
/// <summary> /// Prints the specified text with the given maximum size, alignment and clipping rectangle /// </summary> /// <param name="font">The <see cref="QFont"/> to print the text with</param> /// <param name="text">The text to print</param> /// <param name="position">The position of the text</param> /// <param name="maxSize">The maximum bounding size of the text</param> /// <param name="alignment">The text alignment</param> /// <param name="clippingRectangle">The clipping rectangle to scissor test the text with</param> /// <returns>The size of the printed text</returns> public SizeF Print(QFont font, string text, Vector3 position, SizeF maxSize, QFontAlignment alignment, Rectangle clippingRectangle = default(Rectangle)) { var dp = new QFontDrawingPrimitive(font); DrawingPrimitives.Add(dp); return(dp.Print(text, position, maxSize, alignment, clippingRectangle)); }
/// <summary> /// Prints the specified text /// </summary> /// <param name="font">The <see cref="QFont"/> to print the text with</param> /// <param name="processedText">The processed text to print</param> /// <param name="position">The position of the text</param> /// <param name="colour">The colour of the text</param> /// <returns>The size of the printed text</returns> public SizeF Print(QFont font, ProcessedText processedText, Vector3 position, Color?colour = null) { var dp = new QFontDrawingPrimitive(font); DrawingPrimitives.Add(dp); return(colour.HasValue ? dp.Print(processedText, position, colour.Value) : dp.Print(processedText, position)); }
public static void AddText(this QFontDrawingPrimitive dp, string text, Vector2 position, StringAlignment vAlign = StringAlignment.Near, StringAlignment hAlign = StringAlignment.Near, float zDepth = 0f) { AddText(dp, text, new RectangleF(position.X, position.Y, 0, 0), vAlign, hAlign, zDepth); }
/// <summary> /// Prints the specified text with the given alignment, color and clipping rectangle /// </summary> /// <param name="font">The <see cref="QFont"/> to print the text with</param> /// <param name="text">The text to print</param> /// <param name="position">The position of the text</param> /// <param name="alignment">The alignment of the text</param> /// <param name="color">The colour of the text</param> /// <param name="clippingRectangle">The clipping rectangle to scissor test the text with</param> /// <returns>The size of the printed text</returns> public SizeF Print(QFont font, string text, Vector3 position, QFontAlignment alignment, Color?color = null, Rectangle clippingRectangle = default(Rectangle)) { var dp = new QFontDrawingPrimitive(font); DrawingPrimitives.Add(dp); if (color.HasValue) { return(dp.Print(text, position, alignment, color.Value, clippingRectangle)); } return(dp.Print(text, position, alignment, clippingRectangle)); }
public static void AddText(this QFontDrawing renderer, string text, QFont font, Color color, RectangleF bounds, StringAlignment vAlign = StringAlignment.Near, StringAlignment hAlign = StringAlignment.Near) { var dp = new QFontDrawingPrimitive(font, new QFontRenderOptions() { Colour = color, LockToPixel = true }); AddText(dp, text, bounds, vAlign, hAlign); }
public SizeF Print(QFont font, ProcessedText processedText, Vector3 position, Color?colour = null, Rectangle clippingRectangle = default(Rectangle)) { var dp = new QFontDrawingPrimitive(font); DrawingPrimitives.Add(dp); if (colour.HasValue) { return(dp.Print(processedText, position, colour.Value)); } else { return(dp.Print(processedText, position)); } }
/// <summary> /// Measures the specified text. Helper method delegating functionality. /// </summary> /// <param name="text">The text.</param> /// <param name="alignment">The alignment.</param> /// <returns> /// Measured size. /// </returns> public SizeF Measure(string text, QFontAlignment alignment = QFontAlignment.Left) { var test = new QFontDrawingPrimitive(this); return(test.Measure(text, alignment)); }
/// <summary> /// Measures the specified text. Helper method delegating functionality. /// </summary> /// <param name="processedText">The processed text.</param> /// <returns> /// Measured size. /// </returns> public SizeF Measure(ProcessedText processedText) { var test = new QFontDrawingPrimitive(this); return(test.Measure(processedText)); }
/// <summary> /// Measures the specified text. Helper method delegating functionality. /// </summary> /// <param name="text">The text.</param> /// <param name="maxWidth">The maximum width.</param> /// <param name="alignment">The alignment.</param> /// <returns> /// Measured size. /// </returns> public SizeF Measure(string text, float maxWidth, QFontAlignment alignment) { var test = new QFontDrawingPrimitive(this); return(test.Measure(text, maxWidth, alignment)); }
public static void AddText(this QFontDrawingPrimitive dp, string text, RectangleF bounds, StringAlignment vAlign = StringAlignment.Near, StringAlignment hAlign = StringAlignment.Near, float zDepth = 0f) { bool noBounds = bounds.Size.IsEmpty; var textSize = dp.Font.Measure(text, noBounds ? new SizeF(9999, 9999) : bounds.Size, QFontAlignment.Left); textSize.Height += 2; if (bounds.Size.IsEmpty) { bounds = new RectangleF(bounds.X, bounds.Y, textSize.Width, textSize.Height); } var textPos = Vector2.Zero; switch (hAlign) { case StringAlignment.Near: textPos.X = bounds.X; break; case StringAlignment.Far: if (noBounds) { textPos.X = bounds.Left - textSize.Width; } else { textPos.X = bounds.Right - textSize.Width; } break; case StringAlignment.Center: if (noBounds) { textPos.X = bounds.Left - (textSize.Width / 2f); } else { textPos.X = bounds.Left + ((bounds.Width - textSize.Width) / 2f); } break; } switch (vAlign) { case StringAlignment.Near: textPos.Y = bounds.Y; break; case StringAlignment.Far: if (noBounds) { textPos.Y = bounds.Y + textSize.Height; } else { textPos.Y = bounds.Y - bounds.Height + textSize.Height; } break; case StringAlignment.Center: if (noBounds) { textPos.Y = bounds.Y + (textSize.Height / 2f); } else { textPos.Y = bounds.Y - ((bounds.Height - textSize.Height) / 2f); } break; } dp.Print(text, new Vector3(textPos.X, textPos.Y, zDepth), bounds.Size, QFontAlignment.Left); }