All pastes #503463 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-22 21:43 UTC
rendered paste body
		internal override bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent) {
			IntPtr		dc;
			TEXTMETRIC	tm;

			tm = new TEXTMETRIC();

			dc = Win32GetDC(IntPtr.Zero);
			Win32SelectObject(dc, font.ToHfont());   <-- Crashes here
			if (Win32GetTextMetrics(dc, ref tm) == false) {
				Win32ReleaseDC(IntPtr.Zero, dc);
				ascent = 0;
				descent = 0;
				return false;
			}
			Win32ReleaseDC(IntPtr.Zero, dc);

			ascent = tm.tmAscent;
			descent = tm.tmDescent;

			return true;
		}