?
Solved

Font in Delphi

Posted on 2005-03-08
6
Medium Priority
?
589 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:kapot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13487285
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
 
LVL 17

Accepted Solution

by:
mokule earned 260 total points
ID: 13487804
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13487851
Nice .. new one for me :o)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:CodedK
ID: 13487998
Hi.
kapot wants fonts to be available in other computers.
Mokule is right.
I wasnt quick enough... :/
0
 
LVL 1

Expert Comment

by:mhamini
ID: 13489195
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
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13490089
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question