列出Windows 10 Universal App中已安装的字体名称 [英] List installed font names in Windows 10 Universal App

查看:83
本文介绍了列出Windows 10 Universal App中已安装的字体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#构建Windows 10通用应用程序,该应用程序必须列出系统上已安装字体的名称.该应用程序是Metro/Modern ui/windows 8.1应用程序,我使用了以获取名称.

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在Windows 10 UAP上不可用(尚未?),因此不再起作用.

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.

提前谢谢!

推荐答案

相同的基本思想:您仍将使用DirectWrite来获取字体名称.

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

您可以在Windows 8.1和通用Windows平台应用程序中使用 Win2D 从C#转到DirectWrite..CanvasTextFormat. GetSystemFontFamilies 将返回字体系列:

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));
}

这篇关于列出Windows 10 Universal App中已安装的字体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆