C# - 读取和放大器;预览字体 [英] C# - Read & Preview Font

查看:485
本文介绍了C# - 读取和放大器;预览字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以读取和C#预览字体(TTF为主和OTF)? ?可以/我应该用什么样的语言

Can I read and preview fonts (mainly ttf and otf) in C#? What other languages can/should I use?

阅读:


  • 信息像字体,字体名

预览:


  • 使用字体来显示一些文本

  • 任何方式显示所有支持的字体字符?

推荐答案

注意:不使用System.Drawing中/ System.Windows.Forms的,如果你想预览OTF字体。除非他们是TTF的变相,你不会让他们展示。 System.Drawing中,基于GDI +,只支持TTF字体!

Caution: don't use System.Drawing / System.Windows.Forms if you want to preview OTF fonts. Unless they're TTF's in disguise, you won't get them to show. System.Drawing, based on GDI+, only supports TTF fonts!

不过,如果你可以使用.NET 3.0中,你可以使用

However, if you can use .NET 3.0, you could use

Fonts.GetFontFamilies(location)

System.Windows.Media 命名空间(只是参考PresentationCore.dll中)。

from System.Windows.Media namespace (just reference PresentationCore.dll).

的FontFamily ,可以获得个人的字样 S(.ttc文件包含多个'字型',但的FontFamily 也结合了各种重量和变型)。而从字样,您可以致电 TryGetGlyphTypeface 以获得 GlyphTypeface ,它有一个 CharacterToGlyphMap 属性,它应该告诉你哪些Unicode代码物理支持。

From a FontFamily, you can get the individual Typefaces (.ttc files contain more than one 'font', but a FontFamily also combines the various weights and variants). And from a Typeface, you can call TryGetGlyphTypeface to get the GlyphTypeface, which has a CharacterToGlyphMap property, which should tell you which unicode codepoints are physically supported.

这似乎也可以使用 GlyphTypeface 直接,但我看不出有什么办法,你可以处理.ttc文件。但是,如果这是不相关的,只是创建每个文件GlyphTypeface。

It also seems possible to use GlyphTypeface directly, but I see no way that you can handle .ttc files. However, if that's not relevant, just create a GlyphTypeface per file.

我倒是建议反对尽管尝试所有Unicode代码顺序。

I'd advice against trying all Unicode codepoints sequentially though.

这篇关于C# - 读取和放大器;预览字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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