I'm trying to develop a font application. In a ListView, I have listed all installed fonts. Now I want to show the fonts name written in that font.
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
fontFamilies = installedFontCollection.Families;
int fontCount = fontFamilies.Length;
familyList = new ListViewItem[fontCount];
for (int i = 0; i < fontCount; i++)
{
familyList[i] = new ListViewItem(fontFamilies[i].Name);
}
listView1.Items.AddRange(familyList);
In the for-loop, I try setting the fonts with
familyList[i].Font = new Font(fontFamilies[i], 12);
However, all text goes blank.
If I hardcode the values, it works fine. Even when I hardcode different fonts based on random conditions, say
if (i % 2 == 0)
familyList[i].Font = new Font(fontFamilies[53], 12);
else
familyList[i].Font = new Font(fontFamilies[12], 12);
the list alternates the font as expected.
What could be the problem here? Are some fonts maybe undefined or otherwise unusable, making the entire list fail? No error is thrown.
Thanks.