从 WPF 中的 FontFamily 获取字体名称
我目前正在为自己开发一个小型字体组织/预览应用程序,但是,我很难获得我需要的确切信息。
我发现只需创建一个新的 FontFamily 对象并将字体的文件位置作为其源即可加载外部字体。但是,我找不到一种方法来获取字体的特定字体名称。我知道我可以使用 FontFamily.FamilyNames 来获取字体的 family 名称,但是当我有多个显示相同系列的字体时,这对我来说毫无用处。我想实际显示特定字体的特定名称。
有什么办法可以做到这一点吗?我目前显示的是文件名,但它非常草率,因为我必须迭代目录中的每个文件并对每个文件调用 Fonts.GetFontFamilies() ,这样我才能获取实际的文件名(FontFamily 的 Source 属性仅提供 WPF 的临时系列- 命名源而不是有用的东西)。
I'm currently working on a little font organization/preview application for myself, however, I'm having a hard time getting the exact information I need.
I've found that I can load an external font by just creating a new FontFamily object with the font's file location as its source. However, I can't find a way to get a font's specific font name back. I know I can use FontFamily.FamilyNames to get the font's family name back, but that's useless to me when I have multiple fonts with the same family being displayed. I'd like to actually display the specific name for the specific font.
Is there any way to do this? I currently display the file name instead, but it's incredibly sloppy because I have to iterate through every file in a directory and call Fonts.GetFontFamilies() on each just so I can get the actual file name(FontFamily's Source property only gives WPF's makeshift family-name source instead of something useful).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我正在做的:
This is what I am doing: