/// <summary> /// Draws the text using the default resolution of <value>72dpi</value> onto the the image filled via the brush then outlined via the pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> /// <param name="location">The location.</param> /// <param name="options">The options.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, string text, Font font, IBrush <TPixel> brush, IPen <TPixel> pen, PointF location, TextGraphicsOptions options) where TPixel : struct, IPixel <TPixel> { float dpiX = DefaultTextDpi; float dpiY = DefaultTextDpi; var style = new RendererOptions(font, dpiX, dpiY, location) { ApplyKerning = options.ApplyKerning, TabWidth = options.TabWidth, WrappingWidth = options.WrapTextWidth, HorizontalAlignment = options.HorizontalAlignment, VerticalAlignment = options.VerticalAlignment }; IPathCollection glyphs = TextBuilder.GenerateGlyphs(text, style); var pathOptions = (GraphicsOptions)options; if (brush != null) { source.Fill(brush, glyphs, pathOptions); } if (pen != null) { source.Draw(pen, glyphs, pathOptions); } return(source); }
/// <summary> /// Draws the text onto the the image filled via the brush. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="location">The location.</param> /// <param name="options">The options.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, string text, Font font, IBrush <TPixel> brush, PointF location, TextGraphicsOptions options) where TPixel : struct, IPixel <TPixel> => source.DrawText(text, font, brush, null, location, options);
/// <summary> /// Draws the text onto the the image filled via the brush. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="path">The path.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush <TPixel> brush, IPath path) where TPixel : struct, IPixel <TPixel> => source.DrawText(options, text, font, brush, null, path);
/// <summary> /// Draws the text onto the the image filled via the brush. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="color">The color.</param> /// <param name="path">The path.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, TextGraphicsOptions options, string text, Font font, TPixel color, IPath path) where TPixel : struct, IPixel <TPixel> => source.DrawText(options, text, font, Brushes.Solid(color), null, path);
/// <summary> /// Draws the text onto the the image outlined via the pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="pen">The pen.</param> /// <param name="path">The path.</param> /// <param name="options">The options.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, string text, Font font, IPen <TPixel> pen, IPath path, TextGraphicsOptions options) where TPixel : struct, IPixel <TPixel> => source.DrawText(text, font, null, pen, path, options);
/// <summary> /// Draws the text onto the the image outlined via the pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="pen">The pen.</param> /// <param name="location">The location.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, TextGraphicsOptions options, string text, Font font, IPen <TPixel> pen, PointF location) where TPixel : struct, IPixel <TPixel> => source.DrawText(options, text, font, null, pen, location);
/// <summary> /// Draws the text using the default resolution of <value>72dpi</value> onto the the image filled via the brush then outlined via the pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> /// <param name="location">The location.</param> /// <returns> /// The <see cref="Image{TPixel}" />. /// </returns> public static IImageProcessingContext <TPixel> DrawText <TPixel>(this IImageProcessingContext <TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush <TPixel> brush, IPen <TPixel> pen, PointF location) where TPixel : struct, IPixel <TPixel> => source.ApplyProcessor(new DrawTextProcessor <TPixel>(options, text, font, brush, pen, location));