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.
kapotAsked:
Who is Participating?
 
mokuleConnect With a Mentor Commented:
You should deploy this font with application, and use the following from application

on creation
  AddFontResource('FOTOM2.FON');
  SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);


on destroying
  RemoveFontResource('FOTOM2.FON');
  SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);

mokule
0
 
mikelittlewoodCommented:
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.
0
 
mikelittlewoodCommented:
Nice .. new one for me :o)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
CodedKCommented:
Hi.
kapot wants fonts to be available in other computers.
Mokule is right.
I wasnt quick enough... :/
0
 
mhaminiCommented:
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);
0
 
TheRealLokiSenior DeveloperCommented:
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;
0
All Courses

From novice to tech pro — start learning today.