public static WindowsFont FromHfont(IntPtr hFont, bool takeOwnership) { IntNativeMethods.LOGFONT lp = new IntNativeMethods.LOGFONT(); IntUnsafeNativeMethods.GetObject(new HandleRef(null, hFont), lp); return(new WindowsFont(lp, false) { hFont = hFont, ownHandle = takeOwnership }); }
private void CreateFont() { this.hFont = IntUnsafeNativeMethods.CreateFontIndirect(this.logFont); if (this.hFont == IntPtr.Zero) { this.logFont.lfFaceName = "Microsoft Sans Serif"; this.logFont.lfOutPrecision = 7; this.hFont = IntUnsafeNativeMethods.CreateFontIndirect(this.logFont); } IntUnsafeNativeMethods.GetObject(new HandleRef(this, this.hFont), this.logFont); this.ownHandle = true; }