Warm tip: This article is reproduced from serverfault.com, please click

How to Get lists of all installed font families in uwp

发布于 2021-01-04 13:35:10

Can anyone tell me how I can get lists of all installed fonts in c# uwp? I just want to put those fonts in combo box. So, I just need a list that has all the installed fonts of the PC.

I also tried to use Win2D but it gave me null output. My code:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    var fonts = Microsoft.Graphics.Canvas.Text.CanvasTextFormat.GetSystemFontFamilies();
    BaseExample.ItemsSource = fonts;
}
Questioner
Binamra
Viewed
0
Mark Benningfield 2021-01-04 22:18:36

You will need to install the Win2D Nuget package.

Then you can call the CanvasTextFormat.GetSystemFontFamilies method to return a list of the installed fonts.