libgdiplus icon indicating copy to clipboard operation
libgdiplus copied to clipboard

GraphicsPath.AddString is wrongly positioned on Linux

Open hegdevnayak opened this issue 5 years ago • 5 comments

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 lorem-ipsum-dolor-sit-ame_small (1)

And on windows lorem-ipsum-dolor-sit-ame_small

hegdevnayak avatar May 24 '20 10:05 hegdevnayak

What version of libgdiplus is installed on the system?

filipnavara avatar May 24 '20 10:05 filipnavara

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?

hegdevnayak avatar May 24 '20 11:05 hegdevnayak

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.

qmfrederik avatar May 24 '20 11:05 qmfrederik

Ok, Upgraded to 6.0.5-0xamarin1+ubuntu1804b1... Still left aligned

hegdevnayak avatar May 24 '20 11:05 hegdevnayak

Center align works for Graphics.DrawString, the issue is only on GraphicsPath.AddString

hegdevnayak avatar May 24 '20 11:05 hegdevnayak