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 not from a DLL. I want to load from font file.
To activate a font on any version of Windows, navigate to Computer ▸ Local Disk (C:) ▸ Windows ▸ Fonts. Locate the folder you've expanded from the downloaded . zip file, and drag the font files into the Fonts folder.
If the font files are zipped, unzip them by right-clicking the . zip folder and then clicking Extract. Now you'll see the available TrueType and OpenType font files: Right-click the fonts you want, and click Install.
Search for Fonts in settings. Click on the Fonts Folder to open the Font folder. Drag and Drop or Copy and Paste the unzipped fonts files into the Fonts folder to install.
To install the TrueType font in Windows:Click on Start, Select, Settings and click on Control Panel. Click on Fonts, click on File in the main tool bar and select Install New Font. Select the folder where the font is located. The fonts will appear; select the desired font that is titled TrueType and click on OK.
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.
Load a font from disk, stream or byte array
Try this...
The blog describes how to use the FontCollection classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With