예제 #1
0
        public void SetFont(Font font)
        {
            var lf = new LogFont();
            font.ToLogFont(lf);
            lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;

            NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf);
        }
예제 #2
0
        public ICollection EnumFonts()
        {
            var bmp = new Bitmap(10, 10);
            Graphics g = Graphics.FromImage(bmp);

            IntPtr hDC = g.GetHdc();
            Fonts = new Hashtable();
            var lf = new LogFont {lfCharSet = 1};
            FONTENUMPROC callback = CallbackFunc;
            NativeMethods.EnumFontFamiliesEx(hDC, lf, callback, 0, 0);

            g.ReleaseHdc(hDC);
            g.Dispose();
            bmp.Dispose();
            return Fonts.Keys;
        }
예제 #3
0
        protected void Init(string fontname, float size, bool bold, bool italic, bool underline, bool strikethrough)
        {
            FontName = fontname;
            Size = size;
            Bold = bold;
            Italic = italic;
            Underline = underline;
            Strikethrough = strikethrough;

            LogFont tFont = new LogFont();
            tFont.lfItalic = (byte) (this.Italic ? 1 : 0);
            tFont.lfStrikeOut = (byte) (this.Strikethrough ? 1 : 0);
            tFont.lfUnderline = (byte) (this.Underline ? 1 : 0);
            tFont.lfWeight = this.Bold ? 700 : 400;
            tFont.lfWidth = 0;
            tFont.lfHeight = (int) (-this.Size*1.3333333333333);
            tFont.lfCharSet = 1;

            tFont.lfFaceName = this.FontName;

            hFont = NativeMethods.CreateFontIndirect(tFont);
        }
예제 #4
0
        protected void Init(string fontname, float size, bool bold, bool italic, bool underline, bool strikethrough)
        {
            FontName = fontname;
            Size = size;
            Bold = bold;
            Italic = italic;
            Underline = underline;
            Strikethrough = strikethrough;

            var tFont = new LogFont
                        {
                            lfItalic = ((byte) (Italic ? 1 : 0)),
                            lfStrikeOut = ((byte) (Strikethrough ? 1 : 0)),
                            lfUnderline = ((byte) (Underline ? 1 : 0)),
                            lfWeight = (Bold ? 700 : 400),
                            lfWidth = 0,
                            lfHeight = ((int) (-Size*1.3333333333333)),
                            lfCharSet = 1,
                            lfFaceName = FontName
                        };

            hFont = NativeMethods.CreateFontIndirect(tFont);
        }
예제 #5
0
 public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, LogFont lParam);
예제 #6
0
        public void SetFont(string fontname, float fontsize)
        {
            LogFont tFont = new LogFont();
            tFont.lfItalic = (byte) 0;
            tFont.lfStrikeOut = (byte) 0;
            tFont.lfUnderline = (byte) 0;
            tFont.lfWeight = 400;
            tFont.lfWidth = 0;
            tFont.lfHeight = (int) (-fontsize*1.3333333333333);
            tFont.lfCharSet = 1;
            tFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
            tFont.lfFaceName = fontname;

            LogFont lf = tFont;

            NativeMethods.SendMessage(
                hIMEWnd, (int) WindowMessage.WM_IME_CONTROL,
                IMC_SETCOMPOSITIONFONT,
                lf
                );
        }