コード例 #1
0
ファイル: Fonts.cs プロジェクト: onelifeonelover/cstd
        private static IntPtr CreateFontObject(Font font, bool antiAliasing)
        {
            NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
            font.ToLogFont(logFont);

            int  nHeight            = logFont.lfHeight;
            int  nWidth             = logFont.lfWidth;
            int  nEscapement        = logFont.lfEscapement;
            int  nOrientation       = logFont.lfOrientation;
            int  fnWeight           = logFont.lfWeight;
            uint fdwItalic          = logFont.lfItalic;
            uint fdwUnderline       = logFont.lfUnderline;
            uint fdwStrikeOut       = logFont.lfStrikeOut;
            uint fdwCharSet         = logFont.lfCharSet;
            uint fdwOutputPrecision = logFont.lfOutPrecision;
            uint fdwClipPrecision   = logFont.lfClipPrecision;
            uint fdwQuality;

            if (antiAliasing)
            {
                fdwQuality = NativeConstants.ANTIALIASED_QUALITY;
            }
            else
            {
                fdwQuality = NativeConstants.NONANTIALIASED_QUALITY;
            }

            uint   fdwPitchAndFamily = logFont.lfPitchAndFamily;
            string lpszFace          = logFont.lfFaceName;

            IntPtr hFont = SafeNativeMethods.CreateFontW(
                nHeight,
                nWidth,
                nEscapement,
                nOrientation,
                fnWeight,
                fdwItalic,
                fdwUnderline,
                fdwStrikeOut,
                fdwCharSet,
                fdwOutputPrecision,
                fdwClipPrecision,
                fdwQuality,
                fdwPitchAndFamily,
                lpszFace);

            if (hFont == IntPtr.Zero)
            {
                NativeMethods.ThrowOnWin32Error("CreateFontW returned NULL");
            }

            return(hFont);
        }
コード例 #2
0
ファイル: Fonts.cs プロジェクト: metadeta96/openpdn
        private static IntPtr CreateFontObject(Font font, bool antiAliasing)
        {
            NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
            font.ToLogFont(logFont);

            int nHeight = logFont.lfHeight;
            int nWidth = logFont.lfWidth;
            int nEscapement = logFont.lfEscapement;
            int nOrientation = logFont.lfOrientation;
            int fnWeight = logFont.lfWeight;
            uint fdwItalic = logFont.lfItalic;
            uint fdwUnderline = logFont.lfUnderline;
            uint fdwStrikeOut = logFont.lfStrikeOut;
            uint fdwCharSet = logFont.lfCharSet;
            uint fdwOutputPrecision = logFont.lfOutPrecision;
            uint fdwClipPrecision = logFont.lfClipPrecision;
            uint fdwQuality;
            
            if (antiAliasing)
            {
                fdwQuality = NativeConstants.ANTIALIASED_QUALITY;
            }
            else
            {
                fdwQuality = NativeConstants.NONANTIALIASED_QUALITY;
            }

            uint fdwPitchAndFamily = logFont.lfPitchAndFamily;
            string lpszFace = logFont.lfFaceName;

            IntPtr hFont = SafeNativeMethods.CreateFontW(
                nHeight,
                nWidth,
                nEscapement,
                nOrientation,
                fnWeight,
                fdwItalic,
                fdwUnderline,
                fdwStrikeOut,
                fdwCharSet,
                fdwOutputPrecision,
                fdwClipPrecision,
                fdwQuality,
                fdwPitchAndFamily,
                lpszFace);

            if (hFont == IntPtr.Zero)
            {
                NativeMethods.ThrowOnWin32Error("CreateFontW returned NULL");
            }

            return hFont;
        }
コード例 #3
0
ファイル: Fonts.cs プロジェクト: onelifeonelover/cstd
 /// <summary>
 /// Determines whether a font uses the 'symbol' character set.
 /// </summary>
 /// <remarks>
 /// Symbol fonts do not typically contain glyphs that represent letters of the alphabet.
 /// Instead they might contain pictures and symbols. As such, they are not useful for
 /// drawing text. Which means you can't use a symbol font to write out its own name for
 /// illustrative purposes (like for the font drop-down chooser).
 /// </remarks>
 public static bool IsSymbolFont(Font font)
 {
     NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
     font.ToLogFont(logFont);
     return(logFont.lfCharSet == NativeConstants.SYMBOL_CHARSET);
 }
コード例 #4
0
ファイル: Fonts.cs プロジェクト: leejungho2/xynotecgui
 /// <summary>
 /// Determines whether a font uses the 'symbol' character set.
 /// </summary>
 /// <remarks>
 /// Symbol fonts do not typically contain glyphs that represent letters of the alphabet.
 /// Instead they might contain pictures and symbols. As such, they are not useful for
 /// drawing text. Which means you can't use a symbol font to write out its own name for
 /// illustrative purposes (like for the font drop-down chooser).
 /// </remarks>
 public static bool IsSymbolFont(Font font)
 {
     NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
     font.ToLogFont(logFont);
     return logFont.lfCharSet == NativeConstants.SYMBOL_CHARSET;
 }