Special font in Delphi XE2, TLabel

I want to use a special font, like DS-DIGIB for caption in TLabel
It is not currently available.
Is it possible to implement it ?
This URL shows examples of what I need : http://www.dafont.com/theme.php?cat=302
LVL 1
LeTayAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
just install the font in the windows environment

> add the font to c:\windows\fonts
0
LeTayAuthor Commented:
Will try that !
0
jimyXCommented:
If your application is going to work outside your workstation, probably distributed to clients, then you are going to need to supply that font along with your application and use AddFontResource() to make it available before it was used.

Edit:
Do not miss the valuable info at the bottom of the link:
Remarks

Any application that adds or removes fonts from the system font table should notify other windows of the change by sending a WM_FONTCHANGE message to all top-level windows in the operating system. The application should send this message by calling the SendMessage function and setting the hwnd parameter to HWND_BROADCAST.

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.

This function installs the font only for the current session. When the system restarts, the font will not be present. To have the font installed even after restarting the system, the font must be listed in the registry.

A font listed in the registry and installed to a location other than the %windir%\fonts\ folder cannot be modified, deleted, or replaced as long as it is loaded in any session. In order to change one of these fonts, it must first be removed by calling RemoveFontResource, removed from the font registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts), and the system restarted. After restarting the system, the font will no longer be loaded and can be changed.
0
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

jimyXCommented:
Also you could add the font as resource from Delphi menu, go to Project -> Resources and images ... and locate the font file.
0
Sinisa VukSoftware architectCommented:
For such "led" type fonts - it is better to use special components like Jedi's TJvSegmentedLEDDisplay, TJvDigits .. and be font depending ... More on Torry.net
or https://www.tmssoftware.com/site/advsmoothledlabel.asp
0
LeTayAuthor Commented:
I put the font file in my project's directory
Now I can't see it in the font list of my TLabel component
What did I miss ?
0
jimyXCommented:
Did you put in your exe directory?
Normally under your project directory, under "Debug/Win32" or "Debug/Win64".

I tried this and it worked:
//I downloaded the font from here http://dl.dafont.com/dl/?f=ds_digital
//DS-DIGIT.TTF is the one I used from the downloaded fonts

procedure TForm1.FormCreate(Sender: TObject);
begin
  AddFontResource('DS-DIGIT.TTF');
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

  Label1.Font.Name:= 'DS-Digital';
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); // or main form destroy
begin
  RemoveFontResource('DS-DIGIT.TTF');
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;

Also you could have used OnShow/OnActivate to set the font name.
Even you can set it at design time from the OI even if it was not listed it will work.
{procedure TForm1.FormShow(Sender: TObject);
begin
  Label1.Font.Name:= 'DS-Digital';
end;}

Open in new window


Also you could add the font to the registry if you don't want to do this process every time your application is launched.

PS: The font name used in the "Font.Name" should be matching the font name in the TTF file when you open at the very top.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert GOracle dbaCommented:
because the os doesn't look there for any fonts

searching all directories on a windows machine will take a long while to find all existing fonts
a general approach for apps taking minutes to load something ... is to kill the app and try again

put the font in c:\windows\fonts
0
Sinisa VukSoftware architectCommented:
Did you try my suggestion ... until now you would have working solution/form. Special LED components looks better than special LED font.
0
LeTayAuthor Commented:
Sorry, I was travelling for the last three weeks.
I will have a look at your proposal this sunday
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.