Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add fonts to windows from VFP apps
Message
From
08/01/2003 20:23:49
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00738923
Message ID:
00739644
Views:
45
Hi Sergey,

I show below my code ro add fonts to windows OS. I am using WIN2K/98

*-- Add font to windows to print reports
#define HWND_BROADCAST 65535
#define WM_FONTCHANGE 29

Declare INTEGER CreateScalableFontResource IN GDI32.DLL ;
INTEGER fHidden, ;
STRING @lpszResourceFile, ;
STRING @lpszFontFile, ;
STRING @lpszCurrentPath

Declare Integer AddFontResource in gdi32 ;
String lpFileName

DECLARE INTEGER SendMessage IN user32 ;
INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam

if adir(aFonts,[c:\temp\fonts\*.ttf]) > 0
*-- Add font to windows system
for i = 1 to alen(aFonts,1)
copy file ([c:\temp\fonts\]+aFonts[i,1]) to ([c:\windows\fonts\]+aFonts[i,1])
if file([c:\windows\fonts\]+juststem(aFonts[i,1])+[.fot])
delete file ([c:\windows\fonts\]+juststem(aFonts[i,1])+[.fot])
endif
= CreateScalableFontResource(0,[c:\windows\fonts\]+juststem(aFonts[i,1])+[.fot],[c:\temp\fonts\]+aFonts[i,1],[c:\windows\fonts])
= AddFontResource([c:\temp\fonts\]+aFonts[i,1])
= SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
endfor
endif

*-- Make key to registry to permenent install fonts here

*-- Reboot the windows OS here
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform