Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Install Barcode Font programmatically 1

Status
Not open for further replies.

newtofoxpro

Programmer
Sep 16, 2007
301
IN
VFP9SP2, Windows 10
With the help of this thread I tried but no success


Code:

1. I have tried myapp.exe run as Administrator
2. At DOS-Prompt CMD.EXE I found FREE3OF9.TTF file exist.
DIR c:\windows\fonts\FREE3OF9.TTF
3. But does not appear in Windows browser c:\windows\fonts

Is it possible to Install Barcode Font programmatically?
 
Sorry, this is the code

lcFontLocFile=GETENV("SYSTEMROOT")+"\FONTS\FREE3OF9.TTF"
=AFONT(gaFontArray)
IF ASCAN(gaFontArray,"Free 3 of 9")=0 OR !FILE(lcFontLocFile)
COPY FILE ("FREE3OF9.TTF") TO (m.lcFontLocFile)
DECLARE INTEGER AddFontResource IN GDI32.DLL STRING @lpszFileName
lnNumFontsAdded=AddFontResource(lcFontLocFile)
ENDIF
 
Instead of installing a new font, why don't you use FoxBarCode instead?

NB! Please don't hide behind a fake name. If you absolutely don't want to reveal your name, at least use something meaningful, something that we can relate to.
 
I need barcode and regional language font also.

Thank you sir, for suggesting FoxBarCode.
 
A permanent font installation is needing administrative permissions.

AddFontResource documentation tells you it will only make a font available to a session, not permanently.

[URL unfurl="true" said:
https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-addfontresourcea[/URL]]This function installs the font only for the current session. When the system restarts, the font will not be present. To have the font installed even after restarting the system, the font must be listed in the registry.

On the other side, you also only need the font in your application, don't you? So you can make the AddFontResource call at every start of your application to be able to use it within your application. Indeed, it then will not list as a font when you browse c:\windows\fonts, because it's not installed, actually, it's just added to the fonts for your own process/application, but this could be sufficient.

If you have the need to create docx or other files that other applications like MS Word should also be able to display and print with that font, the straight forward way is to really install the font with a setup you should do for your application anyway. It's a feature of installers like Inno setup to also install fonts.

Chriss

PS: Regarding the quote end "...the font must be listed in the registry", This is not detailed there, so the simplest option surely is installing the font in the setup of the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top