I am trying to annotate an image with Arabic text, but unfortunately, the letters are shown disconnected. I tried changing the text encoding, but the result does not change. Also, the text direction did not work with me when I tried setting it to "TextDirection.RightToLeft". The text still shows from left to right which is not correct in Arabic language.
However, when I use the Graphics class and DrawString method (in native ASP.NET), I get Arabic text correctly with no issues in encoding. But the issue with this approach is that I lose the image resolution and sometimes I get an image double the size of its original.
I would really appreciate if you could help me in resolving this encoding issue in Magick.NET.
I am using the code shown below.
Regards,
Menhal
using (MagickImageCollection images = new MagickImageCollection())
{
MagickImage logo = new MagickImage("logo:");
images.Add(logo);
MagickImage label = new MagickImage();
label.BackgroundColor = Color.Black;
label.FillColor= Color.White;
label.TextDirection = TextDirection.RightToLeft;
label.TextGravity = Gravity.East;
label.TextEncoding = Encoding.Unicode;
label.Read("label:" + "مرحبا بكم");
label.Extent(logo.Width, label.Height, Gravity.East);
images.Add(label);
using (MagickImage output = images.AppendVertically())
{
}
However, when I use the Graphics class and DrawString method (in native ASP.NET), I get Arabic text correctly with no issues in encoding. But the issue with this approach is that I lose the image resolution and sometimes I get an image double the size of its original.
I would really appreciate if you could help me in resolving this encoding issue in Magick.NET.
I am using the code shown below.
Regards,
Menhal
using (MagickImageCollection images = new MagickImageCollection())
{
MagickImage logo = new MagickImage("logo:");
images.Add(logo);
MagickImage label = new MagickImage();
label.BackgroundColor = Color.Black;
label.FillColor= Color.White;
label.TextDirection = TextDirection.RightToLeft;
label.TextGravity = Gravity.East;
label.TextEncoding = Encoding.Unicode;
label.Read("label:" + "مرحبا بكم");
label.Extent(logo.Width, label.Height, Gravity.East);
images.Add(label);
using (MagickImage output = images.AppendVertically())
{
output.Write("output-b.png");
}}