There's an example of doing this in an HTML/JS app using a C++ interop here:
http://code.msdn.microsoft.com/windowsapps/DirectWrite-font-60e53e0b
I can't really beleive we need to go to such lengths to do something so simple, but luckily SharpDX comes to the rescue (again). It's still a bit convoluted having to interrogate the DirectWrite font family collections, but loads easier than writing a C++ interop!
Here's a helper class I wrote to get font names:
using SharpDX.DirectWrite;
using System.Collections.Generic;
using System.Linq;
namespace WebberCross.Helpers
{
public class FontHelper
{
public static IEnumerable<string>
GetFontNames()
{
var fonts = new List<string>();
// DirectWrite factory
var factory = new
Factory();
// Get font collections
var fc = factory.GetSystemFontCollection(false);
for (int i = 0; i
< fc.FontFamilyCount; i++)
{
// Get
font family and add first name
var ff = fc.GetFontFamily(i);
var name = ff.FamilyNames.GetString(0);
fonts.Add(name);
}
// Always dispose DirectX objects
factory.Dispose();
return fonts.OrderBy(f => f);
}
}
}