Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List installed font names in Windows 10 Universal App

I am building a Windows 10 universal app in C# that has to list the names of the installed fonts on the system. The app was a metro/modern ui/windows 8.1 app and I used the SharpDX 'trick' there to get the names.

SharpDX is not available (yet?) for Windows 10 UAP, so that does not work anymore.

Any other ways to achieve my goal? Should I consider a fixed list of font names as described here under recommended fonts? This seems rather limiting when on a desktop for instance.

Thanks in advance!

like image 584
Raf Avatar asked Nov 06 '15 21:11

Raf


1 Answers

Same basic idea: you'll still use DirectWrite to get the font names.

You can use Win2D to get to DirectWrite from C# in both Windows 8.1 and Universal Windows Platform apps. CanvasTextFormat.GetSystemFontFamilies will return the font families:

string[] fonts = Microsoft.Graphics.Canvas.Text.CanvasTextFormat.GetSystemFontFamilies();
foreach (string font in fonts)
{
    Debug.WriteLine(string.Format("Font: {0}", font));
}
like image 197
Rob Caplan - MSFT Avatar answered Sep 20 '22 04:09

Rob Caplan - MSFT