Link to home
Start Free TrialLog in
Avatar of kapot
kapot

asked on

Font in Delphi

Hello,

How can I make sure that a font will be available for TEdit and TLabel component?

I meant, I have a TTF font, for example MyFont.TTF .

I want to use it for my TEdit and TLabel, how can I embed and assign it into my app ?

Thanks for any help.
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

As long as the font dialog box that comes with editable components such as a TEdit can see the font then it should be available within the application.
It might not be available if it isnt a True Type Font.
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice .. new one for me :o)
Avatar of CodedK
Hi.
kapot wants fonts to be available in other computers.
Mokule is right.
I wasnt quick enough... :/
Avatar of mhamini
mhamini

hi friend ...
it is so easy ...
just distribute your font file with your program , and then by this code , instal that to target os :

AddFontResource(PChar('yourFont.TTF'));
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
here'san example from
 The Unofficial Newsletter of Delphi Users - Issue #18 - November 1996

on how to embed anything into your exe (i.e. your font, so you can install it on client's computer)

--------------------------------------------------------------------------------

 

Put Anything In Your Delphi EXE!
by William A. Portillo - hallcom@wantree.com.au

I don't know if this is useful stuff but after a couple of weeks of playing with the resources side of Delphi, I ended up writing a routine that will &quotextract" other files out of a Delphi EXE. I found this useful for distributing little picture or sound files with the application or as a setup program with internal files. No doubt many of you will find other uses for this technique.

First, I create an RC project with NOTEPAD.EXE and ARJ.EXE in it as follows (we'll call it RESJUNK.RC):

 NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
 ARJ EXEFILE C:\UTILS\ARJ.EXE
then I compile it with BRCC32 into a RES file. After this I include it in my Delphi project by using the $R compiler directive like this:

{$R RESJUNK.RES}
and extract this files by using the TResourceStream class.

      procedure ExtractRes(ResType, ResName, ResNewName : String);
       var
         Res : TResourceStream;
       begin
         Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
         Res.SavetoFile(ResNewName);
         Res.Free;
       end;