C
chris.dannemiller
I have the following code
public static IntPtr CreateFont ( Font fnt )
{
LOGFONT logFont = new LOGFONT();
logFont.lfFaceName = fnt.Name;
logFont.lfHeight = -Win32API.MulDiv((int)fnt.Size,
Win32API.GetDeviceCaps(Win32API.GetDC(0), LOGPIXELSY), 72);
logFont.lfItalic = (byte) ((fnt.Italic) ? (0x01)0x00));
logFont.lfStrikeOut = (byte) ((fnt.Strikeout) ? (0x01)0x00));
logFont.lfUnderline = (byte) ((fnt.Underline) ? (0x01)0x00));
if ( fnt.Bold )
logFont.lfWeight = 800;
else
logFont.lfWeight = 400;
return Win32API.CreateFontIndirect ( logFont );
}
This attempts to create a HFONT from a Font. I tried ToHFont as well.
It works on some displays but on other displays the font looks
completly distored when it is created this way. What I am doing wrong?
I need to do this so I can underline leading and trailing spaces.
public static IntPtr CreateFont ( Font fnt )
{
LOGFONT logFont = new LOGFONT();
logFont.lfFaceName = fnt.Name;
logFont.lfHeight = -Win32API.MulDiv((int)fnt.Size,
Win32API.GetDeviceCaps(Win32API.GetDC(0), LOGPIXELSY), 72);
logFont.lfItalic = (byte) ((fnt.Italic) ? (0x01)0x00));
logFont.lfStrikeOut = (byte) ((fnt.Strikeout) ? (0x01)0x00));
logFont.lfUnderline = (byte) ((fnt.Underline) ? (0x01)0x00));
if ( fnt.Bold )
logFont.lfWeight = 800;
else
logFont.lfWeight = 400;
return Win32API.CreateFontIndirect ( logFont );
}
This attempts to create a HFONT from a Font. I tried ToHFont as well.
It works on some displays but on other displays the font looks
completly distored when it is created this way. What I am doing wrong?
I need to do this so I can underline leading and trailing spaces.