从 C# 应用程序上的文件加载字体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/544972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Load fonts from file on a C# application
提问by FerranB
采纳答案by John Leidegren
There's a class System.Drawing.Text.PrivateFontCollection in System.Drawing.dll which can manage fonts on a per application basis.
System.Drawing.dll 中有一个 System.Drawing.Text.PrivateFontCollection 类,它可以在每个应用程序的基础上管理字体。
All you do is that you maintain this collection within your app and you add fonts through AddFontFile or AddMemoryFont and you'll then be able to use that font as if it was installed on your system.
您所做的就是在您的应用程序中维护此集合,并通过 AddFontFile 或 AddMemoryFont 添加字体,然后您就可以使用该字体,就像它已安装在您的系统上一样。
It's like installing the font for the application only. The font will be uninstalled once the process terminates.
这就像仅为应用程序安装字体。一旦进程终止,字体将被卸载。
回答by Adrian Hum
Load a font from disk, stream or byte array
Try this...
尝试这个...
The blog describes how to use the FontCollection classes.
该博客描述了如何使用 FontCollection 类。