List installed font names in Windows 10 Universal App
Asked Answered
D

2

5

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!

Dannielledannon answered 6/11, 2015 at 21:25 Comment(2)
FYI, SharpDX 3.0.0-beta+ is compatible with Windows 10 UAPErrecart
Thank you xoofx, good to know!Dannielledannon
L
9

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));
}
Limnology answered 7/11, 2015 at 1:9 Comment(1)
Awesome! I tried SharpDX for font enumeration in windows 8.1. It's works fine but failed on certification (WACK) cause of deprecated API in dll - D2D1GetGradientMeshInteriorPointsFromCoonsPatch.Grube
O
2

I decided for the fixed list approach. It does not require Win2D.

If someone is interested, here is the list of fonts that are guaranteed to be available in all Windows 10 editions that support UWP apps:

Parsed from https://msdn.microsoft.com/en-us/library/windows/apps/hh700394.aspx

public static string[] FontNames = {
    "Arial", "Calibri", "Cambria", "Cambria Math", "Comic Sans MS", "Courier New",
    "Ebrima", "Gadugi", "Georgia",
    "Javanese Text Regular Fallback font for Javanese script", "Leelawadee UI",
    "Lucida Console", "Malgun Gothic", "Microsoft Himalaya", "Microsoft JhengHei",
    "Microsoft JhengHei UI", "Microsoft New Tai Lue", "Microsoft PhagsPa",
    "Microsoft Tai Le", "Microsoft YaHei", "Microsoft YaHei UI",
    "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text",
    "Nirmala UI", "Segoe MDL2 Assets", "Segoe Print", "Segoe UI", "Segoe UI Emoji",
    "Segoe UI Historic", "Segoe UI Symbol", "SimSun", "Times New Roman",
    "Trebuchet MS", "Verdana", "Webdings", "Wingdings", "Yu Gothic",
    "Yu Gothic UI"
};

Particularly, for my application, I removed from this list a few that do not interest me, like Javanese Text Regular Fallback font for Javanese script plus those Microsoft * asian languages and Segoe MDL2 Assets plus (Web|Wing)dings which are only for icons.

Oppress answered 12/11, 2015 at 13:26 Comment(1)
A newer version of a similar page: learn.microsoft.com/en-us/typography/fonts/windows_10_font_list.Sateia

© 2022 - 2024 — McMap. All rights reserved.