Skip to content

Commit 159e672

Browse files
Update enum names
1 parent 5f11770 commit 159e672

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,42 +211,42 @@ public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, TextDrawi
211211

212212
public void BeginFigure() => this.builder.StartFigure();
213213

214-
public TextDecoration EnabledDecorations()
214+
public TextDecorations EnabledDecorations()
215215
{
216-
var decorations = this.currentTextRun.TextDecorations;
216+
TextDecorations decorations = this.currentTextRun.TextDecorations;
217217
if (this.currentTextRun is TextDrawingRun drawingRun)
218218
{
219219
if (drawingRun.UnderlinePen != null)
220220
{
221-
decorations |= TextDecoration.Underline;
221+
decorations |= TextDecorations.Underline;
222222
}
223223

224224
if (drawingRun.StrikeoutPen != null)
225225
{
226-
decorations |= TextDecoration.Strikeout;
226+
decorations |= TextDecorations.Strikeout;
227227
}
228228

229229
if (drawingRun.OverlinePen != null)
230230
{
231-
decorations |= TextDecoration.Overline;
231+
decorations |= TextDecorations.Overline;
232232
}
233233
}
234234

235235
return decorations;
236236
}
237237

238-
public void SetDecoration(TextDecoration textDecoration, Vector2 start, Vector2 end, float thickness)
238+
public void SetDecoration(TextDecorations textDecorations, Vector2 start, Vector2 end, float thickness)
239239
{
240-
ref var targetDecoration = ref this.currentStrikout;
241-
if (textDecoration == TextDecoration.Strikeout)
240+
ref TextDecorationDetails? targetDecoration = ref this.currentStrikout;
241+
if (textDecorations == TextDecorations.Strikeout)
242242
{
243243
targetDecoration = ref this.currentStrikout;
244244
}
245-
else if (textDecoration == TextDecoration.Underline)
245+
else if (textDecorations == TextDecorations.Underline)
246246
{
247247
targetDecoration = ref this.currentUnderline;
248248
}
249-
else if (textDecoration == TextDecoration.Overline)
249+
else if (textDecorations == TextDecorations.Overline)
250250
{
251251
targetDecoration = ref this.currentOverline;
252252
}
@@ -258,20 +258,21 @@ public void SetDecoration(TextDecoration textDecoration, Vector2 start, Vector2
258258
IPen pen = null;
259259
if (this.currentTextRun is TextDrawingRun drawingRun)
260260
{
261-
if (textDecoration == TextDecoration.Strikeout)
261+
if (textDecorations == TextDecorations.Strikeout)
262262
{
263263
pen = drawingRun.StrikeoutPen ?? pen;
264264
}
265-
else if (textDecoration == TextDecoration.Underline)
265+
else if (textDecorations == TextDecorations.Underline)
266266
{
267267
pen = drawingRun.UnderlinePen ?? pen;
268268
}
269-
else if (textDecoration == TextDecoration.Overline)
269+
else if (textDecorations == TextDecorations.Overline)
270270
{
271271
pen = drawingRun.OverlinePen;
272272
}
273273
}
274274

275+
// TODO:Isn't this already handled in font via GetEnds?
275276
//fix up the thickness/Y position so that the line render nicly
276277
var thicknessOffset = new Vector2(0, thickness * .5f);
277278
var tl = start - thicknessOffset;

tests/ImageSharp.Drawing.Tests/Drawing/Text/DrawTextOnImageTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public void DrawRichText<TPixel>(
517517
{
518518
Start = 4,
519519
End = 10,
520-
TextDecorations = TextDecoration.Strikeout,
520+
TextDecorations = TextDecorations.Strikeout,
521521
StrikeoutPen = Pens.Solid(Color.Red),
522522
Brush = Brushes.Solid(Color.Red),
523523
},
@@ -527,15 +527,15 @@ public void DrawRichText<TPixel>(
527527
Start = 10,
528528
End = 13,
529529
Font = font2,
530-
TextDecorations = TextDecoration.Strikeout,
530+
TextDecorations = TextDecorations.Strikeout,
531531
StrikeoutPen = Pens.Solid(Color.White),
532532
},
533533

534534
new TextDrawingRun
535535
{
536536
Start = 19,
537537
End = 23,
538-
TextDecorations = TextDecoration.Underline,
538+
TextDecorations = TextDecorations.Underline,
539539
UnderlinePen = Pens.Dot(Color.Fuchsia, 2),
540540
Brush = Brushes.Solid(Color.Blue),
541541
},
@@ -544,7 +544,7 @@ public void DrawRichText<TPixel>(
544544
{
545545
Start = 23,
546546
End = 25,
547-
TextDecorations = TextDecoration.Underline,
547+
TextDecorations = TextDecorations.Underline,
548548
UnderlinePen = Pens.Solid(Color.White),
549549
}
550550
}
@@ -574,7 +574,7 @@ public void DrawRichTextArabic<TPixel>(
574574
WrappingLength = 400,
575575
TextRuns = new[]
576576
{
577-
new TextDrawingRun { Start = 0, End = CodePoint.GetCodePointCount(text.AsSpan()), TextDecorations = TextDecoration.Underline }
577+
new TextDrawingRun { Start = 0, End = CodePoint.GetCodePointCount(text.AsSpan()), TextDecorations = TextDecorations.Underline }
578578
}
579579
};
580580
provider.RunValidatingProcessorTest(

0 commit comments

Comments
 (0)