Effect picture:
To get the font library, first add the SharpDx.Direct2D1 api to NuGet:
/// <summary> /// Get the system font library list /// </summary> public void GetFontLibrary() { SharpDX.DirectWrite.Factory factory = new SharpDX.DirectWrite.Factory(); var fontCollection = factory.GetSystemFontCollection(false); var familCount = fontCollection.FontFamilyCount; for (int i = 0; i < familCount; i++) { var fontFamily = fontCollection.GetFontFamily(i); var familyNames = fontFamily.FamilyNames; int index; if (!familyNames.FindLocaleName(CultureInfo.CurrentCulture.Name, out index)) { if (!familyNames.FindLocaleName("en-us", out index)) { index = 0; } } string name = familyNames.GetString(index); FontList.Add(name); } }
Because setting the FontFamily property requires a string type, we just need to get the font name and add it to a string collection.
Original address: http://edi.wang/post/2017/1/22/windows-10-uwp-get-fonts