libgdiplus
libgdiplus copied to clipboard
GraphicsPath.AddString is wrongly positioned on Linux
Using .net core 3.1 and System.drawing 4.7. StringAlignment.Center works on windows, but in Linux, it is always left-aligned.
Pen p = new Pen(Color, 4){ LineJoin = LineJoin.Round };
var format= new StringFormat()
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center,
};
Graphics drawing = Graphics.FromImage(img);
var rect = new Rectangle(0, 0, img.Width, img.Height);
GraphicsPath gp = new GraphicsPath();
gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, rect, format);
.DrawPath(p, gp);
that.FillPath(brush, gp);
Here is the result on Linux

And on windows

What version of libgdiplus is installed on the system?
sorry... My bad. Ubuntu saying "libgdiplus is already the newest version (4.2-2)" I didn't check what is the latest version before raising the issue.
But why is so old, why apt-get saying its newest version. What is the best way to upgrade?
The easiest way is to add the Moni apt repositories to your system, and then run apt-get update and upgrade.
https://www.mono-project.com/download/stable/#download-lin
You don't need to install Mono, just libgdiplus from the Mono repositories.
Ok, Upgraded to 6.0.5-0xamarin1+ubuntu1804b1... Still left aligned
Center align works for Graphics.DrawString, the issue is only on GraphicsPath.AddString