Install a font programatically

This forum is for general support of Xbase++
Post Reply
Message
Author
bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Install a font programatically

#1 Post 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.
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Install a font programatically

#2 Post by Auge_Ohr »

bwolfsohn wrote:Has anyone come up w/ a routine to install a font programatically ?
hm ... you need Administrator Rights to install.
greetings by OHR
Jimmy

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Install a font programatically

#3 Post 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..
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Install a font programatically

#4 Post 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' )
The eXpress train is coming - and it has more cars.

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: Install a font programatically

#5 Post 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.
Klaus

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Install a font programatically

#6 Post 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.
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Install a font programatically

#7 Post by rdonnay »

Brian -

Why don't you use the AddFontResourceA API call?
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Install a font programatically

#8 Post 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 ?
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Install a font programatically

#9 Post 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.
The eXpress train is coming - and it has more cars.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Install a font programatically

#10 Post 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.

Post Reply