Reputation: 145
Basically, I am using a custom font in my project, which is installed in my OS. The problem is that on client's PC this font is not installed, so application is using default font.
Is there any way to use that font inside application without every form/control code change? The best solution would be to use font without installing it in system and changing every form/control code.
Upvotes: 0
Views: 452
Reputation: 22559
There's no global setting to do that.
You will need to loops through all the controls in the form recursively, and change the font. Make a Base Form that inherits from Form. Do the recursion.
Then make all your forms inherit from that base form. Use PrivateFontCollection to import the font and change the conrtol font.
var pfc = new PrivateFontCollection();
pfc.AddFontFile(@"C:\MyFont.ttf");
myControl.Font = new Font(pfc.Families[0], 14, FontStyle.Regular);
Upvotes: 1