/// <include file='doc\Font.uex' path='docs/doc[@for="Font.ToHfont"]/*' /> /// <devdoc> /// Returns a handle to this <see cref='System.Drawing.Font'/>. /// </devdoc> public IntPtr ToHfont() { SafeNativeMethods.LOGFONT lf = new SafeNativeMethods.LOGFONT(); IntSecurity.ObjectFromWin32Handle.Assert(); try { this.ToLogFont(lf); } finally { System.Security.CodeAccessPermission.RevertAssert(); } IntPtr handle = SafeNativeMethods.CreateFontIndirect(lf); if (handle == IntPtr.Zero) { throw new Win32Exception(); } return(handle); }