public static Font FromLogFont(object lf, IntPtr hdc)
        {
            IntPtr  newObject;
            LOGFONT o      = (LOGFONT)lf;
            Status  status = GDIPlus.GdipCreateFontFromLogfont(hdc, ref o, out newObject);

            GDIPlus.CheckStatus(status);
            return(new Font(newObject, "Microsoft Sans Serif", FontStyle.Regular, 10));
        }
Esempio n. 2
0
        public static Font FromLogFont(object lf, IntPtr hdc)
        {
            IntPtr unmanaged_lf;
            IntPtr newObject;

            if (Marshal.SizeOf(lf) != Marshal.SizeOf <LOGFONT>())
            {
                throw new ArgumentException("LOGFONT structure has wrong size");
            }
            unmanaged_lf = Marshal.AllocCoTaskMem(Marshal.SizeOf(lf));
            try
            {
                Marshal.StructureToPtr(lf, unmanaged_lf, false);
                Status status = GDIPlus.GdipCreateFontFromLogfont(hdc, unmanaged_lf, out newObject);
                GDIPlus.CheckStatus(status);
            }
            finally
            {
                Marshal.FreeCoTaskMem(unmanaged_lf);
            }
            return(new Font(newObject, "Microsoft Sans Serif", FontStyle.Regular, 10));
        }