예제 #1
0
파일: Font.cs 프로젝트: OpenPSS/PssIL
        public Font(FontAlias alias, int size, FontStyle style)
        {
            int errorCode = Font.NewFromAliasSizeStyle(alias, size, style, out this.handle);

            if (errorCode < 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
예제 #2
0
        public Font(FontAlias alias, int size, FontStyle style)
        {
            this.__alias = alias;
            this.__size  = size;
            this.__style = style;
            System.Drawing.FontStyle _style = System.Drawing.FontStyle.Regular;
            switch (style)
            {
            case FontStyle.Regular:
                _style = System.Drawing.FontStyle.Regular;
                break;

            case FontStyle.Bold:
                _style = System.Drawing.FontStyle.Bold;
                break;

            case FontStyle.Italic:
                _style = System.Drawing.FontStyle.Italic;
                break;
            }
            //Arial
            //Comic Sans MS
            //MS Gothic
            this.__font = new System.Drawing.Font("MS Gothic", (int)(__size * 0.75f), _style);             //FIXME:???0.8
            //this.__font = new System.Drawing.Font("Arial", __size, _style); //FIXME:???0.8
            //this.__font = new System.Drawing.Font(/*"宋体"*/FontFamily.GenericSansSerif, __size, _style);

            this.__metrics = new FontMetrics();


            IntPtr hdc    = GetDC(IntPtr.Zero);
            IntPtr handle = __font.ToHfont();

            try
            {
                IntPtr     handle2    = SelectObject(hdc, handle);
                TEXTMETRIC tEXTMETRIC = new TEXTMETRIC();
                GetTextMetrics(hdc, ref tEXTMETRIC);
                __metrics.Ascent  = tEXTMETRIC.tmAscent;
                __metrics.Descent = tEXTMETRIC.tmDescent;
                __metrics.Leading = tEXTMETRIC.tmHeight - tEXTMETRIC.tmAscent - tEXTMETRIC.tmDescent;
                SelectObject(hdc, handle2);
            }
            finally
            {
                DeleteObject(handle);
                ReleaseDC(IntPtr.Zero, hdc);
            }
        }
예제 #3
0
파일: Font.cs 프로젝트: OpenPSS/PssIL
 private static extern int NewFromAliasSizeStyle(FontAlias alias, int size, FontStyle style, out int handle);