Answer the question
In order to leave comments, you need to log in
How to assign a custom font to a label programmatically from a folder without installing the font?
There is a label CategoryLabel1
In the program folder there is a folder with fonts.
How to install a custom font for this label from a folder?
I need a programmatic way to use custom fonts from a folder, since in the future these fonts will be in the combobox, and the settings for these fonts will also be in the settings file.
Font folder:
An example of the name of one custom font:
Answer the question
In order to leave comments, you need to log in
Everything looks simple
// Create our collection of custom fonts
System.Drawing.Text.PrivateFontCollection privateFontCollection = new System.Drawing.Text.PrivateFontCollection();
// Add your TTF font file to it
privateFontCollection.AddFontFile(@"C:\Temp\gothic.ttf");
// Create a Font object by taking the 0th font from the
Font collection customFont = new Font(privateFontCollection.Families[0], 32, FontStyle.Regular, GraphicsUnit.Pixel);
// We register at the label
CategoryLabel1.Font = customFont;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question