Skip to content

Commit 5703f58

Browse files
committed
Access list of paths directly in RichTextGlyphRenderer
1 parent 0dbfc38 commit 5703f58

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/ImageSharp.Drawing/Processing/Processors/Text/RichTextGlyphRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected override void EndGlyph()
292292
}
293293

294294
// Path has already been added to the collection via the base class.
295-
IPath path = this.Paths.Last();
295+
IPath path = this.PathList[^1];
296296
Point renderLocation = ClampToPixel(path.Bounds.Location);
297297
if (this.noCache || this.rasterizationRequired)
298298
{

src/ImageSharp.Drawing/Shapes/InternalPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private static PointData[] Simplify(ReadOnlySpan<PointF> points, bool isClosed,
332332
if (isClosed && removeCloseAndCollinear)
333333
{
334334
// walk back removing collinear points
335-
while (results.Count > 2 && results.Last().Orientation == PointOrientation.Collinear)
335+
while (results.Count > 2 && results[^1].Orientation == PointOrientation.Collinear)
336336
{
337337
results.RemoveAt(results.Count - 1);
338338
}

src/ImageSharp.Drawing/Shapes/Text/BaseGlyphBuilder.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace SixLabors.ImageSharp.Drawing.Text;
1212
/// </summary>
1313
internal class BaseGlyphBuilder : IGlyphRenderer
1414
{
15-
private readonly List<IPath> paths = new();
1615
private Vector2 currentPoint;
1716
private GlyphRendererParameters parameters;
1817

@@ -27,10 +26,12 @@ internal class BaseGlyphBuilder : IGlyphRenderer
2726
/// <param name="transform">The default transform.</param>
2827
public BaseGlyphBuilder(Matrix3x2 transform) => this.Builder = new PathBuilder(transform);
2928

29+
protected List<IPath> PathList { get; } = new();
30+
3031
/// <summary>
3132
/// Gets the paths that have been rendered by the current instance.
3233
/// </summary>
33-
public IPathCollection Paths => new PathCollection(this.paths);
34+
public IPathCollection Paths => new PathCollection(this.PathList.ToArray());
3435

3536
/// <summary>
3637
/// Gets the path builder for the current instance.
@@ -74,7 +75,7 @@ void IGlyphRenderer.CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdContr
7475
/// </summary>
7576
void IGlyphRenderer.EndGlyph()
7677
{
77-
this.paths.Add(this.Builder.Build());
78+
this.PathList.Add(this.Builder.Build());
7879
this.EndGlyph();
7980
}
8081

0 commit comments

Comments
 (0)