コード例 #1
0
ファイル: GDIFont.cs プロジェクト: Wiladams/NewTOAPIA
        public GDIFont(string lfFaceName, int lfHeight,
            byte lfPitchAndFamily, byte lfCharSet,
            FontQuality lfQuality, FontWeight lfWeight, bool lfItalic, bool lfStrikeOut, bool lfUnderline,
            byte lfClipPrecision, byte lfOutPrecision,
            int lfEscapement, int lfOrientation,
            int lfWidth, Guid aGuid)
            : base(true, aGuid)
        {
            fFaceName = lfFaceName;
            fHeight = lfHeight;

            fLogFont = new LOGFONT();
            //fLogFont.Init();
            fLogFont.lfCharSet = lfCharSet;
            fLogFont.lfClipPrecision = lfClipPrecision;
            fLogFont.lfEscapement = lfEscapement;
            fLogFont.lfFaceName = lfFaceName;
            fLogFont.lfHeight = lfHeight;
            fLogFont.lfItalic = (byte)(lfItalic ? 1 : 0);
            fLogFont.lfOrientation = lfOrientation;
            fLogFont.lfOutPrecision = lfOutPrecision;
            fLogFont.lfPitchAndFamily = lfPitchAndFamily;
            fLogFont.lfQuality = (byte)lfQuality;
            fLogFont.lfStrikeOut = (byte)(lfStrikeOut ? 1 : 0);
            fLogFont.lfUnderline = (byte)(lfUnderline ? 1 : 0);
            fLogFont.lfWeight = (int)lfWeight;
            fLogFont.lfWidth = lfWidth;

            //fFontHandle = GDI32.CreateFontIndirect(ref fLogFont);
            
            IntPtr fontHandle = GDI32.CreateFontW(
                lfHeight, lfWidth,
                lfEscapement, lfOrientation,
                (int)lfWeight,
                (uint)(lfItalic ? 1 : 0), 
                (uint)(lfUnderline ? 1 : 0), 
                (uint)(lfStrikeOut ? 1 : 0),
                lfCharSet, 
                lfOutPrecision, 
                lfClipPrecision,
                (uint)lfQuality, 
                lfPitchAndFamily, 
                lfFaceName);

            SetHandle(fontHandle);
        }
コード例 #2
0
ファイル: GDIGlyph.cs プロジェクト: Wiladams/NewTOAPIA
        public static uint SelectFont(GDIContext hdc, System.Drawing.Font font)
        {
            GDI32.SelectObject(hdc, font.ToHfont());

            uint size = GDI32.GetOutlineTextMetrics(hdc, 0, IntPtr.Zero);

            if (size != uint.MaxValue)
            {
                UnmanagedMemory otm = new UnmanagedMemory((int)size);
                uint err = GDI32.GetOutlineTextMetrics(hdc, size, otm.MemoryPointer);
                uint otmEMSquare = (uint)Marshal.ReadInt32(otm, 92);
                otm.Dispose();

                LOGFONT log = new LOGFONT();
                font.ToLogFont(log);
                log.lfHeight = -(int)otmEMSquare;

                font = System.Drawing.Font.FromLogFont(log);
                GDI32.SelectObject(hdc, font.ToHfont());
            }

            return size;
        }
コード例 #3
0
ファイル: GDI32_Objects.cs プロジェクト: Wiladams/NewTOAPIA
 public static int GetObject(IntPtr hObject, LOGFONT lp)
 {
     return GetObject(hObject, Marshal.SizeOf(typeof(LOGFONT)), lp);
 }
コード例 #4
0
ファイル: GDI32_Text.cs プロジェクト: Wiladams/NewTOAPIA
 public static extern IntPtr CreateFontIndirect(ref LOGFONT lplf);