66using System . Linq ;
77using SixLabors . Fonts ;
88using SixLabors . Fonts . Unicode ;
9+ using SixLabors . ImageSharp . Drawing . Processing . Processors . Drawing ;
910using SixLabors . ImageSharp . Memory ;
1011using SixLabors . ImageSharp . PixelFormats ;
1112using SixLabors . ImageSharp . Processing . Processors ;
@@ -19,7 +20,8 @@ namespace SixLabors.ImageSharp.Drawing.Processing.Processors.Text
1920 internal class DrawTextProcessor < TPixel > : ImageProcessor < TPixel >
2021 where TPixel : unmanaged, IPixel < TPixel >
2122 {
22- private CachingGlyphRenderer textRenderer ;
23+ // private CachingGlyphRenderer textRenderer;
24+ private RichTextGlyphRenderer textRenderer ;
2325 private readonly DrawTextProcessor definition ;
2426
2527 public DrawTextProcessor ( Configuration configuration , DrawTextProcessor definition , Image < TPixel > source , Rectangle sourceRectangle )
@@ -31,16 +33,23 @@ protected override void BeforeImageApply()
3133 base . BeforeImageApply ( ) ;
3234
3335 // Do everything at the image level as we are delegating the processing down to other processors
34- this . textRenderer = new CachingGlyphRenderer (
35- this . Configuration . MemoryAllocator ,
36- this . definition . Text . GetGraphemeCount ( ) ,
36+ //this.textRenderer = new CachingGlyphRenderer(
37+ // this.Configuration.MemoryAllocator,
38+ // this.definition.Text.GetGraphemeCount(),
39+ // this.definition.TextOptions,
40+ // this.definition.Pen,
41+ // this.definition.Brush,
42+ // this.definition.DrawingOptions.Transform)
43+ //{
44+ // Options = this.definition.DrawingOptions
45+ //};
46+
47+ this . textRenderer = new RichTextGlyphRenderer (
3748 this . definition . TextOptions ,
49+ this . definition . DrawingOptions ,
50+ this . Configuration . MemoryAllocator ,
3851 this . definition . Pen ,
39- this . definition . Brush ,
40- this . definition . DrawingOptions . Transform )
41- {
42- Options = this . definition . DrawingOptions
43- } ;
52+ this . definition . Brush ) ;
4453
4554 TextRenderer renderer = new ( this . textRenderer ) ;
4655 renderer . RenderText ( this . definition . Text , this . definition . TextOptions ) ;
@@ -49,6 +58,17 @@ protected override void BeforeImageApply()
4958 protected override void AfterImageApply ( )
5059 {
5160 base . AfterImageApply ( ) ;
61+
62+ foreach ( var path in this . textRenderer . Paths )
63+ {
64+ new FillPathProcessor (
65+ this . definition . DrawingOptions ,
66+ new SolidBrush ( Color . HotPink . WithAlpha ( .5F ) ) ,
67+ path ) . Execute ( this . Configuration , this . Source , this . SourceRectangle ) ;
68+ }
69+
70+
71+
5272 this . textRenderer ? . Dispose ( ) ;
5373 this . textRenderer = null ;
5474 }
@@ -62,7 +82,7 @@ void Draw(IEnumerable<DrawingOperation> operations)
6282 {
6383 using BrushApplicator < TPixel > app = operation . Brush . CreateApplicator (
6484 this . Configuration ,
65- this . textRenderer . Options . GraphicsOptions ,
85+ this . definition . DrawingOptions . GraphicsOptions ,
6686 source ,
6787 this . SourceRectangle ) ;
6888
0 commit comments