Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack - special offer!

Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

WinAPI Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
cdtrrracks.com new!

Blogspot  greatis.blogspot.com

Include font from from a resource file - Resource - Tips & Tricks - Greatis Delphi Pages

You should include {$R MyNewFont.RES} line to the implementation section.
For causing from a resource font is necessary to create an object of TResorceStream type and to add font with AddFontResource procedure.
And for including font you should use the WM_FONTCHANGE message.
There is a 'MYFONT' section which contents a font file in the resource file.


{$R MyNewFont.RES}
...
procedure TForm1.FormCreate(Sender: TObject);
var
  MyResStream: TResourceStream;
begin
  MyResStream:=TResourceStream.Create(hInstance, 'MYFONT', RT_RCDATA);
  MyResStream.SavetoFile('Gen4.ttf');
  AddFontResource(PChar('Gen4.ttf'));
  SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
  Label1.Font.Charset:=SYMBOL_CHARSET;
  Label1.Font.Size:=24;
  Label1.Font.Name:='Gen4';
end;
Related topics
Load bitmap from resource DLL
Include jpeg as a resource in *.exe
Play wav sound from a resource file

For more
Delphi Help

Download source