标签:字符串类型 ima oid void https rpd fan add sharp
原文:uwp 获取系统字体库效果图:
要获取到字体库首先要在 NuGet 添加 SharpDx.Direct2D1 api:
/// <summary> /// 获取系统字体库列表 /// </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); } }
因为 设置FontFamily 属性需要的时一个字符串类型,我们只要获取到字体的名字添加到一个字符串集合上就可以了。
原文地址:http://edi.wang/post/2017/1/22/windows-10-uwp-get-fonts
标签:字符串类型 ima oid void https rpd fan add sharp
原文地址:https://www.cnblogs.com/lonelyxmas/p/8970172.html