public static unsafe void SetFontName(ref LOGFONT logFont, string fontName) { //font name not longer than 32 chars char[] fontNameChars = fontName.ToCharArray(); int j = Math.Min(fontNameChars.Length, 31); fixed(char *c = logFont.lfFaceName) { char *c1 = c; for (int i = 0; i < j; ++i) { *c1 = fontNameChars[i]; c1++; } } }
public static unsafe void SetFontName(ref LOGFONT logFont, string fontName) { //font name not longer than 32 chars char[] fontNameChars = fontName.ToCharArray(); int j = Math.Min(fontNameChars.Length, 31); fixed (char* c = logFont.lfFaceName) { char* c1 = c; for (int i = 0; i < j; ++i) { *c1 = fontNameChars[i]; c1++; } } }
[DllImport("gdi32.dll", CharSet = CharSet.Unicode)] //need -> unicode public extern static IntPtr CreateFontIndirect(ref LOGFONT logFont);
public static extern int EnumFontFamiliesEx(HDC hdc, ref LOGFONT lpLogFont, ref int lpEnumFontProc, int lParam, int dw);
public static extern int CreateFontIndirect(LOGFONT lpLogFont);