Load fonts from file on a C# application

后端 未结 2 986
旧巷少年郎
旧巷少年郎 2020-12-03 05:02

I wish to load and use a font to a desktop application in C#. It\'s that possible without installing the font on the system?

It\'s a kind of question like this but n

2条回答
  •  既然无缘
    2020-12-03 05:33

    There's a class System.Drawing.Text.PrivateFontCollection in System.Drawing.dll which can manage fonts on a per application basis.

    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.

    It's like installing the font for the application only. The font will be uninstalled once the process terminates.

提交回复
热议问题