By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,670 Members | 1,558 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,670 IT Pros & Developers. It's quick & easy.

Installing a TT-Font

P: n/a
Hi

How would I go about installing a font file on WinXP?

I have tried this and it won't get installed properly,

private void installFont()
{
File.Copy( Application.StartupPath+"\\Lucon1.ttf",
this.fontDir+"\\Lucon1.ttf", true );
key.SetValue( "Lucida Console ANSI
TrueType)", "Lucon1.ttf");
SendMessage((System.IntPtr)HWND_BROADCAST,
WM_FONTCHANGE, 0, 0);
}
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Johan,

Does your app include a Setup Project? Because if you build a setup project
for your app, you can add fonts to it and when the user installs it the
fonts will be automatically installed, and removed upon un-install.

JIM
"Johan" <he***@hotmail.com> wrote in message
news:5e****************************@phx.gbl...
Hi

How would I go about installing a font file on WinXP?

I have tried this and it won't get installed properly,

private void installFont()
{
File.Copy( Application.StartupPath+"\\Lucon1.ttf",
this.fontDir+"\\Lucon1.ttf", true );
key.SetValue( "Lucida Console ANSI
TrueType)", "Lucon1.ttf");
SendMessage((System.IntPtr)HWND_BROADCAST,
WM_FONTCHANGE, 0, 0);
}

Nov 16 '05 #2

P: n/a
Yes I know I could go that way, but I was kind of hoping to just end up with
one exe-file for the application without the need for installation...

/Johan

"James" <no****@hypercon.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Johan,

Does your app include a Setup Project? Because if you build a setup
project for your app, you can add fonts to it and when the user installs
it the fonts will be automatically installed, and removed upon un-install.

JIM
"Johan" <he***@hotmail.com> wrote in message
news:5e****************************@phx.gbl...
Hi

How would I go about installing a font file on WinXP?

I have tried this and it won't get installed properly,

private void installFont()
{
File.Copy( Application.StartupPath+"\\Lucon1.ttf",
this.fontDir+"\\Lucon1.ttf", true );
key.SetValue( "Lucida Console ANSI
TrueType)", "Lucon1.ttf");
SendMessage((System.IntPtr)HWND_BROADCAST,
WM_FONTCHANGE, 0, 0);
}


Nov 16 '05 #3

P: n/a
Hi,

You should rather use the GDI Function AddFontResource by P-Invoke,
shouldn't you? I was searching for sample code demonstrating how to load
the font out of a ttf file but all i found were some functions, one of
them is AddFontResource.

This could be your signature:

[DllImport("gdi32")]
static extern int AddFontResource(string lpszFilename);
// returns the number of fonts installed
This could be your Add font function:

public static bool AddFont(string filename)
{
if (System.IO.File.Exists(filename))
{
// returns true if (>=1) font is installed
return (AddFontResource(filename) != 0);
}
return false;
}

I do not know whether it does the right thing for you, but you may givbe
it a try if it does

Greets,

AS
Nov 16 '05 #4

P: n/a
Oh no, it doesn't work...
Perhaps system font table is something different than system fonts or it
installs the font for the calling app only.

Andreas Schöneck schrieb:
Hi,

You should rather use the GDI Function AddFontResource by P-Invoke,
shouldn't you? I was searching for sample code demonstrating how to load
the font out of a ttf file but all i found were some functions, one of
them is AddFontResource.

This could be your signature:

[DllImport("gdi32")]
static extern int AddFontResource(string lpszFilename);
// returns the number of fonts installed
This could be your Add font function:

public static bool AddFont(string filename)
{
if (System.IO.File.Exists(filename))
{
// returns true if (>=1) font is installed
return (AddFontResource(filename) != 0);
}
return false;
}

I do not know whether it does the right thing for you, but you may givbe
it a try if it does

Greets,

AS

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.