SetFontName() public static method

public static SetFontName ( Win32.LOGFONT &logFont, string fontName ) : void
logFont Win32.LOGFONT
fontName string
return void
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)));
        }