Exemple #1
0
        private void CreateFonts()
        {
            _font = new FontHandle(RuntimeUtil.CreateFont(_fontName, _fontSize), _useClearType);
            FontStyle fs = _font.Font.Style;

            _boldfont          = new FontHandle(new Font(_font.Font, fs | FontStyle.Bold), _useClearType);
            _underlinefont     = new FontHandle(new Font(_font.Font, fs | FontStyle.Underline), _useClearType);
            _boldunderlinefont = new FontHandle(new Font(_font.Font, fs | FontStyle.Underline | FontStyle.Bold), _useClearType);

            _cjkFont              = new FontHandle(new Font(_cjkFontName, _fontSize), _useClearType);
            fs                    = _cjkFont.Font.Style;
            _cjkBoldfont          = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Bold), _useClearType);
            _cjkUnderlinefont     = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Underline), _useClearType);
            _cjkBoldUnderlinefont = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Underline | FontStyle.Bold), _useClearType);

            _usingIdenticalFont = (_font.Font.Name == _cjkFont.Font.Name);

            //通常版
            Graphics g   = Graphics.FromHwnd(Win32.GetDesktopWindow());
            IntPtr   hdc = g.GetHdc();

            Win32.SelectObject(hdc, _font.HFONT);
            Win32.SIZE charsize1, charsize2;
            Win32.GetTextExtentPoint32(hdc, "A", 1, out charsize1);
            Win32.GetTextExtentPoint32(hdc, "AAA", 3, out charsize2);

            _pitch   = new SizeF((charsize2.width - charsize1.width) / 2, charsize1.height);
            _chargap = (charsize1.width - _pitch.Width) / 2;
            g.ReleaseHdc(hdc);
            g.Dispose();
        }
 private void InitUI()
 {
     AdjustFontDescription(_profile.FontName, _profile.CJKFontName, _profile.FontSize);
     _fontSample.Font      = RuntimeUtil.CreateFont(_profile.FontName, _profile.FontSize);
     _fontSample.BackColor = _profile.BackColor;
     _fontSample.ForeColor = _profile.ForeColor;
     _fontSample.ClearType = _profile.UseClearType;
     _fontSample.Invalidate(true);
     _backgroundImageBox.Text    = _profile.BackgroundImageFileName;
     _bgColorBox.SelectedColor   = _profile.BackColor;
     _textColorBox.SelectedColor = _profile.ForeColor;
     _imageStyleBox.SelectedItem = _profile.ImageStyle;  // select EnumListItem<T> by T
 }
Exemple #3
0
        private void OnASCIIFontChange(object sender, EventArgs args)
        {
            if (_ignoreEvent || _asciiFontList.SelectedIndex == -1)
            {
                return;
            }
            string fontname = (string)_asciiFontList.Items[_asciiFontList.SelectedIndex];

            _asciiFont = RuntimeUtil.CreateFont(fontname, GetFontSize());
            if (_checkForceBoldStyle.Checked)
            {
                _asciiFont = new Font(_asciiFont, _asciiFont.Style | FontStyle.Bold);
            }
            _lASCIISample.Font = _asciiFont;
        }
        private void OnFontSelect(object sender, EventArgs args)
        {
            GFontDialog gd = new GFontDialog();
            Font        nf = RuntimeUtil.CreateFont(_profile.FontName, _profile.FontSize);
            Font        jf = RuntimeUtil.CreateFont(_profile.CJKFontName, _profile.FontSize);

            gd.SetFont(_profile.UseClearType, _profile.EnableBoldStyle, _profile.ForceBoldStyle, nf, jf);
            if (gd.ShowDialog(this) == DialogResult.OK)
            {
                Font f = gd.ASCIIFont;
                _profile.FontName        = f.Name;
                _profile.CJKFontName     = gd.CJKFont.Name;
                _profile.FontSize        = f.Size;
                _profile.UseClearType    = gd.UseClearType;
                _profile.EnableBoldStyle = gd.EnableBoldStyle;
                _fontSample.Font         = f;
                AdjustFontDescription(f.Name, gd.CJKFont.Name, f.Size);
            }
        }
        private void CreateFonts()
        {
            _font = new FontHandle(RuntimeUtil.CreateFont(_fontName, _fontSize));
            FontStyle fs = _font.Font.Style;

            _boldfont          = new FontHandle(new Font(_font.Font, fs | FontStyle.Bold));
            _underlinefont     = new FontHandle(new Font(_font.Font, fs | FontStyle.Underline));
            _boldunderlinefont = new FontHandle(new Font(_font.Font, fs | FontStyle.Underline | FontStyle.Bold));

            _cjkFont              = new FontHandle(new Font(_cjkFontName, _fontSize));
            fs                    = _cjkFont.Font.Style;
            _cjkBoldfont          = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Bold));
            _cjkUnderlinefont     = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Underline));
            _cjkBoldUnderlinefont = new FontHandle(new Font(_cjkFont.Font, fs | FontStyle.Underline | FontStyle.Bold));

            _usingIdenticalFont = (_font.Font.Name == _cjkFont.Font.Name);

            //通常版
            Graphics g   = Graphics.FromHwnd(Win32.GetDesktopWindow());
            IntPtr   hdc = g.GetHdc();

            Win32.SelectObject(hdc, _font.HFONT);
            Win32.SIZE charsize1, charsize2;
            Win32.GetTextExtentPoint32(hdc, "A", 1, out charsize1);
            Win32.GetTextExtentPoint32(hdc, "AAA", 3, out charsize2);

            _pitch = new SizeF((charsize2.width - charsize1.width) / 2, charsize1.height);
#if KM20121125_UseExtTextOut_impl3
            {
                float pw = _pitch.Width;
                float fx = 0f;
                for (int i = 0; i < PITCH_DX_LEN; i++, fx += pw)
                {
                    pitch_deltaXArray[i] = (int)(fx + pw) - (int)fx;
                }
            }
#endif

            _chargap = (charsize1.width - _pitch.Width) / 2;
            g.ReleaseHdc(hdc);
            g.Dispose();
        }