I have a weird problem with drawing fonts in C#. Basically I followed the steps in this blog https://web.archive.org/web/20141224204810/http://bobpowell.net/embedfonts.aspx to load the font. Everything works fine, but sometimes when I load the application the text gets messy like this picture: http://oi41.tinypic.com/20jphkx.jpg
Anyone has any idea what's happening?
P.S: Here is how I load the font
_fonts = new PrivateFontCollection();
byte[] fontData = Properties.Resources.PlacardMTCondensed;
IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length);
Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
_fonts.AddMemoryFont(fontPtr, fontData.Length);
Marshal.FreeCoTaskMem(fontPtr);
And here is how I try to use it in OnPain event:
g.DrawString(stBuilder.ToString(), "Something", blackBrush, 0, 0);