예제 #1
0
파일: FontDlg.cs 프로젝트: kghost/WTerm
        private void AddFont_Click(object sender, EventArgs e)
        {
            if (FontDialog.ShowDialog() != DialogResult.Cancel)
            {
                FontItem f = new FontItem();
                f.font = FontDialog.Font;
                f.charset = FontItem.Charset.Latin;
                FontList.Items.Add(f.ToItem());
                ListMap[f.index] = f;

                using (Graphics g = Graphics.FromHwnd(Handle))
                {
                    SizeF chars_size = g.MeasureString("◆", f.font, -1, StringFormat.GenericTypographic);
                    if (chars_size.Height == 0)
                    {
                        chars_size = g.MeasureString("N", f.font, -1, StringFormat.GenericTypographic);
                    }

                    if (chars_size.Height != 0 && (double)chars_size.Width / chars_size.Height > 0.8F)
                    {
                        chars_size.Width /= 2;
                    }

                    SizeX.Value = (int)Math.Max(SizeX.Value, chars_size.Width * 100);
                    SizeY.Value = (int)Math.Max(SizeY.Value, chars_size.Height * 100);
                }

                UpdateFontGroup();
            }
        }
예제 #2
0
파일: FontDlg.cs 프로젝트: kghost/WTerm
        private void FontDlg_Load(object sender, EventArgs e)
        {
            foreach (TerminalEmulator.Font ft in _fontgroup.Fonts)
            {
                FontItem f = new FontItem();
                f.font = ft.GetFont;
                f.offset = ft.Offset;
                if (ft is TerminalEmulator.UnicodeFont)
                    f.charset = FontItem.Charset.Unicode;
                else if (ft is TerminalEmulator.LatinFont)
                    f.charset = FontItem.Charset.Latin;
                FontList.Items.Add(f.ToItem());
                ListMap[f.index] = f;
            }
            SizeX.Value = (int)_fontgroup.Size.Width * 100;
            SizeY.Value = (int)_fontgroup.Size.Height * 100;

            UpdateFontGroup();
            PreviewUpdate();
        }