if (GetCharWidthFloat(graphics.GetHdc(), ch, ch, out widthPtr) == 1)
if (widthPtr != IntPtr.Zero)
Marshal.Copy(widthPtr, widthOfChar, 0, 1);
static private extern int GetCharWidthFloat(IntPtr hcd, uint first, uint last, out IntPtr widthsBuffer);
At Marshal.Copy it throws exception: Exception System.AccessViolationException was thrown in debuggee: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.