diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs
deleted file mode 100644
index 827d6b95f..000000000
--- a/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using SixLabors.Fonts;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
-using SixLabors.ImageSharp.Processing.Text.Processors;
-using SixLabors.Shapes;
-
-namespace SixLabors.ImageSharp.Processing.Text
-{
- ///
- /// Adds extensions that allow the drawing of text along given paths to the type.
- ///
- public static partial class DrawTextExtensions
- {
- ///
- /// Draws the text onto the the image filled via the brush.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The text.
- /// The font.
- /// The color.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- string text,
- Font font,
- TPixel color,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(TextGraphicsOptions.Default, text, font, color, path);
-
- ///
- /// Draws the text onto the the image filled via the brush.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The options.
- /// The text.
- /// The font.
- /// The color.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- TextGraphicsOptions options,
- string text,
- Font font,
- TPixel color,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(options, text, font, Brushes.Solid(color), null, path);
-
- ///
- /// Draws the text onto the the image filled via the brush.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The text.
- /// The font.
- /// The brush.
- /// The location.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- string text,
- Font font,
- IBrush brush,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(TextGraphicsOptions.Default, text, font, brush, path);
-
- ///
- /// Draws the text onto the the image filled via the brush.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The options.
- /// The text.
- /// The font.
- /// The brush.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- TextGraphicsOptions options,
- string text,
- Font font,
- IBrush brush,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(options, text, font, brush, null, path);
-
- ///
- /// Draws the text onto the the image outlined via the pen.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The text.
- /// The font.
- /// The pen.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- string text,
- Font font,
- IPen pen,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(TextGraphicsOptions.Default, text, font, pen, path);
-
- ///
- /// Draws the text onto the the image outlined via the pen.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The options.
- /// The text.
- /// The font.
- /// The pen.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- TextGraphicsOptions options,
- string text,
- Font font,
- IPen pen,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(options, text, font, null, pen, path);
-
- ///
- /// Draws the text onto the the image filled via the brush then outlined via the pen.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The text.
- /// The font.
- /// The brush.
- /// The pen.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- string text,
- Font font,
- IBrush brush,
- IPen pen,
- IPath path)
- where TPixel : struct, IPixel =>
- source.DrawText(TextGraphicsOptions.Default, text, font, brush, pen, path);
-
- ///
- /// Draws the text onto the the image filled via the brush then outlined via the pen.
- ///
- /// The type of the color.
- /// The image this method extends.
- /// The options.
- /// The text.
- /// The font.
- /// The brush.
- /// The pen.
- /// The path.
- ///
- /// The .
- ///
- public static IImageProcessingContext DrawText(
- this IImageProcessingContext source,
- TextGraphicsOptions options,
- string text,
- Font font,
- IBrush brush,
- IPen pen,
- IPath path)
- where TPixel : struct, IPixel =>
- source.ApplyProcessor(new DrawTextOnPathProcessor(options, text, font, brush, pen, path));
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextOnPathProcessor.cs b/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextOnPathProcessor.cs
deleted file mode 100644
index 1e703d1cc..000000000
--- a/src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextOnPathProcessor.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System;
-using System.Threading.Tasks;
-using SixLabors.Fonts;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Primitives;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
-using SixLabors.ImageSharp.Processing.Drawing.Processors;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Primitives;
-using SixLabors.Shapes;
-
-namespace SixLabors.ImageSharp.Processing.Text.Processors
-{
- ///
- /// Using the brush as a source of pixels colors blends the brush color with source.
- ///
- /// The pixel format.
- internal class DrawTextOnPathProcessor : ImageProcessor
- where TPixel : struct, IPixel
- {
- private FillRegionProcessor fillRegionProcessor = null;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The options
- /// The text we want to render
- /// The font we want to render with
- /// The brush to source pixel colors from.
- /// The pen to outline text with.
- /// The path on which to draw the text along.
- public DrawTextOnPathProcessor(TextGraphicsOptions options, string text, Font font, IBrush brush, IPen pen, IPath path)
- {
- this.Brush = brush;
- this.Options = options;
- this.Text = text;
- this.Pen = pen;
- this.Font = font;
- this.Path = path;
- }
-
- ///
- /// Gets or sets the brush.
- ///
- public IBrush Brush { get; set; }
-
- ///
- /// Gets or sets the options
- ///
- private TextGraphicsOptions Options { get; set; }
-
- ///
- /// Gets or sets the text
- ///
- private string Text { get; set; }
-
- ///
- /// Gets or sets the pen used for outlining the text, if Null then we will not outline
- ///
- public IPen Pen { get; set; }
-
- ///
- /// Gets or sets the font used to render the text.
- ///
- public Font Font { get; set; }
-
- ///
- /// Gets or sets the path to draw the text along.
- ///
- public IPath Path { get; set; }
-
- protected override void BeforeImageApply(Image source, Rectangle sourceRectangle)
- {
- base.BeforeImageApply(source, sourceRectangle);
-
- // do everythign at the image level as we are deligating the processing down to other processors
- var style = new RendererOptions(this.Font, this.Options.DpiX, this.Options.DpiY)
- {
- ApplyKerning = this.Options.ApplyKerning,
- TabWidth = this.Options.TabWidth,
- WrappingWidth = this.Path.Length,
- HorizontalAlignment = this.Options.HorizontalAlignment,
- VerticalAlignment = this.Options.VerticalAlignment
- };
-
- IPathCollection glyphs = TextBuilder.GenerateGlyphs(this.Text, this.Path, style);
- this.fillRegionProcessor = new FillRegionProcessor();
- this.fillRegionProcessor.Options = (GraphicsOptions)this.Options;
-
- if (this.Brush != null)
- {
- this.fillRegionProcessor.Brush = this.Brush;
-
- foreach (IPath p in glyphs)
- {
- this.fillRegionProcessor.Region = new ShapeRegion(p);
- this.fillRegionProcessor.Apply(source, sourceRectangle);
- }
- }
-
- if (this.Pen != null)
- {
- this.fillRegionProcessor.Brush = this.Pen.StrokeFill;
-
- foreach (IPath p in glyphs)
- {
- this.fillRegionProcessor.Region = new ShapePath(p, this.Pen);
- this.fillRegionProcessor.Apply(source, sourceRectangle);
- }
- }
- }
-
- ///
- protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
- {
- // this is a no-op as we have processes all as an image, we should be able to pass out of before email apply a skip frames outcome
- }
- }
-}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
deleted file mode 100644
index d352489b8..000000000
--- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System.Numerics;
-using SixLabors.Fonts;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
-using SixLabors.ImageSharp.Processing.Drawing.Processors;
-using SixLabors.ImageSharp.Processing.Text;
-using SixLabors.ImageSharp.Processing.Text.Processors;
-using SixLabors.Shapes;
-using Xunit;
-
-namespace SixLabors.ImageSharp.Tests.Drawing.Text
-{
- public class DrawText_Path : BaseImageOperationsExtensionTest
- {
- Rgba32 color = Rgba32.HotPink;
-
- SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
-
- IPath path = new SixLabors.Shapes.Path(
- new LinearLineSegment(
- new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), }));
-
- private readonly FontCollection FontCollection;
-
- private readonly Font Font;
-
- public DrawText_Path()
- {
- this.FontCollection = new FontCollection();
- this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenBrushSetAndNotPen()
- {
- this.operations.DrawText(
- new TextGraphicsOptions(true),
- "123",
- this.Font,
- Brushes.Solid(Rgba32.Red),
- null,
- this.path);
-
- this.Verify>(0);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, this.path);
-
- this.Verify>(0);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenBrushSet()
- {
- this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Rgba32.Red), this.path);
-
- this.Verify>(0);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenBrushSetDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), this.path);
-
- this.Verify>(0);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenColorSet()
- {
- this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Rgba32.Red, this.path);
-
- var processor = this.Verify>(0);
-
- SolidBrush brush = Assert.IsType>(processor.Brush);
- Assert.Equal(Rgba32.Red, brush.Color);
- }
-
- [Fact]
- public void FillsForEachACharachterWhenColorSetDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, Rgba32.Red, this.path);
-
- DrawTextOnPathProcessor processor = this.Verify>(0);
-
- SolidBrush brush = Assert.IsType>(processor.Brush);
- Assert.Equal(Rgba32.Red, brush.Color);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSetAndNotBrush()
- {
- this.operations.DrawText(
- new TextGraphicsOptions(true),
- "123",
- this.Font,
- null,
- Pens.Dash(Rgba32.Red, 1),
- this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSet()
- {
- this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSetDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path);
-
- DrawTextOnPathProcessor processor = this.Verify>(0);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet()
- {
- this.operations.DrawText(
- new TextGraphicsOptions(true),
- "123",
- this.Font,
- Brushes.Solid(Rgba32.Red),
- Pens.Dash(Rgba32.Red, 1),
- this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions()
- {
- this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void BrushAppliesBeforPen()
- {
- this.operations.DrawText(
- new TextGraphicsOptions(true),
- "1",
- this.Font,
- Brushes.Solid(Rgba32.Red),
- Pens.Dash(Rgba32.Red, 1),
- this.path);
-
- var processor = this.Verify>(0);
- }
-
- [Fact]
- public void BrushAppliesBeforPenDefaultOptions()
- {
- this.operations.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), this.path);
-
- var processor = this.Verify>(0);
- }
- }
-}
diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
index abb384ffb..3ceba0838 100644
--- a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
@@ -159,88 +159,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
appendSourceFileOrDescription: true);
}
- [Theory]
- [WithSolidFilledImages(200, 100, "White", PixelTypes.Rgba32, 50, "SixLaborsSampleAB.woff", AB)]
- [WithSolidFilledImages(900, 100, "White", PixelTypes.Rgba32, 50, "OpenSans-Regular.ttf", TestText)]
- public void FontShapesAreRenderedCorrectlyAlongAPath(
- TestImageProvider provider,
- int fontSize,
- string fontName,
- string text)
- where TPixel : struct, IPixel
- {
- Font font = CreateFont(fontName, fontSize);
- TPixel colorFill = NamedColors.Gray;
- TPixel colorOutline = NamedColors.Black;
- IBrush fillBrush = Brushes.Solid(colorFill);
- IPen outlinePen = Pens.DashDot(colorOutline, 3);
-
- provider.VerifyOperation(
- OutlinedTextDrawingComparer,
- img =>
- {
- IPath path = new Path(new LinearLineSegment(new Point(0, img.Height), new Point(img.Width, 0)));
- img.Mutate(
- c =>
- {
- c.DrawText(
- new TextGraphicsOptions
- {
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Top
- },
- text,
- new Font(font, fontSize),
- fillBrush,
- outlinePen,
- path);
- });
- },
- $"pen_{fontName}-{fontSize}-{ToTestOutputDisplayText(text)}",
- appendPixelTypeToFileName: false,
- appendSourceFileOrDescription: true);
- }
-
- [Theory]
- [WithSolidFilledImages(600, 600, "White", PixelTypes.Rgba32, 50, "OpenSans-Regular.ttf", TestText)]
- public void FontShapesAreRenderedCorrectlyAlongACirclePath(
- TestImageProvider provider,
- int fontSize,
- string fontName,
- string text)
- where TPixel : struct, IPixel
- {
- Font font = CreateFont(fontName, fontSize);
- TPixel colorFill = NamedColors.Black;
- IBrush fillBrush = Brushes.Solid(colorFill);
-
- provider.VerifyOperation(
- TextDrawingComparer,
- img =>
- {
- int w = (int)(img.Width * 0.6);
- int h = (int)(img.Height * 0.6);
- IPath path = new EllipsePolygon(img.Width/2, img.Height/2, w, h);
-
- img.Mutate(c =>
- {
- c.DrawText(
- new TextGraphicsOptions
- {
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Top
- },
- text,
- new Font(font, fontSize),
- fillBrush,
- path);
- });
- },
- $"pen_{fontName}-{fontSize}-{ToTestOutputDisplayText(text)}",
- appendPixelTypeToFileName: false,
- appendSourceFileOrDescription: true);
- }
-
private static string Repeat(string str, int times) => string.Concat(Enumerable.Repeat(str, times));
private static string ToTestOutputDisplayText(string text)