diff --git a/MaddoShared/ImageCreatorAlternate.cs b/MaddoShared/ImageCreatorAlternate.cs index ecbe6ac..476b9be 100644 --- a/MaddoShared/ImageCreatorAlternate.cs +++ b/MaddoShared/ImageCreatorAlternate.cs @@ -271,8 +271,16 @@ public class ImageCreatorAlternate : IImageCreator // Ensure we're drawing inside the canvas vertically if (y + finalFont.Size < 0 || y > working.Height) continue; - ctx.DrawText(line, finalFont, shadowColor, new SixLabors.ImageSharp.PointF(originX + 1, y + 1)); - ctx.DrawText(line, finalFont, textColor, new SixLabors.ImageSharp.PointF(originX, y)); + // Center each line individually so multi-line (vertical) text is justified to center + var approxWidthLine = finalFont.Size * (line?.Length ?? 0) * 0.6f; + if (approxWidthLine > working.Width) + approxWidthLine = working.Width * 0.95f; + + var x = xCenterOfImg - (approxWidthLine / 2f); + x = Math.Max(0, Math.Min(x, working.Width - approxWidthLine)); + + ctx.DrawText(line, finalFont, shadowColor, new SixLabors.ImageSharp.PointF(x + 1, y + 1)); + ctx.DrawText(line, finalFont, textColor, new SixLabors.ImageSharp.PointF(x, y)); } }); }