Page 1 of 1

Install a font programatically

Posted: Thu Sep 04, 2014 1:41 pm
by bwolfsohn
Has anyone come up w/ a routine to install a font programatically ?
in order to do it w/o user intervention, i guess you'd also need to know the default location of fonts.
is there an environmental var that stores the location of fonts for the version of windows you are on ?

i'm looking at marlett, which should be in the fonts on disk, it just may not be installed.

Re: Install a font programatically

Posted: Thu Sep 04, 2014 3:11 pm
by Auge_Ohr
bwolfsohn wrote:Has anyone come up w/ a routine to install a font programatically ?
hm ... you need Administrator Rights to install.

Re: Install a font programatically

Posted: Thu Sep 04, 2014 4:27 pm
by bwolfsohn
Auge_Ohr wrote:
bwolfsohn wrote:Has anyone come up w/ a routine to install a font programatically ?
hm ... you need Administrator Rights to install.
ok..
other than that, the same question still applies..

Re: Install a font programatically

Posted: Fri Sep 05, 2014 7:09 am
by rdonnay
This is how I do it in a customer's application:

Code: Select all

	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", DC_Path(AppName(.t.))+'ZapfDingbats.ttf' )
	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", DC_Path(AppName(.t.))+'IDAutomationHC39M_FREE.otf' )
	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", DC_Path(AppName(.t.))+'FRE3OF9X.TTF' )
	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", DC_Path(AppName(.t.))+'Symbol.ttf' )
	DllCall("GDI32.DLL", DLL_STDCALL, "AddFontResourceA", DC_Path(AppName(.t.))+'Consola.ttf' )

Re: Install a font programatically

Posted: Fri Sep 05, 2014 8:06 am
by Koverhage
is there an environmental var that stores the location of fonts for the version of windows you are on ?
normally this is always c:\windows\fonts

no need to install the font, just copy the ttf to c:\windows\fonts

the font is automatic installed.

Re: Install a font programatically

Posted: Fri Sep 05, 2014 1:08 pm
by bwolfsohn
Koverhage wrote:
is there an environmental var that stores the location of fonts for the version of windows you are on ?
normally this is always c:\windows\fonts

no need to install the font, just copy the ttf to c:\windows\fonts

the font is automatic installed.
tried copying. in windows 7, the font did not automatically install.
when i typed the name of the font in a dos box, and clicked install, it said this font is already installed want to overwrite,
answered yes, and it worked.

Re: Install a font programatically

Posted: Fri Sep 05, 2014 3:46 pm
by rdonnay
Brian -

Why don't you use the AddFontResourceA API call?

Re: Install a font programatically

Posted: Fri Sep 05, 2014 4:04 pm
by bwolfsohn
rdonnay wrote:Brian -

Why don't you use the AddFontResourceA API call?
I plan on using it.. i just wanted to respond that the other method didn't work.,..

do you do any testing to see if that font is installed already ?
if so, how ?

Re: Install a font programatically

Posted: Sat Sep 06, 2014 7:23 am
by rdonnay
You don't need to test.
That's done by the API function.

Those 5 lines of code are called every time the app starts.
It's been working fine for over 2 years with 350 work stations.

Re: Install a font programatically

Posted: Sat Sep 06, 2014 6:14 pm
by Cliff Wiernik
Simply copying to the font folder worked with WinXP. Not entirely with Win7. I found you had to access the fonts via an office program to make certain they were recognized. But the other methods do work.

I also do the font install and select the folder with the new fonts and that works also.