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

            NativeUser32Api.SendMessage(
                hIMEWnd, (int)WindowMessage.WM_IME_CONTROL,
                IMC_SETCOMPOSITIONFONT,
                lf
                );
        }
Example #2
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;

            NativeUser32Api.SendMessage(
                hIMEWnd, (int)WindowMessage.WM_IME_CONTROL,
                IMC_SETCOMPOSITIONFONT,
                lf
                );
        }
Example #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 = NativeGdi32Api.CreateFontIndirect(tFont);
		}
Example #4
0
        public ICollection EnumFonts()
        {
            Bitmap bmp = new Bitmap(10, 10);
            Graphics g = Graphics.FromImage(bmp);

            IntPtr hDC = g.GetHdc();
            Fonts = new Hashtable();
            LogFont lf = new LogFont();
            lf.lfCharSet = 1;
            FONTENUMPROC callback = new FONTENUMPROC(this.CallbackFunc);
            NativeGdi32Api.EnumFontFamiliesEx(hDC, lf, callback, 0, 0);

            g.ReleaseHdc(hDC);
            g.Dispose();
            bmp.Dispose();
            return Fonts.Keys;
        }
Example #5
0
 public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, LogFont lParam);