Designing a Custom Font Dialog/Selector for C# that filters out non true type fonts
See the question and my original answer on StackOverflowYou could modify the MyFontDialog like this:
public partial class MyFontDialog : Form
{
private FontListBox _fontListBox;
private ListBox _fontSizeListBox;
public MyFontDialog()
{
//InitializeComponent();
_fontListBox = new FontListBox();
_fontListBox.SelectedIndexChanged += OnfontListBoxSelectedIndexChanged;
_fontListBox.Size = new Size(200, Height);
Controls.Add(_fontListBox);
_fontSizeListBox = new ListBox();
_fontSizeListBox.Location = new Point(_fontListBox.Width, 0);
Controls.Add(_fontSizeListBox);
}
private void OnfontListBoxSelectedIndexChanged(object sender, EventArgs e)
{
_fontSizeListBox.Items.Clear();
Font font = _fontListBox.SelectedItem as Font;
if (font != null)
{
foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
{
if (font.FontFamily.IsStyleAvailable(style))
{
_fontSizeListBox.Items.Add(style);
}
}
}
}
}
It will create a list box aside the font list box with the list of available font styles. As for the size choice, you can simply add a list box with hardcoded list of size: 8,9,10,11,12, 14,16,18,20,22,24,26,28,36,48 and 72, just like the standard FontDialog, since we're dealing with true type fonts.