Exemplo n.º 1
0
        static IntPtr InitFont(string fontName, float emHeight, FontStyle style)
        {
            //see: MSDN, LOGFONT structure
            //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
            MyWin32.LOGFONT logFont = new MyWin32.LOGFONT();
            MyWin32.SetFontName(ref logFont, fontName);
            logFont.lfHeight  = -(int)ConvEmSizeInPointsToPixels(emHeight); //minus **
            logFont.lfCharSet = 1;                                          //default
            logFont.lfQuality = 0;                                          //default

            MyWin32.LOGFONT_FontWeight weight =
                ((style & FontStyle.Bold) == FontStyle.Bold) ?
                MyWin32.LOGFONT_FontWeight.FW_BOLD :
                MyWin32.LOGFONT_FontWeight.FW_REGULAR;
            logFont.lfWeight = (int)weight;
            //
            logFont.lfItalic = (byte)(((style & FontStyle.Italic) == FontStyle.Italic) ? 1 : 0);
            return(MyWin32.CreateFontIndirect(ref logFont));
        }
Exemplo n.º 2
0
        public static Win32Font CreateWin32Font(string fontName, float emHeight, bool bold, bool italic, float pixels_per_inch = 96)
        {
            //see: MSDN, LOGFONT structure
            //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
            MyWin32.LOGFONT logFont = new MyWin32.LOGFONT();
            MyWin32.SetFontName(ref logFont, fontName);
            logFont.lfHeight  = -(int)MyWin32.ConvEmSizeInPointsToPixels(emHeight, pixels_per_inch); //minus **
            logFont.lfCharSet = 1;                                                                   //default
            logFont.lfQuality = 0;                                                                   //default

            //
            MyWin32.LOGFONT_FontWeight weight =
                bold ?
                MyWin32.LOGFONT_FontWeight.FW_BOLD :
                MyWin32.LOGFONT_FontWeight.FW_REGULAR;
            logFont.lfWeight = (int)weight;
            //
            logFont.lfItalic = (byte)(italic ? 1 : 0);
            return(new Win32Font(MyWin32.CreateFontIndirect(ref logFont)));
        }
Exemplo n.º 3
0
 public static IntPtr CreateFontHelper(string fontName, float emHeight, bool bold, bool italic, float pixels_per_inch = 96)
 {
     //see: MSDN, LOGFONT structure
     //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
     MyWin32.LOGFONT logFont = new MyWin32.LOGFONT();
     MyWin32.SetFontName(ref logFont, fontName);
     logFont.lfHeight = -(int)ConvEmSizeInPointsToPixels(emHeight, pixels_per_inch);//minus **
     logFont.lfCharSet = 1;//default
     logFont.lfQuality = 0;//default
     
     //
     MyWin32.LOGFONT_FontWeight weight =
         bold ?
         MyWin32.LOGFONT_FontWeight.FW_BOLD :
         MyWin32.LOGFONT_FontWeight.FW_REGULAR;
     logFont.lfWeight = (int)weight;
     //
     logFont.lfItalic = (byte)(italic ? 1 : 0);
     return MyWin32.CreateFontIndirect(ref logFont);
 }
Exemplo n.º 4
0
 static IntPtr InitFont(string fontName, float emHeight, FontStyle style)
 {
     //see: MSDN, LOGFONT structure
     //https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
     MyWin32.LOGFONT logFont = new MyWin32.LOGFONT();
     MyWin32.SetFontName(ref logFont, fontName);
     logFont.lfHeight = -(int)PixelFarm.Drawing.RequestFont.ConvEmSizeInPointsToPixels(emHeight);//minus **
     logFont.lfCharSet = 1;//default
     logFont.lfQuality = 0;//default
     
     MyWin32.LOGFONT_FontWeight weight =
         ((style & FontStyle.Bold) == FontStyle.Bold) ?
         MyWin32.LOGFONT_FontWeight.FW_BOLD :
         MyWin32.LOGFONT_FontWeight.FW_REGULAR;
     logFont.lfWeight = (int)weight;
     //
     logFont.lfItalic = (byte)(((style & FontStyle.Italic) == FontStyle.Italic) ? 1 : 0);
     return MyWin32.CreateFontIndirect(ref logFont);
 }