I am incorrectly receiving a MagicCoderErrorException when I use pango with any html entities. The Additional information is as follows:
> Additional information: Magick: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as & <markup><span color="#000000">LOOK !!!!&`amp`; HERE!!!</span></markup>
Removing the &`amp`; in the string causes the error to cease. A work around is instead to use &`#38`; for the ampersand. But if that's the case, the error message should be changed. Also any html entity causes this error so I have to replace them all.
My Exact code is below. Note that when testing I put an & character in the text variable which is then encoded by HttpUtility.HtmlEncode. Even if I remove HttpUtility.HtmlEncode and putting &`amp`; directly in the text variable, the error still occurs.
MagickImage img = new MagickImage(MagickColor.Transparent, size.Width, size.Height);
img.Font = fontName;
img.FontPointsize = 200;
img.FillColor = new MagickColor(color);
img.TextGravity = Gravity.Center;
img.StrokeColor = new MagickColor("#000");
img.Read(string.Format("pango:<markup><span color=\"{1}\">{0}</span></markup>", HttpUtility.HtmlEncode(text), color));
img.Trim();
return img;
Comments: ** Comment from web user: dlemstra **
> Additional information: Magick: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as & <markup><span color="#000000">LOOK !!!!&`amp`; HERE!!!</span></markup>
Removing the &`amp`; in the string causes the error to cease. A work around is instead to use &`#38`; for the ampersand. But if that's the case, the error message should be changed. Also any html entity causes this error so I have to replace them all.
My Exact code is below. Note that when testing I put an & character in the text variable which is then encoded by HttpUtility.HtmlEncode. Even if I remove HttpUtility.HtmlEncode and putting &`amp`; directly in the text variable, the error still occurs.
MagickImage img = new MagickImage(MagickColor.Transparent, size.Width, size.Height);
img.Font = fontName;
img.FontPointsize = 200;
img.FillColor = new MagickColor(color);
img.TextGravity = Gravity.Center;
img.StrokeColor = new MagickColor("#000");
img.Read(string.Format("pango:<markup><span color=\"{1}\">{0}</span></markup>", HttpUtility.HtmlEncode(text), color));
img.Trim();
return img;
Comments: ** Comment from web user: dlemstra **
It seems that the PANGO reader wants you to encode all the ampersands after you performed the HTML encode. The following works for me:
```C#
using (MagickImage img = new MagickImage())
{
img.Font = "Arial";
img.FontPointsize = 200;
img.FillColor = new MagickColor("red");
img.TextGravity = Gravity.Center;
img.StrokeColor = new MagickColor("#000");
string text = HttpUtility.HtmlEncode("O<&>K").Replace("&", "&");
img.Read(string.Format("pango:<span color=\"{1}\">{0}</span>", text, "red"));
img.Trim();
img.Write(@"C:\test.jpg");
}
```
I will close this issue, next time please start a topic here first: https://magick.codeplex.com/discussions