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;
> 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;