Author: Lou Adler
How to use True Type fonts without installing
Answer:
Setting an alternative font for your forms is easy. But how to use your specialized
fonts without the need to fill up your user's FONTS directory? Well, it's just a
few lines, so here we go:
1 // first load it in the OnCreate event of a form:2 3 procedure TForm1.FormCreate(Sender: TObject);
4 begin5 AddFontResource('c:\FONTS\MyFont.TTF');
6 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
7 end;
8 9 // before application terminates, we must free it:10 11 procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
12 begin13 RemoveFontResource('C:\FONTS\MyFont.TTF');
14 SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
15 end;