我在这里使用代码: 从我在StackOverflow上搜索:
List<string> fonts = new List<string>();
foreach (FontFamily font in System.Drawing.FontFamily.Families)
{
fonts.Add(font.Name);
}
更新: 我解决了我的问题。我认为这不是最佳解决方案,但它对我有用。 这里:
private void cbxFontSize_SelectedIndexChanged(object sender, EventArgs e)
{
lblFontSample.Font = new Font(lblFontSample.Font.FontFamily, Convert.ToInt32(cbxFontSize.SelectedItem), lblFontSample.Font.Style);
}
private void cbxFont_TextChanged(object sender, EventArgs e)
{
try
{
lblFontSample.Font = new Font(cbxFont.Text, lblFontSample.Font.Size);
}
catch { }
}
private void frmConvertImage_Load(object sender, EventArgs e)
{
foreach (FontFamily fonts in FontFamily.Families)
{
cbxFont.Items.Add(fonts.Name.ToString());
}
}