tags:

views:

519

answers:

3

Hi there.

I have a label on my Winform and I want to use a custom font called XCalibur to make it appear more shnazzy.

If I use a custom font on a label and then build the solution and then .ZIP the files in \bin\Release will the end user see the labels with my custom app I used regardless if they have that font installed or not?

If this isn't the case, what's the proper way to use Custom Fonts on Labels.Text?

A: 

The proper way is to have the font has to be copied to the proper directory under the Windows Folder.

The best way to accomplish this would be to create an installer package.

Add a Setup Project to your solution.

Right click "File System on Target Machine" and open Add Special Folder and select Fonts Folder.

Then add your Font to the Fonts Folder.

Alfred Myers
What if my application isn't meant to be installed but be portable?
Sergio Tapia
I don't know of another way to install the font. Maybe somebody else can tip in.
Alfred Myers
+3  A: 

I think the solution is to embed the desired font into you application.

Try this link:

http://www.emoreau.com/Entries/Articles/2007/10/Embedding-a-font-into-an-application.aspx

P.K
+2  A: 

Embed the font as a resource (or just include it in the bin directory), and then use the PrivateFontCollection to load the font (See the AddFontFile and AddMemoryFont functions). You then use the font normally like it was installed on the machine.

The PrivateFontCollection class allows applications to install a private version of an existing font without the requirement to replace the system version of the font. For example, GDI+ can create a private version of the Arial font in addition to the Arial font that the system uses. PrivateFontCollection can also be used to install fonts that do not exist in the operating system.

Source

Adam Hughes