/// <summary> /// Creates a <see cref="Font"/> from the specified handle to a device context (HDC). /// </summary> /// <returns>The newly created <see cref="Font"/>.</returns> public static Font FromHdc(IntPtr hdc) { IntPtr font = IntPtr.Zero; int status = Gdip.GdipCreateFontFromDC(hdc, ref font); // Special case this incredibly common error message to give more information if (status == Gdip.NotTrueTypeFont) { throw new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName); } else if (status != Gdip.Ok) { throw Gdip.StatusException(status); } return(new Font(font, 0, false)); }