/ Published in: Delphi

Here's how to use a TTF (true type font) in your Delphi application without having to install it in Windows:
In the OnCreate event for the main form in your Delphi application call the AddFontResource API function. The AddFontResource function adds the font resource from the specified file to the system font table.
When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function. Do this in the OnDestroy event for the main form.
In the OnCreate event for the main form in your Delphi application call the AddFontResource API function. The AddFontResource function adds the font resource from the specified file to the system font table.
When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function. Do this in the OnDestroy event for the main form.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
procedure TForm1.FormCreate(Sender: TObject) ; begin AddFontResource('c:\FONTS\MyFont.TTF') ; SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ; end; {Before application terminates we must remove our font:} procedure TForm1.FormDestroy(Sender: TObject; var Action: TCloseAction) ; begin RemoveFontResource('C:\FONTS\MyFont.TTF') ; SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ; end;
Comments
