mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
333 stars 171 forks source link

GraphicsPath.AddString is wrongly positioned on Linux #652

Open hegdevnayak opened 4 years ago

hegdevnayak commented 4 years ago

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

filipnavara commented 4 years ago

What version of libgdiplus is installed on the system?

hegdevnayak commented 4 years ago

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?

qmfrederik commented 4 years ago

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.

hegdevnayak commented 4 years ago

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

hegdevnayak commented 4 years ago

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