C # using native font without installing it

Possible duplicate:
How to insert a font using my application in C #? (using Visual Studio 2005)

Hi,

I want to use my own font in the text box without installing it on the client machine. I want it in the folder with the application file. [I know that most gaming applications use their own font). How can i do this?

Thank.

+3
source share
1 answer

I think you need this:

// Be sure to dispose your PrivateFontCollection
// and Font to avoid an easy leak!
System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection();
privateFonts.AddFontFile("c:\myapplication\mycustomfont.ttf");
System.Drawing.Font font = new Font(privateFonts.Families[0], 12);
this.textBox1.Font = font;
+6
source

Source: https://habr.com/ru/post/1777320/


All Articles