T
Tom Kazimiers
Hi there,
I need to rotate some Text and want to use LOGFONT for this. The
reason for this decision is that the App is compiled for compact
framwork but should also be compatible to the desktop. This means I
cannot use RotateTransform. So I took the LOGFONT-Structore from
pinvoke.net:
http://www.pinvoke.net/default.aspx/Structures/LOGFONT.html
I could instantiate a new Font like this:
LOGFONT lf = new LOGFONT();
int curDPI = (int)context.DpiY;
lf.lfHeight = (int)(-10f * context.DpiY / curDPI);
lf.lfCharSet = FontCharSet.DEFAULT_CHARSET;
lf.lfOutPrecision = FontPrecision.OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = FontClipPrecision.CLIP_DEFAULT_PRECIS;
lf.lfQuality = FontQuality.DEFAULT_QUALITY;
lf.lfPitchAndFamily = FontPitchAndFamily.FF_DONTCARE;
lf.lfFaceName = "Tahoma\0";
lf.lfEscapement = 2700;
lf.lfOrientation = lf.lfEscapement;
font = Font.FromLogFont((object)lf);
This gets me a new font, but if I use DrawString() with this font it
gets not rotated.
If I P/Invoke the GetFontIndirect-API the same results happen:
IntPtr handle = CreateFontIndirect(lf);
if (handle == IntPtr.Zero)
throw new ApplicationException("Could not create logical font.");
font = Font.FromHfont(handle);
In the compact framwork there is a already a LOGFONT class that I can
use, and with the same settings there it works.
Have you any hint what could be wrong with my approach?
Thanks in advance,
Tom
I need to rotate some Text and want to use LOGFONT for this. The
reason for this decision is that the App is compiled for compact
framwork but should also be compatible to the desktop. This means I
cannot use RotateTransform. So I took the LOGFONT-Structore from
pinvoke.net:
http://www.pinvoke.net/default.aspx/Structures/LOGFONT.html
I could instantiate a new Font like this:
LOGFONT lf = new LOGFONT();
int curDPI = (int)context.DpiY;
lf.lfHeight = (int)(-10f * context.DpiY / curDPI);
lf.lfCharSet = FontCharSet.DEFAULT_CHARSET;
lf.lfOutPrecision = FontPrecision.OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = FontClipPrecision.CLIP_DEFAULT_PRECIS;
lf.lfQuality = FontQuality.DEFAULT_QUALITY;
lf.lfPitchAndFamily = FontPitchAndFamily.FF_DONTCARE;
lf.lfFaceName = "Tahoma\0";
lf.lfEscapement = 2700;
lf.lfOrientation = lf.lfEscapement;
font = Font.FromLogFont((object)lf);
This gets me a new font, but if I use DrawString() with this font it
gets not rotated.
If I P/Invoke the GetFontIndirect-API the same results happen:
IntPtr handle = CreateFontIndirect(lf);
if (handle == IntPtr.Zero)
throw new ApplicationException("Could not create logical font.");
font = Font.FromHfont(handle);
In the compact framwork there is a already a LOGFONT class that I can
use, and with the same settings there it works.
Have you any hint what could be wrong with my approach?
Thanks in advance,
Tom