Пример #1
0
 private WindowsFont(IntNativeMethods.LOGFONT lf, bool createHandle)
 {
     this.fontSize = -1f;
     this.logFont  = lf;
     if (this.logFont.lfFaceName == null)
     {
         this.logFont.lfFaceName = "Microsoft Sans Serif";
     }
     this.style = FontStyle.Regular;
     if (lf.lfWeight == 700)
     {
         this.style |= FontStyle.Bold;
     }
     if (lf.lfItalic == 1)
     {
         this.style |= FontStyle.Italic;
     }
     if (lf.lfUnderline == 1)
     {
         this.style |= FontStyle.Underline;
     }
     if (lf.lfStrikeOut == 1)
     {
         this.style |= FontStyle.Strikeout;
     }
     if (createHandle)
     {
         this.CreateFont();
     }
 }
Пример #2
0
 public static WindowsFont FromHfont(IntPtr hFont, bool takeOwnership)
 {
     IntNativeMethods.LOGFONT lp = new IntNativeMethods.LOGFONT();
     IntUnsafeNativeMethods.GetObject(new HandleRef(null, hFont), lp);
     return(new WindowsFont(lp, false)
     {
         hFont = hFont, ownHandle = takeOwnership
     });
 }
Пример #3
0
 public LOGFONT(IntNativeMethods.LOGFONT lf)
 {
     this.lfHeight         = lf.lfHeight;
     this.lfWidth          = lf.lfWidth;
     this.lfEscapement     = lf.lfEscapement;
     this.lfOrientation    = lf.lfOrientation;
     this.lfWeight         = lf.lfWeight;
     this.lfItalic         = lf.lfItalic;
     this.lfUnderline      = lf.lfUnderline;
     this.lfStrikeOut      = lf.lfStrikeOut;
     this.lfCharSet        = lf.lfCharSet;
     this.lfOutPrecision   = lf.lfOutPrecision;
     this.lfClipPrecision  = lf.lfClipPrecision;
     this.lfQuality        = lf.lfQuality;
     this.lfPitchAndFamily = lf.lfPitchAndFamily;
     this.lfFaceName       = lf.lfFaceName;
 }
Пример #4
0
        public WindowsFont(string faceName, float size, FontStyle style, byte charSet, WindowsFontQuality fontQuality)
        {
            this.fontSize = -1f;
            this.logFont  = new IntNativeMethods.LOGFONT();
            int num = (int)Math.Ceiling((double)((WindowsGraphicsCacheManager.MeasurementGraphics.DeviceContext.DpiY * size) / 72f));

            this.logFont.lfHeight       = -num;
            this.logFont.lfFaceName     = (faceName != null) ? faceName : "Microsoft Sans Serif";
            this.logFont.lfCharSet      = charSet;
            this.logFont.lfOutPrecision = 4;
            this.logFont.lfQuality      = (byte)fontQuality;
            this.logFont.lfWeight       = ((style & FontStyle.Bold) == FontStyle.Bold) ? 700 : 400;
            this.logFont.lfItalic       = ((style & FontStyle.Italic) == FontStyle.Italic) ? ((byte)1) : ((byte)0);
            this.logFont.lfUnderline    = ((style & FontStyle.Underline) == FontStyle.Underline) ? ((byte)1) : ((byte)0);
            this.logFont.lfStrikeOut    = ((style & FontStyle.Strikeout) == FontStyle.Strikeout) ? ((byte)1) : ((byte)0);
            this.style = style;
            this.CreateFont();
        }
Пример #5
0
 public static extern int IntGetObject(HandleRef hFont, int nSize, [In, Out] IntNativeMethods.LOGFONT lf);
Пример #6
0
 public static int GetObject(HandleRef hFont, IntNativeMethods.LOGFONT lp)
 {
     return(IntGetObject(hFont, Marshal.SizeOf(typeof(IntNativeMethods.LOGFONT)), lp));
 }