2009. április 10., péntek
How to use True Type fonts without installing
Problem/Question/Abstract:
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:
// first load it in the OnCreate event of a form:
procedure TForm1.FormCreate(Sender: TObject);
begin
AddFontResource('c:\FONTS\MyFont.TTF');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
// before application terminates, we must free it:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
RemoveFontResource('C:\FONTS\MyFont.TTF');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése